- 
	
	
	
		
Exchange weapons
	
	
		Hello Guys! 
I need a V menu with exchange weapons!
Its how like.. You Press V 9 1 and you must aim on a player to exchange the weapons.
The guy, who was aimed, he must press K to accept exchangeweapons.
The Guy press K and the weapons will exchange :>
I hope you will help me :)
	 
 - 
	
	
	
	
		@Loveboy help of course but I think no one will give you full code... 
Tip: Try to use IsLookingAt() function. (or geteye() function. I don't know which is better in this case so I ask someone with experience btw :))
Here is a great collection of useful functions/scripts - http://www.zeroy.com/script/
	 
 - 
	
	
	
	
		where is IsLookingAt() or geteye() function?
	 
 - 
	
	
	
	
		I will show you based on this code:
	Code:
	
if(self.name == Loveboy)      //<- for example if player got name "Loveboy" then continue
{
       players = getentarray("player", "classname");
       aimedplayer = undefined;              //undefined yet
       for(i = 0; i < players.size; i++)
       {
              if(self islookingat (players[i]) )   //here is used IsLookingAt function... so if player is looking at the target(on other player) then continue also...
              {
                      aimedplayer = players[i];
                      players[i] iprintlnBold("something!")      //this text is visible only for aimed player...
              }
       }
}
 I hope you understand now, if you have questions write.
	 
 - 
	
	
	
	
		Ok, players[i] iprintlnBold("Press K to exchange weapons...") now if the player press k, he will accept and the weapons will exchange.
	 
 - 
	
	
	
	
		so now we need the continue the script..
	 
 - 
	
	
	
	
		Now you can add a loop on aimedPlayer, which is checking useButtonPressed() for like 5 seconds.
	 
 - 
	
	
	
	
		kung, sorry i am not good in english and i am bad in script. pls explain me not just write a script pls :D
	 
 - 
	
	
	
	
		Hope I'm able to explain what Kungy means in a newbie way.
You need to add a loop: while() or for(;;)
a loop is something that does the same thing over and over again
example:
seconds = 0;
while(seconds < 5)
{
    wait 1;
    seconds += 1;
}
This loop counts the seconds and after 5 seconds the loop stops.
In such a loop you can check, whether the aimedplayer pressed the useButton(that standardly is the 'F' Button)
if(aimedPlayer useButtonPressed())         //if aimedPlayer pressed the useButton(F-Button) the function exchangeWeapons is called.
   player exchangeWeapons(aimedPlayer);
you could write a thread exchangeWeapons(player){} where 'self' and 'player' exchange the weapons in.
This is just an example and I'm pretty sure this won't work the way you want it to work. I just wanted to explain the loop and stuff to you, at least as best as I can.
Hope this could help you a little, even though I'm not that good at explaining, I'm aware of that.
	 
 - 
	
	
	
	
		so could work this?
       players = getentarray("player", "classname");
       aimedplayer = undefined;              //undefined yet
       for(i = 0; i < players.size; i++)
       {
              if(self islookingat (players[i]) )   //here is used IsLookingAt function... so if player is looking at the target(on other player) then continue also...
              {
                      aimedplayer = players[i];
                      players[i] iprintlnBold("Press F to exchange weapons with "players.name" ")      //this text is visible only for aimed player...
	   if(aimedPlayer useButtonPressed()) //if aimedPlayer pressed the useButton(F-Button) the function exchangeWeapons is called.
		{
	   player exchangeWeapons(aimedPlayer);
	   aimedPlayer exchangeWeapons(player);
              }
       }
	 
 - 
	
	
	
	
		That's at least a start.
The problem in this case would be that the player, who is being asked to exchange weapons, had only like a millisecond of time to press the F-Button, since you only check once if he pressed the button. That's where while() is used.
	Code:
	
players = getentarray("player", "classname");
aimedplayer = undefined; //undefined yet
selfweapon = self getCurrentWeapon();
otherweapon = undefined;
for(i = 0; i < players.size; i++)
{
    if(self islookingat (players[i]) ) //here is used IsLookingAt function... so if player is looking at the target(on other player) then continue also...
    {
        aimedplayer = players[i];
        otherweapon = aimedplayer getCurrentweapon();
        aimedplayer iprintlnBold("Press F to exchange weapons with " + players.name); //this text is visible only for aimed player...
    }
}
secs = 0.0;
while(secs < 5)
{
    if(aimedplayer useButtonPressed())
    {
        self thread exchangeWeapons(aimedPlayer, selfweapon, otherweapon);
        return;
    }
    wait .05;
    secs += 0.05;
}
self iprintlnBold(aimedplayer.name + " did not want to exchange weapons with you"); //A note for the player
 Then you will need the exchangeWeapons() function.
	Code:
	
//aimedPlayer = Player who was aimed, selfweapon = weapon of the guy who asked for weaponexchange, otherweapon = weapon of the other guy
exchangeWeapons(aimedPlayer, selfweapon, otherweapon)
{
    //give 'selfweapon' to 'aimedPlayer
    //give 'otherweapon' to 'self'
}