SQL Registring player system by ID - 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: SQL Registring player system by ID (
/showthread.php?tid=336109)
SQL Registring player system by ID -
[WSF]ThA_Devil - 21.04.2012
Hello everyone, I would really need help with SQL Lite player id system...
I am not so experienced with SQL's so please can you answer my 2 questions down below?
1st. How can i get biggest id already registred?
2. How can i make it to start from 0 and increase itself after registraton?
Thanks
Re: SQL Registring player system by ID -
[MG]Dimi - 21.04.2012
1)
pawn Код:
SELECT `ID` FROM `Accounts` ORDER BY `ID` DESC LIMIT 1
`ID` is column in which ID is stored, `Accounts` is table where IDs are stored. Change them to your own.
2) To get auto increse on each new row, make column ID in Table and select AUTO_INCREMENT. It will put number one time higher than last one on each row entry.
Re: SQL Registring player system by ID -
[WSF]ThA_Devil - 21.04.2012
Quote:
Originally Posted by [MG]Dimi
1)
pawn Код:
SELECT `ID` FROM `Accounts` ORDER BY `ID` DESC LIMIT 1
`ID` is column in which ID is stored, `Accounts` is table where IDs are stored. Change them to your own.
2) To get auto increse on each new row, make column ID in Table and select AUTO_INCREMENT. It will put number one time higher than last one on each row entry.
|
Thanks
Re: SQL Registring player system by ID -
[WSF]ThA_Devil - 21.04.2012
pawn Код:
db_query(Database, "CREATE TABLE IF NOT EXISTS `USERS` (`ID` AUTO_INCREMENT,`NAME`, `PASSWORD`, `IP`, `SCORE`, `CASH`, `ADMIN`, `VIP`)");
It always return me nuber 0 when trying to get ids count his way:
pawn Код:
format(Query, sizeof(Query), "SELECT `NAME` FROM `USERS` WHERE `NAME` = '%s' ",name);
Result = db_query(Database, Query);
if(db_num_rows(Result))
{
new Field[ 20 ];
db_get_field_assoc(Result, "ID", Field, 30);
format(Query, sizeof(Query), "**%s has registred making the total of %i players registred.", name, Field);
SendClientMessageToAll(0xFFFFFFAA,Query);
}