Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: Exchange weapons

  1. #11
    Private
    Join Date
    Jul 2012
    Posts
    76
    Thanks
    9
    Thanked 56 Times in 38 Posts
    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'
    }
    Last edited by Peterlankton; 30th December 2012 at 10:25.

  2. The Following User Says Thank You to Peterlankton For This Useful Post:

    kung foo man (30th December 2012)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •