My ban command doesn't work
#2

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