Random? - 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: Random? (
/showthread.php?tid=259885)
Random? -
dorotej - 06.06.2011
someone know how to select a random player?
Re: Random? -
WooTFTW - 06.06.2011
pawn Код:
stock SelectRandomPlayer()
{
new random = Random(MAX_PLAYERS);
if(IsPlayerConnected(random))
{
return random;
}
else
{
SelectRandomPlayer();
}
}
Now you can use it for example like this:
pawn Код:
new randomplayer = SelectRandomPlayer();
SetPlayerHealth(randomplayer, 100);
You can make the code efficent tho.
Or you can use foreach include, for more efficent random player selecting.
Re: Random? -
dorotej - 06.06.2011
thanks for help guys