Phone Numbers
#1

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

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.
Reply
#3

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.
Reply
#4

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
Reply
#5

how do i try it when im a goon at scripting
Reply
#6

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!
Reply
#7

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

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
Reply
#9

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

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);
    }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)