Unban IP command - 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: Unban IP command (
/showthread.php?tid=292481)
Unban IP command -
Luis- - 23.10.2011
Hi, I was wondering how i'd go about making a /unban [ip] command, I am using mysql if it helps.
Thanks.
Re: Unban IP command -
AeroBlast - 24.10.2011
SendRconCommand("unbanip");
?
Re: Unban IP command -
[MWR]Blood - 24.10.2011
Well, as your ban system is MySQL, you can just search for the IP specified (or in this case you will use the command params) in the table specified, and delete the whole row.
Re: Unban IP command -
0x80808000 - 24.10.2011
pawn Код:
command(unban, playerid, params[])
{
new ip[17];
if (sscanf(params, "s[17]", ip))SendClientMessage(playerid, -1, "* Use: /unban [ip]");
new query[100];
format(query, 100, "SELECT `ip` FROM `bans` WHERE `ip` = '%s' LIMIT 1", ip);
mysql_query(query);
mysql_store_result();
if (mysql_num_rows()) // Found Ip
{
format(query, 100, "DELET FROM `bans` WHERE `ip` = '%s'", ip);
mysql_query(query);
SendClientMessage(playerid, -1, "Ip successful deleted from banlist!");
}
else SendClientMessage(playerid, -1, "ERROR: INVALID PLAYER IP!");
mysql_free_result();
return 1;
}
In this ex i'm using zcmd and sscanf because i dont using strcmp or something else.
Re: Unban IP command -
Sinner - 24.10.2011
I can think of 2 methods, be real careful with where to put ` and ' or it wont work:
Method 1, you have a users table and you put a field to '1' when a player is banned:
pawn Код:
//To ban a user
mysql_query("UPDATE `your_users_table` SET `your_banned_field` = 1 WHERE `your_ip_field` = 'the_players_ip'");
// To unban a user
mysql_query("UPDATE `your_user_table` SET `your_banned_field` = 0 WHERE `your_ip_field` = 'the_players_ip'");
//EXAMPLE
mysql_query("UPDATE `users` SET `banned` = 0 WHERE `ip` = '127.0.0.1'");
method 2, you have a seperate table with bans:
pawn Код:
//To ban a user
mysql_query("INSERT INTO `your_banned_users_table` (`your_ip_field`) VALUES('the_players_ip')");
// To unban a user
mysql_query("DELETE FROM `your_banned_users_table` WHERE `your_ip_field` = 'the_players_ip'");
//EXAMPLE
mysql_query("DELETE FROM `bans` WHERE `ip` = '127.0.0.1'");
Hope that makes sense to you. If it's not you can always PM me.
Re: Unban IP command -
GAMER_PS2 - 24.10.2011
Sinner is that you? its me [SP]Mr.Kakashi[WP]
come here
https://sampforum.blast.hk/showthread.php?tid=292530
its about ban system