23.10.2011, 22:34
Hi, I was wondering how i'd go about making a /unban [ip] command, I am using mysql if it helps.
Thanks.
Thanks.
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;
}
//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'");
//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'");