Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: KrlozZ... on May 02, 2018, 08:33 AM

Title: Help with ID Accounts
Post by: KrlozZ... on May 02, 2018, 08:33 AM
Hello, well i use IDS for my accounts and its a problem since account 999, my function to add a new id is;
local o = QuerySQL( db, "SELECT MAX(ID) FROM Accounts" );
local asd = GetSQLColumnData( o, 0 )+1;

let me explain, when you register, it check the last ID and add the new account with another ID +1, but since account ID 999, it made 9991 account instead of 1000, do you have another way to do it, or to fix it ?
Title: Re: Help with ID Accounts
Post by: Xmair on May 02, 2018, 10:08 AM
Use
GetSQLColumnData( o, 0 ).tointeger() + 1;GetSQLColumnData returns a string afaik.
Title: Re: Help with ID Accounts
Post by: KrlozZ... on May 03, 2018, 03:19 AM
Quote from: Xmair on May 02, 2018, 10:08 AMUse
GetSQLColumnData( o, 0 ).tointeger() + 1;GetSQLColumnData returns a string afaik.

oh nice it works, but it taking always the max as 999, not taking the real max which is 1477, so how to take correctly the max ID ?,
Title: Re: Help with ID Accounts
Post by: Saiyan Attack on May 03, 2018, 07:22 AM
hmm, what type you prefer in db "NUMERIC" and "INTEGER" for ID column? If you are using these one. Then try to use "INTEGER PRIMARY KEY" this will automatically generates total number of your account. i mean to say, it works exactly you want. there is no need to add extra things. just skip this line while inserting account info ...