random connected id - 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 connected id (
/showthread.php?tid=120040)
random connected id -
Headshot1108 - 10.01.2010
hey,
how i can select a random id that connect in the server?
maybe:
pawn Код:
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
...
}
}
but more i dont know.
Re: random connected id -
Correlli - 10.01.2010
pawn Код:
RANDOM_CODE:
new
randomPlayer;
randomPlayer = random(MAX_PLAYERS);
if(IsPlayerConnected(randomPlayer))
{
// connected.
}
else
{
goto RANDOM_CODE;
}
Re: random connected id -
Streetplaya - 10.01.2010
Quote:
Originally Posted by Don Correlli
pawn Код:
new randomPlayer; randomPlayer = random(MAX_PLAYERS); if(IsPlayerConnected(randomPlayer)) { // connected. } else { // not connected. }
|
That unfortunately won't work very well..
It would return "Not connected" too often, and it would be quite inefficient in a loop
Re: random connected id -
Correlli - 10.01.2010
Depends where you want to use it.
Re: random connected id -
Finn - 10.01.2010
Start using
foreach.
pawn Код:
new randomplayer = Itter_Random(Player);
Re: random connected id -
Headshot1108 - 10.01.2010
i like to use it in a mission.
example: i type /mission and than comes: go an kill id 5.
and 10 players are connectet, therefore don't select id 20 or so.