12.07.2014, 15:58
Whenever someone gets banned( Well, preferably the /ban cmd ), the server starts bugging out.
It causes people to have FPS spikes, "database errors" etc.
Code;
OnGameModeInit
Ban command
Some 'debug' stuff ( console );
Why does the ban stuff cause the WHOLE( or just `USERS` ) database to bug out? e_e
Should i add "if(!Banned[ playerid ])" when it updates the account stats ( @OnPlayerDisconnect )?
It causes people to have FPS spikes, "database errors" etc.
Code;
OnGameModeInit
pawn Код:
db_query(CnR, "CREATE TABLE IF NOT EXISTS `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`)");
pawn Код:
CMD:ban(playerid, params[]) {
new id, reason[50];
new stringz[92];
if(PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}You're not a high enough level to use this command!");
if(sscanf(params, "us[50]", id, reason)) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF} /ban [playerid/name] [reason]");
if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}Invalid id!");
if(PlayerInfo[id][AdminLevel] == 7) return SendClientMessage(playerid, COLOR_NOTES2, "* One does not simply ban the server owner!");
format(stringz, sizeof(stringz), "* %s(%d) has been banned by %s(%d) due to: %s", GetName(id), id, GetName(playerid), playerid, reason);
SendClientMessageToAll(COLOR_RED, stringz);
SetTimerEx("KickTimer", 100, false, "i", id);
format(stringz, sizeof(stringz), "~r~BANNED~n~~y~%s", reason);
GameTextForPlayer(id, stringz, 5000, 6);
format(stringz, sizeof(stringz), "{FFFFFF}* {00C0FF}AdmCmd: %s(%d) has used BAN on %s(%d)", GetName(playerid), playerid, GetName(id), id);
SendMessageToAdmins(-1, stringz);
new Query[240], DBResult:result, day, month, year, second, minute, hour;
getdate(day, month, year);
gettime(hour, minute, second);
format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year);
format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(id)), DB_Escape(PlayerIP(id)), reason, DB_Escape(GetName(playerid)), datestring, timestring);
result = db_query(CnR, Query);
if(result) printf(">> SQLITE: successfully added %s's ban info", GetName(id));
else printf(">> SQLITE: could not add %s's ban info", GetName(id));
Query = "\0";
return 1;
}
Код:
[05:31:50] >> SQLITE: successfully added Mr_Max's ban info [05:31:50] >> SQLite: Mr_Max's stats have been saved successfully [05:31:50] [part] Mr_Max has left the server (1:2) [05:33:02] Incoming connection: IP [05:33:12] Incoming connection: IP [05:33:13] [join] TrusT has joined the server (IP) [05:33:16] >> SQLITE: TrusT failed to register [05:33:16] >> SQLite: TrusT's stats have not been saved
Should i add "if(!Banned[ playerid ])" when it updates the account stats ( @OnPlayerDisconnect )?