• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[HOWTO] Create Coins ID

Newbie Spellweaver
Joined
Dec 23, 2008
Messages
46
Reaction score
29
Every character that did visit the D-Shop gets a unique ID, witch is different from the user_no
I know its retarded but we have to deal with it
so lets look at the SP in the database:

PHP:
/****** Object:  Stored Procedure dbo.BL_CreateIdCode    Script Date: 2006-5-25 13:03:36 ******/

CREATE PROCEDURE  dbo.BL_CreateIdCode
@o_id_code		varchar(20) 		OUTPUT	
AS
BEGIN
	
	DECLARE @serv_code  char(2)
	DECLARE @rand_seqno varchar(12)
	DECLARE @rand_code varchar(36)
	SET @serv_code = '01'
	SET @rand_code = newid() 
	SET @rand_seqno = SubString(@rand_code, 1, 8) + SubString(@rand_code, 10, 4)
	SET @o_id_code = @serv_code + CONVERT(VARCHAR(6), GetDate(), 12) +  @rand_seqno

END

GO

And his user_no is: 09082414173865
but we dont need that yet!

we need to create a code like: 010909167956B7D86FEB

01 => The server ID code (normaly 01)
090916 => The date (year month day)
7956B7D86FEB => A random 12 number & letter code

we can make one with the following code

PHP:
<?php

//-----------------------------------------------------
// This is for MSSQL newid()
function create_newid($length, $characters){

	if ($characters == ''){ return ''; }
	$chars_length = strlen($characters)-1;
	
	mt_srand((double)microtime()*1000000);
	
	$newid = '';
	while(strlen($newid) < $length){
		$rand_char = mt_rand(0, $chars_length);
		$newid .= $characters[$rand_char];
	}
	
	return $newid;

}
//-----------------------------------------------------


// Server code is always 01
$serv_code = '01';

// Create a random code
$rand_code = create_newid(12, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890');

// Get the ymd date
$date = date("ymd");

// Add it all toghter
$o_id_code = $serv_code . '' . $date . '' . $rand_code;

// echo out the code
echo $o_id_code; 

?>

Now insert into a db

PHP:
INSERT INTO user_cash
    (
    id,
    user_no,
    group_id,
    amount,
    free_amount
    )
VALUES
    (
    $o_id_code, // the code we just created
    $i_user_no, // the user_no
    '01', // the group code => should be 01
    '0', // the amount
    '0' // the free amount
    )

this should work, if not ..... let me know :D
 
Back
Top