Assign everyone a random 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: Assign everyone a random ID (
/showthread.php?tid=91899)
Assign everyone a random ID -
Hecky - 17.08.2009
Hey,
I need help with something. Can anyone show me how to assign every player in a server with a random ID, from 0 to however many players there are? I'm trying not to use a loop that keeps going around until everyone has a unique ID.
Thanks
Re: Assign everyone a random ID -
Hecky - 17.08.2009
Update :
Код:
for(new i = 0; i<MAX_PLAYERS; i++)
{
for(new p = 0; p<MAX_PLAYERS; p++)
{
for(new a = 0; a<MAX_PLAYERS; a++)
{
if(gPlayerData[p][ID] == 255)
{
gPlayerData[p][ID] = a;
}
}
}
}
It's a bit messy, but I think that'll do the job (ID 255 is used to show that the player has no ID)