Well, just now I re-scripted it with help of Konstantinos' tutorial, but I get an error when player disconnects, the stats aren't saved.
OnPlayerDisconnect
pawn Code:
new Query[185], DBResult:Result;
format(Query, sizeof(Query), "UPDATE users SET ip = %s, money = %d, score = %d, kills = %d, deaths = %d, adminlevel = %d, viplevel = %d WHERE name = '%s'",
PlayerInfo[playerid][IP], PlayerInfo[playerid][Money], GetPlayerScore(playerid), PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][Admin], PlayerInfo[playerid][VIP], DB_Escape(PlayerName(playerid)));
Result = db_query(BFU, Query);
if(Result) printf("SQLITE: account of %s - SAVED.", PlayerName(playerid));
else if(!Result) printf("SQLITE ERROR: account of %s - NOT SAVED.", PlayerName(playerid));
db_free_result(Result);
OnGameModeInit
pawn Code:
db_query(BFU, "CREATE TABLE IF NOT EXISTS users (name VARCHAR(24) COLLATE NOCASE, password VARCHAR(24), ip VARCHAR(16), money INTEGER DEFAULT 0 NOT NULL, score INTEGER DEFAULT 0 NOT NULL, kills INTEGER DEFAULT 0 NOT NULL, deaths INTEGER DEFAULT 0 NOT NULL, adminlevel INTEGER DEFAULT 0 NOT NULL, viplevel INTEGER DEFAULT 0 NOT NULL)");
I can't manage to see the mistake, help?