My ban command doesn't work
#1

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;
}
Reply


Messages In This Thread
My ban command doesn't work - by LeonMrBonnie - 28.01.2017, 12:33
Re: My ban command doesn't work - by LeonMrBonnie - 11.02.2017, 13:00
Re: My ban command doesn't work - by Macronix - 11.02.2017, 22:10

Forum Jump:


Users browsing this thread: 1 Guest(s)