SA-MP Forums Archive
Random Cellphone Numbers - 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 Cellphone Numbers (/showthread.php?tid=138672)



Random Cellphone Numbers - Torran - 02.04.2010

How can i make it, Like on roleplays,
Like it gives player a random cellphone number with 5 digits,
But it cant be the same as someone else, How would i do that?


Re: Random Cellphone Numbers - Norck - 02.04.2010

Example:
Код:
//Somewhere
new found = 0;
do
{
new phnum = 10000+random(9000);
PlayerInfo[playerid][pPhone] = phnum;
for(new i=0;i<MAX_PLAYERS;i++)
{
  if(IsPlayerConnected(i))
  {
    if(PlayerInfo[i][pPhone] == phnum)//If someone got the same number
    {
      found = 1;
    }
  }
}
}
while(found == 1);//Will generate random 5 digit number, until it will be unique
I don't know what variable do you use to store player's phone number. In this example it's PlayerInfo[playerid][pPhone].
Hope it helps