Posts: 247
Threads: 28
Joined: Jan 2014
Reputation:
0
Can someone help me? I wanted to make a cell phone system but I don't know how to give a players a unique cell phone number like 079-6336-2793 the 079 part needs to always be the same? If some one could help I will rep the ones who help. Thanks in advance.
Posts: 843
Threads: 61
Joined: Feb 2013
Reputation:
0
Use random() to get a some number and give it to the player. Save the number into a file or a database. The next time when someone gets a random value for their phone number, go through the database/file and check if the number exists. If it does, generate a new number.
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
Saving system? If you use MySQL, create a new table to link a phone number to a player and set the number to be the primary key and auto increment. That way it's guaranteed to be unique.
You could also append the current Unix timestamp (returned by gettime()), although that may make the number too long. It also won't be unique if two or more players are assigned a number at the same second.
A third way, that also relies on SQL's auto increment, is to append the players' unique identifier, along with some random numbers.
Posts: 247
Threads: 28
Joined: Jan 2014
Reputation:
0
I'm using y_ini as I struggle with sql I have try many of times but prefer ini
Posts: 247
Threads: 28
Joined: Jan 2014
Reputation:
0
Could I do it the same way you would when giving a player a level but start at a high number and automatically give them the number upon account creation and only allow them to use it once they have a cell phone
Sorry for the double post.
Posts: 3,324
Threads: 96
Joined: Sep 2013
25.05.2015, 17:47
(
Последний раз редактировалось Crayder; 25.05.2015 в 20:51.
)
Start with a 'key' number, save it as the key in a file. Then when someone wants a number, load the key add a random number between 1 or 10. save the new number as their number and the new key.
PS. This has been my method for a while.