23.02.2013, 18:23
Hello guys.i've been configuring trying to make a unban command. but can someone help me? when i type /unban and unban someone it say's the player name doesn't exist on database. can anyone help me?
Code:
Code:
pawn Код:
CMD:unban(playerid, params[])
{
new
String[128],
account[24],
Query[128]
;
if(pInfo[playerid][Adminlevel] < 4) return SendClientMessage(playerid, COLOR_RED_ERROR,"You are not Authorized to use this command");
//
if(!strlen(params)) return SendClientMessage(playerid,COLOR_RED_ERROR,"Usage: /unban (Player Name)");
//
if(strlen(account) > 24) return SendClientMessage(playerid, COLOR_RED_ERROR, "Name of the player can't exceed 24 characters.");
{
format(Query, sizeof(Query), "SELECT Username FROM users WHERE Banned = 1 AND Username = '%s'", PlayerName(playerid));
mysql_query(Query);
mysql_store_result();
if(!mysql_num_rows())
{
mysql_free_result();
format(String, sizeof(String), "This user doesn't exist.", account);
return SendClientMessage(playerid, COLOR_RED_ERROR, String);
}
else if(mysql_num_rows() != 0)
{
format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `Username` = '%s' ", account);
mysql_query(Query);
mysql_store_result();
mysql_fetch_row_format(Query, "|");
sscanf(Query, "p<|>e<s[26]s[512]iiiiiiiiiiiiiiiiiiiis[17]i>", pInfo[100]);
mysql_free_result();
new ubs[128];
format(ubs,128,"unbanip %s",pInfo[100][IpAdress]);
SendRconCommand(ubs);
SendRconCommand("Reloadbans");
format(String, sizeof(String), "You have succesfuly unbanned %s!", account);
SendClientMessage(playerid, COLOR_GREEN, String);
}
}
//
format(String, sizeof(String), "%s has been unbanned. (IP and Name)",params);
SendClientMessage(playerid,COLOR_RED_ERROR,String);
return 1;
}