30.01.2012, 12:38
How can I get the IP ?
pawn Код:
CMD:rban(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
new reason[128], query[256],player[24], playerip[16], string[128];
if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
if(sscanf(params, "s[24]s[128]", player, reason)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /rban [player name] [reason]- Use an underscore or it will not work.");
format(string, sizeof(string), "Admin %s Banned %s [Reason: %s]", GetNameEx(playerid), player, reason);
SendClientMessageToAll(COLOUR_REALRED, string);
format(query, sizeof(query), "SELECT `PlayerIP` FROM `accounts` WHERE `PlayerName` = '%s'", player);
mysql_query(query); // No query line
mysql_store_result();
// What should I do here to get the result from the above query, I know it's a string, but I'm not sure how to address it.
new rows = mysql_num_rows();
if(rows > 0)
{
format(query, sizeof(query), "INSERT INTO `bans` (`playername`, `IP`) VALUES ('%s', '%s')", player, query);
mysql_query(query);
format(string, sizeof(string), "You have banned account(Remote - Ban) %s", player);
SendClientMessage(playerid, COLOUR_REALRED, string);
}
if(rows == 0)
{
SendClientMessage(playerid, COLOUR_GREY, "There are no accounts found with that name.");
}
mysql_free_result();
return 1;
}