sqlite not updating
#1

I use sqlite, and I've been spending a lot of time trying to figure out why the admin level will not update. I am level 5 admin IG (set from DB) and I am make admining myself to 0 which works fine, but when I disconnect and reconnect I am back to being a level 5 admin. Any ideas why this isn't updating?


Quote:

public OnPlayerDisconnect(playerid, reason)
{
new query[400], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(query, sizeof(query), "UPDATE `USERS` SET SCORE = '%d', ADMIN = '%d' WHERE `NAME` = '%s'",
PlayerInfo[playerid][pScore],
PlayerInfo[playerid][pAdmin]);
db_query(Database, query);
return 1;
}

Quote:

CMD:makeadmin(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] <= 4) return SendClientMessage(playerid, COLOR_CMDHELP,"ErRor: You are not authorized to use this");
new id, level;
if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid, COLOR_CMDHELP, "Usage: /makeadmin [PlayerID/PartOfName] [Level]");
else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_CMDHELP, "ERor: Invalid [PlayerID/PartOfName]");
else if(level > 5) return SendClientMessage(playerid, COLOR_CMDHELP, "ErrOr: An admin level cannot be higher then 5!");
else
{
PlayerInfo[id][pAdmin] = level;
}
return 1;
}

Reply
#2

pawn Код:
format(query, sizeof(query), "UPDATE `USERS` SET SCORE = '%d', ADMIN = '%d' WHERE `NAME` = '%s'",
PlayerInfo[playerid][pScore],
PlayerInfo[playerid][pAdmin],
name);
You forgot to format the name. When this happens, just print the query, and you can see how it is being written out on your server console, making it tons easier to see what's wrong, also I'm pretty sure you don't need a 400 cell-sized query to update two collumns.
Reply
#3

You are missing the username on your query.
Reply
#4

Thank you SO much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)