Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[HOWTO] Create User No

Newbie Spellweaver
Joined
Dec 23, 2008
Messages
46
Reaction score
29
Ok, here is how you create a user_no for the database

PHP Code
PHP:
$dk_time=strftime("%y%m%d%H%M%S");
list($usec1, $sec1) = explode(" ",microtime());
$dk_user_no=$dk_time.substr($usec1,2,2);

echo $dk_user_no;

Lets explain that:
strftime = "%y%m%d%H%M%S" = Year - Month - Day - Hour - Minutes - Seconds
NOTE: Year is only displayed with the last 2 digits!
NOTE: If we want the full year like 2011 we use a capital Y

That creates a time like: 110101
Ok then, if 20 uses register on that day, we need to add something more to it
so all users have a special code
for that we use microtime()

that gives us: 0.14240300 1293893126
we create a list so we need to delete some crap that microtime is saying
we need to cut the 2 number is 2 parts

PHP:
list($usec1, $sec1) = explode(" ",microtime());

$usec1 = 0.14240300
$sec1 = 1293893126
and we explode the space between the numbers, cuz we dont need that
we are gonna use the 1st line called $usec1

then we subtract the last and first 2 digits, we dont need that :)
then add it all together

PHP:
$dk_time.substr($usec1,2,2);

then we can give it a variable called $dk_user_no

It will result in:

11010115483761

Again:

11 => Year
01 => Month
01 => Day
15483761 => Special code created from the time

There you go :)
 
Back
Top