SA-MP Forums Archive
Phone 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: Phone Numbers (/showthread.php?tid=128795)



Phone Numbers - Satalone - 19.02.2010

Hey guys, i made a system on my server that everyplayer gets an ID like a number and for example 4 digits, i made it to be random, and it works fine.

Here is my problem - The system it self is giving out people random numbers and there is a possibility that 2 players might have the same number, so how can i make it that if one player already has the number different player won't have that number. I know its a bunch of scripting to do with checking for an ID and all, so if anyone can help me out with this one. Or a different system where it follows so first player will get an ID 1, second player will get an ID 2 etc.


Re: Phone Numbers - Norn - 19.02.2010

Quote:
Originally Posted by Satalone
Hey guys, i made a system on my server that everyplayer gets an ID like a number and for example 4 digits, i made it to be random, and it works fine.

Here is my problem - The system it self is giving out people random numbers and there is a possibility that 2 players might have the same number, so how can i make it that if one player already has the number different player won't have that number. I know its a bunch of scripting to do with checking for an ID and all, so if anyone can help me out with this one. Or a different system where it follows so first player will get an ID 1, second player will get an ID 2 etc.
You could use mysql to store phonenumbers or a folder with all the numbers stored there, run a loop and get the next available phone number.


Re: Phone Numbers - Satalone - 19.02.2010

How about make it like, If player Connects he gets an ID 1 next player connects he gets an Id 2 and like if 100th player connects he will get an Id 100, this way they will never repeat.


Re: Phone Numbers - Norn - 19.02.2010

Quote:
Originally Posted by Satalone
How about make it like, If player Connects he gets an ID 1 next player connects he gets an Id 2 and like if 100th player connects he will get an Id 100, this way they will never repeat.
Try it


Re: Phone Numbers - Satalone - 19.02.2010

how do i try it when im a goon at scripting


Re: Phone Numbers - Norn - 19.02.2010

Quote:
Originally Posted by Satalone
how do i try it when im a goon at scripting
You won't learn if you don't attempt!


Re: Phone Numbers - Satalone - 19.02.2010

True, i don't try to ask for help (as much) but things like this one, at least put me on the right track


Re: Phone Numbers - Norn - 19.02.2010

Quote:
Originally Posted by Satalone
True, i don't try to ask for help (as much) but things like this one, at least put me on the right track
Just make it randomize 3 numbers and make the 4th number there playerid, although the player number will in most cases be more than 1 character.

Or as you said you could just run a loop, but i think this would be easier.

Norn


Re: Phone Numbers - Satalone - 19.02.2010

No i mean like.
Here i start a server, so the first player that connects get a PlayerNumber 1 so like when second player connects he gets a PlayerNumber 2, and these numbers go in players file so next time same player connects he will have a PlayerNumber - 1 and so on, so like when some random guy connects on my server he will also get an ID so if he is the 100th player on my server he will get an PlayerNumber 100 and my thousand's player will get an id 1000, see where im goin with this?


Re: Phone Numbers - Norn - 19.02.2010

What you mean like this?

Top Of Script
pawn Код:
new JoinCounter = 0;
OnPlayerConnect
pawn Код:
JoinCounter = JoinCounter + 1;
    dini_IntSet("count.ini", "Connections", JoinCounter);
    new string[128];
    new UniquePlayerNumber[MAX_PLAYERS];
    UniquePlayerNumber[playerid] = JoinCounter;
    format(string,sizeof(string),"You are player number %d.", UniquePlayerNumber[playerid]);
    SendClientMessage(playerid, COLOR_WHITE, string);
OnGameModeInit
pawn Код:
if(fexist("count.ini"))
    {
      JoinCounter = dini_Int("count.ini", "Connections");
    }
    else
    {
      dini_Create("count.ini");
      dini_IntSet("count.ini", "Connections", 0);
    }