My ban command doesn't work -
LeonMrBonnie - 28.01.2017
Hey,
I'm currently making my own gamemode but I've ran into a problem, I can't get my /ban command to work properly.
Can you help me and say what I am doing wrong?
Код:
CMD:pban(playerid, params[])
{
new Query[240], string[256], targetid[128], reason[128], DBResult:result, day, month, year, second, minute, hour, datestring[24], timestring[24];
if(Player[playerid][Level] < 2 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "FEHLER: Du musst ein Senior Supporter sein um diesen Command zu benutzen.");
if(sscanf(params, "s[24]s[48]", targetid, reason)) return SendClientMessage(playerid, -1, "USAGE: /pban [Spieler] [Grund]");
format(Query, sizeof(Query), "SELECT `NAME` FROM `BANNED` WHERE `NAME` = '%s'", targetid);
result = db_query(bans, Query);
if(!db_num_rows(result))
{
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', '0', '%s', '%s', '%s', '%s')", DB_Escape(targetid), reason, DB_Escape(GetName(playerid)), datestring, timestring);
result = db_query(bans, Query);
if(result)
{
format(string, sizeof(string), "{ff4040}BAN: {FFFFFF}%s {ff4040}wurde von {FFFFFF}%s {ff4040}gebannt. [Grund: {FFFFFF}%s{ff4040}]", targetid, GetName(playerid), reason);
SendClientMessageToAll(-1, string), string = "\0";
printf("[ban] [%s]: gebannt %s mit dem Grund: %s", GetName(playerid), targetid, reason);
}
else
{
format(string, sizeof(string), "FEHLER: Konnte Spieler nicht bannen. Grund: '%s'..", targetid), SendClientMessage(playerid, -1, string);
printf("[ban] [%s]: failed to ban %s due to %s", GetName(playerid), targetid, reason);
}
}
else return SendClientMessage(playerid, -1, "FEHLER: Der Spieler ist bereits gebannt.");
db_free_result(result);
SetTimerEx("OnPlayerKicked", 500, false, "i", targetid);
return 1;
}
Re: My ban command doesn't work -
LeonMrBonnie - 11.02.2017
bump, can anybody help me? I now tried it with this but still the same error:
Код:
CMD:pban(playerid, params[])
{
if(Player[playerid][Level] < 2 && !IsPlayerAdmin(playerid)) return SendErrorMessage(playerid,"Du musst ein Senior Supporter sein um diesen Command benutzen zu kцnnen.");
new targetid, Reason[128];
if(sscanf(params, "ds", targetid, Reason)) return SendUsageMessage(playerid,"/pban [ID] [Grund]");
if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid,"Der gewдhlte Spieler ist nicht auf dem Server.");
if(strlen(Reason) > 128) return SendErrorMessage(playerid,"Der gewдhlte Grund ist zu lang.");
BanWithReason(playerid, targetid, Reason);
return 1;
}
stock BanWithReason(playerid = INVALID_PLAYER_ID, targetid, reason[])
{
new Query[240], string[112], DBResult:result, day, month, year, second, minute, hour, datestring[24], timestring[24];
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);
if(playerid != INVALID_PLAYER_ID)
{
format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", GetName(targetid), PlayerIP(targetid), reason, GetName(playerid), datestring, timestring);
result = db_query(bans, Query);
if(result)
{
format(string, sizeof(string), "BAN: %s(%d) wurde von %s(%d) gebannt [Grund: %s]", GetName(targetid), targetid, GetName(playerid), playerid, reason);
SendClientMessageToAll(-1, string), string = "\0";
printf("[ban] [%s]: Erfolgreich %s's Bann Info hinzugefьgt", GetName(playerid), GetName(targetid));
}
else
{
format(string, sizeof(string), "SERVER: Fehler beim Bannen von '%s'", GetName(targetid));
SendClientMessageToAll(-1, string), string = "\0";
printf("[ban] [%s]: Fehler beim hinzufьgen von %s's Bann Info", GetName(playerid), GetName(targetid));
}
}
/*
else
{
format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', 'Server', '%s', '%s')", DB_Escape(GetName(targetid)), DB_Escape(PlayerIP(targetid)), reason, datestring, timestring);
result = db_query(bans, Query);
format(string, sizeof(string), "BAN: %s(%d) has been banned by the Server due to %s", GetName(targetid), targetid, reason);
SendClientMessageToAll(COLOR_RED, string), string = "\0";
}
for anti-cheat purposes ^
*/
Query = "\0", db_free_result(result);
SetTimerEx("KickTimer", 100, false, "i", targetid);
}
Re: My ban command doesn't work -
Macronix - 11.02.2017
What exactly is the error code?