SQLite question
#4

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?
Reply


Messages In This Thread
SQLite help needed - by LocMax - 02.06.2014, 16:49
Re: SQLite question - by Konstantinos - 02.06.2014, 16:56
Re: SQLite question - by LocMax - 02.06.2014, 17:06
Re: SQLite question - by LocMax - 02.06.2014, 17:55
Re: SQLite question - by Konstantinos - 02.06.2014, 18:32
Re: SQLite question - by LocMax - 03.06.2014, 04:39

Forum Jump:


Users browsing this thread: 2 Guest(s)