SA-MP Forums Archive
Working with auto incriminate - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Working with auto incriminate (/showthread.php?tid=392320)



Working with auto incriminate - thefatshizms - 13.11.2012

Ok, im creating a business system and i want each business that's created to have its own unique ID so i can tell which business it is and do stuff with it. How exactly can i do this with auto incriminate (mysql) ?


Re: Working with auto incriminate - Ballu Miaa - 13.11.2012

Create the database and set the part as AUTO_INCREMENT which you want to increment everytime some data is inserted into the fields.

pawn Код:
`id` int(20) NOT NULL AUTO_INCREMENT
Example of creating a database via pawn:
pawn Код:
format(query,sizeof(query),"CREATE TABLE IF NOT EXISTS `Business`(`id` int(20) NOT NULL AUTO_INCREMENT,`owner` varchar(26) DEFAULT NULL,`bname` varchar(40) DEFAULT NULL,`x` float(20) DEFAULT NULL,`y` float(20) DEFAULT NULL,`z` float(20) DEFAULT NULL,");
    strcat(query,"`world` int(10) DEFAULT NULL,`interior` int(10) DEFAULT NULL,`entangle` float(20) DEFAULT NULL,`exangle` float(20) DEFAULT NULL,`locked` int(5) DEFAULT NULL,`price` int(30) DEFAULT NULL,`forsale` int(5) DEFAULT NULL,`cash` int(15) DEFAULT NULL,");
    strcat(query,"`stock` int(10) DEFAULT NULL,`time` int(20) DEFAULT NULL,PRIMARY KEY (`id`))");
    mysql_query(query);
Now on INSERT INTO part you do not need to insert in 'id' field with this type of code.


Re: Working with auto incriminate - thefatshizms - 13.11.2012

Oh ok i thought it would be more complex than that, so each time i enter a form of data it automatically updates that's great news.