Random Cellphone Numbers
#1

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?
Reply
#2

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)