[MYSQL] OBan not working
#1

fixxed.
Reply
#2

Try this pawn codes
Код:
CMD:oban(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 4)
	{
		SendClientMessageEx(playerid, COLOR_WHITE, "{FF0000}ERROR{E3E3E3}: You have insufficient rights to use this certain command!");
		return 1;
	}

	new string[128], playername[MAX_PLAYER_NAME], reason[64];
	if(sscanf(params, "s[24]s[64]", playername, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /oban [player name] [reason]");

    new giveplayerid = ReturnUser(playername);
	if(IsPlayerConnected(giveplayerid))
	{
		if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
		{
			format(string, sizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin.", GetPlayerNameEx(playerid));
			ABroadCast(COLOR_YELLOW,string,2);
			PlayerInfo[playerid][pBanned] = 1;
			SystemBan(playerid, "[System] (Attempting to ban a higher admin)");
			Kick(giveplayerid);
		}
		else
		{
			new playerip[32];
			GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
			format(string, sizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason);
			Log("logs/ban.log", string);
			SendClientMessageEx(playerid, COLOR_WHITE, "The person is online and has been banned!");
			format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
			SendClientMessageToAllEx(COLOR_LIGHTRED, string);
			PlayerInfo[giveplayerid][pBanned] = 1;
			new ip[32];
			GetPlayerIp(giveplayerid,ip,sizeof(ip));
			AddBan(playerid, giveplayerid, reason);
			MySQLBan(GetPlayerSQLId(giveplayerid),ip,reason,1,GetPlayerNameEx(playerid));
			format(string, sizeof(string), "Banned account (%s)", GetPlayerNameEx(giveplayerid));
			SystemBan(giveplayerid, string);
			SetTimerEx("KickEx", 1000, 0, "i", giveplayerid);
		}
	}
	else
	{
		new query[128], tmpName[24];

		mysql_escape_string(playername, tmpName);
		format(query, sizeof(query), "UPDATE `accounts` SET `Band`=1 WHERE `Username`='%s' AND `AdminLevel` < 2 AND `PermBand` < 3", tmpName);
		mysql_function_query(MainPipeline, query, false, "OnBanPlayer", "i", playerid);

		SetPVarString(playerid, "OnBanPlayer", tmpName);
		SetPVarString(playerid, "OnBanPlayerReason", reason);

		format(query,sizeof(query), "SELECT `id`, `IP` FROM `accounts` WHERE `Username`='%s'", tmpName);
		mysql_function_query(MainPipeline, query, true, "OnBanIP", "i", playerid);

		format(string,sizeof(string),"Attempting to ban %s...", tmpName);
		SendClientMessageEx(playerid, COLOR_YELLOW, string);
	}
	return 1;
}
don't forgot to +rep
Reply
#3

Your string (mysql_format) is messed up..
pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET Banned=1, Reason='%s', BannedBy='%s', BanDate='%s', BanTime='%s' WHERE Username = '%e'", reason, PlayerName(playerid), name, date, time);
Should be
pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET Banned=1, Reason='%s', BannedBy='%s', BanDate='%s', BanTime='%s' WHERE Username = '%e'", reason, PlayerName(playerid), date, time, name);
Reply
#4

Quote:
Originally Posted by Kyance
Посмотреть сообщение
Your string (mysql_format) is messed up..
pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET Banned=1, Reason='%s', BannedBy='%s', BanDate='%s', BanTime='%s' WHERE Username = '%e'", reason, PlayerName(playerid), name, date, time);
Should be
pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET Banned=1, Reason='%s', BannedBy='%s', BanDate='%s', BanTime='%s' WHERE Username = '%e'", reason, PlayerName(playerid), date, time, name);
thanks, fixed!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)