Results 1 to 4 of 4

Thread: random kill

  1. #1
    Private First Class
    Join Date
    Feb 2013
    Posts
    201
    Thanks
    4
    Thanked 10 Times in 7 Posts

    random kill

    hello
    i new on this forum , i need scrpt : random kill allies player
    /rcon randomkill and player died .

    plz help me
    sry for bad english

  2. #2
    Private
    Join Date
    Dec 2012
    Posts
    20
    Thanks
    0
    Thanked 14 Times in 7 Posts
    maybe do something alone, then we can help you

    Script killing a random player from the selected team.

    Code:
    player = getRandomPlayer("allies"); //here u can change team to axis :P
    player suicide();
    Code:
    getRandomPlayer(team)
    {
       teamPlayers = [];
    
       players = getentarray("player", "classname");
    
       for(i=0; i<players.size; i++)
       {
          plr = players[i];
    
          if(isDefined(plr.pers["team"]) && plr.pers["team"] == team)
             teamPlayers[teamPlayers.size] = plr;
       }
    
    
       if(teamPlayers.size > 0)
          return teamPlayers[randomInt(teamPlayers.size)];
       else
          return undefined;
    }
    Last edited by Cz3koladowyPotwor; 5th February 2013 at 21:19.

  3. The Following 2 Users Say Thank You to Cz3koladowyPotwor For This Useful Post:

    kung foo man (5th February 2013),randall (5th February 2013)

  4. #3
    Private
    Join Date
    Jan 2013
    Location
    Hungary
    Posts
    113
    Thanks
    10
    Thanked 74 Times in 45 Posts
    Code:
    script()
    {
    	setCvar("randomkill", "");
    
    	for (;;)
    	{
    		if (getCvar("randomkill") != "")
    		{
    			players = getEntArray("player", "classname");
    			randomPlayer = players[ randomInt( players.size ) ];
    
    			if (randomPlayer.sessionstate == "playing")
    				randomPlayer suicide();
    		}
    
    		wait 1;
    	}
    }

  5. The Following User Says Thank You to randall For This Useful Post:

    kung foo man (5th February 2013)

  6. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    please, please, please doublecheck if player is actually defined to prevent developer 1 crashes...

    You specifically made a function that CAN return undefined but you do not check for it :S

Posting Permissions

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