How to random some player in server - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to random some player in server (
/showthread.php?tid=187522)
How to random some player in server -
gunnrcrakr - 03.11.2010
I want to random 5 players to be Zombie when Payday, How i do ? Thanks
Re: How to random some player in server -
dark_clown - 03.11.2010
lots of work
but try
this
or
this
Re: How to random some player in server -
Grim_ - 03.11.2010
pawn Код:
// In the payday thing;
new count, selected[5];
while(count < 5)
{
new id = random(MAX_PLAYERS);
if(IsPlayerConnected(id))
{
if(selected[0] != id && selected[1] != id && selected[2] != id && selected[3] != id && selected[4] != id)
{
selected[count] = id;
count++;
}
}
}
You may also want to add a check if there are 5 players on the server. If there aren't, that will run forever. Also this is not the most effective way, but it will probably do the trick.