Making IDs be codes?

Forum
Last Post
Threads / Messages

Empress_Swanbottom

Member
Member
Joined
Feb 6, 2013
Messages
48
Points
0
Age
26
Mysidian Dollar
4,241
(*shrinks away* Sorry about all the questions.)

I was wondering if there is a way to make the system change IDs to codes. Like instead of 1, it be something like Ag3dv2?
 
Yes, that could be possible but be a little bit complicated.

As an example:
When you want that all the adoptables get such a code, you need first change your mysql-database. Search with phpMyAdmin (You can find it over the CP of your serverhost) for the _owned_adoptables table and change the table column 'aid' to no AUTO_INCREMENT. Now we need to set the id manually when a new pet gets adopted.

Now we need to edit every file which gives new pets to the users (breeding.php/ doadopts.php). Before the script insert the new pet in the database we need to give it a unique id:

PHP:
$timestamp = time();
$id = md5($timestamp);

//first we select the current servertime (time()) than we encode it with md5
//I haven't test this script, it's only an example

 $mysidia->db->insert("owned_adoptables", array("aid" => $id, "type" => $row->type, "name" => $name, "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
			                                            "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$rand], "lastbred" => 0));

(Sorry for my bad english. Hope it's understandable)
 
Well silverdragontears did this before, you may ask her how it is done. Just a quick note though, it is an irreversible change and you wont be able to use the upgrader when a new version is released. Be careful with your decision.
 
^_^ Okay, thanks. :)
Also, couldn't I put $ as the values instead? I read somewhere that $ are counted as variables, so if I've got, for say, five $ in the values area then it'd just put out codes like Af3tx, hgeWb, 8ebab, etc. right?
 
Last edited:
Well silverdragontears did this before, you may ask her how it is done. Just a quick note though, it is an irreversible change and you wont be able to use the upgrader when a new version is released. Be careful with your decision.

^This. ANY modifications you make, you won't be able to use the upgrader or you lost them all. And each time Mys is updated, most likely you'll have to recode your modifications because of the difference in the Mys coding.

I do know how to do it, but right now I just don't have the time as I'm running two sites and am in the process of updating SA.

You have to generate the codes and then put that piece of script in every single file that assigns ids to the adopts.
 
Okay, thank you Silver. And I completely understand. ^_^ What you're doing for ToD and SA is awesome.


I thought I found a way in functions_rand, but it didn't work. :(
 
Last edited:
I found out how to manually make the number IDs be codes, but that could get kinda crazy and hectic as we get more people on my site... o.o
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,130
Members
1,603
Latest member
Monako
BETA

Latest Threads

Latest Posts

Top