SA-MP Forums Archive
Lost connection when use /unban - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Lost connection when use /unban (/showthread.php?tid=555022)



Lost connection when use /unban - PowerF - 06.01.2015

i just fix my /unban cmd but when i test it to players get banned
server get restarting.

Код:
{
	LoginCheck(playerid);
	if(User[playerid][accountAdmin] >= 2)
	{
	new
	string[150],
	Account[24],
	DBResult:Result,
	Query[129],
	fIP[30]
	;
	if(sscanf(params, "s[24]", Account)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /unban [account name]");
	format(Query, 129, "SELECT FROM `bans` WHERE `username` = '%s'", Account);
	Result = db_query(Database, Query);

	if(db_num_rows(Result))
	{
	db_get_field_assoc(Result, "ip", fIP, 30);
	if(CheckBan(fIP))
	{
	RemoveBan(fIP);
	}
	format(Query, 129, "DELETE FROM `bans` WHERE `username` = '%s'", Account);
	Result = db_query(Database, Query);
	db_free_result(Result);

	format(string, sizeof string, "[UNBANNED] "white"%s has been unbanned by an admin.", Account);
	SendPlayerMessage(COLOR_ORANGE, string);
	format(string, sizeof string, "[UNBANNED] "white"%s has been unbanned by %s.", Account, GetName(playerid));
	SendAMessage(COLOR_ORANGE, string);
	format(string, sizeof string, "[UNBANNED] %s has been unbanned by %s.", Account, GetName(playerid));
	Log("ban.txt", string);
	}
	else
	{
	db_free_result(!Result);
	SendClientMessage(playerid, -1, "» "red"Player is not in the banned database.");
	return 1;
	}
	}
	else
	{
	SendClientMessage(playerid, -1, "» "red"You are not authorized to use this command.");
	}
	return 1;
}