17.02.2011, 10:30
hi...
I'm using a msql db and I made a /setlvl cmd...
always when I use it my server crashes... any idea why?
I'm using a msql db and I made a /setlvl cmd...
pawn Код:
new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
if((PlayerData[playerid][Level] >= 3) || (IsPlayerAdmin(playerid) && !strcmp(name, "MrX", true)))
{
new tmp[256], idx, pid;
tmp = strtok(params, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, GREY, "Useage: /setlvl [id/name] [0-3]");
if(!IsNumeric(tmp)) pid = GetPlayerIDFromName(tmp);
else pid = strval(tmp);
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, GREY, "Player not found");
tmp = strtok(params, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, GREY, "Useage: /setlvl [id/name] [0-3]");
if(!IsNumeric(tmp) || strval(tmp) > 3 || strval(tmp) < 0) return SendClientMessage(playerid, GREY, "Level must be 0 - 3");
new lvl = strval(tmp);
new name2[MAX_PLAYER_NAME], string[100], query[150];
GetPlayerName(pid, name2, sizeof(name2));
format(string, sizeof(string), "*You set %s's level from %d to %d", name2, PlayerData[pid][Level], lvl);
SendClientMessage(playerid, GREY, string);
format(string, sizeof(string), "*Your level was set from %d to %d", PlayerData[pid][Level], lvl);
SendClientMessage(pid, GREY, string);
format(string, sizeof(string), "[SERVER]%s changed %s level from %d to %d", name, name2, PlayerData[pid][Level], lvl);
Log(string);
print(string);
format(query, sizeof(query), "UPDATE `User` SET `Level`='%d' WHERE `Name`='%s'", lvl, name2);
mysql_query(query);
PlayerData[pid][Level] = lvl;
}