View Full Version : random kill
malyczolg
5th February 2013, 20:15
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
Cz3koladowyPotwor
5th February 2013, 22:05
maybe do something alone, then we can help you :)
Script killing a random player from the selected team.
player = getRandomPlayer("allies"); //here u can change team to axis :P
player suicide();
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;
}
randall
5th February 2013, 22:11
script()
{
setCvar("randomkill", "");
for (;;)
{
if (getCvar("randomkill") != "")
{
players = getEntArray("player", "classname");
randomPlayer = players[ randomInt( players.size ) ];
if (randomPlayer.sessionstate == "playing")
randomPlayer suicide();
}
wait 1;
}
}
IzNoGoD
5th February 2013, 23:01
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
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.