16.05.2015, 15:39
PHP Code:
CMD:unban(playerid, params[])
{
if(pInfo[playerid][pLogged] == 1)
{
if(pInfo[playerid][pAdminLevel] >= 2)
{
new Query[256],bname[24],rows, fields;
if (sscanf(params,"s[24]",bname)) return SendClientMessage(playerid,-1,""chat" /unban [name]"); // use sscanf not strlen
mysql_format(mysql,Query, sizeof(Query), "SELECT `Name` FROM `banlog` WHERE Name = '%e' AND pAccountLock = 1 LIMIT 1", bname);
mysql_tquery(mysql, Query,"","");
cache_get_data(rows, fields, mysql);
if(!rows)
{
new string[200];
format(string, sizeof(string), ""chat" Nobody under the name of %s is banned!", bname);
return SendClientMessage(playerid,-1,string);
}
else
{
mysql_format(mysql,Query, sizeof(Query), "UPDATE `banlog` SET `pAccountLock` = 0 WHERE Name = '%s'", bname);
mysql_tquery(mysql, Query,"","");
new string[200];
format(string, sizeof(string), ""chat" %s has been unbanned!", bname);
SendClientMessage(playerid, 0x66FF33, string);
}
}
}
return 1;
}
PHP Code:
CMD:searchip(playerid, params[])
{
if(pInfo[playerid][pLogged] != 1) return 0;
new ip[16],rows, fields;
if(sscanf(params, "s[16]", ip)) return SendClientMessage(playerid, -1, ""chat" /searchip [IP]");
new query[70], string[75];
mysql_format(mysql,query, sizeof(query), "SELECT `Username` FROM `users` WHERE `pIP`='%s'", ip); // READ NOTE
mysql_tquery(mysql, query);
cache_get_data(rows, fields, mysql);
if(!rows)
{
format(string, sizeof(string), ""chat" Nobody account founded with %s IP!", ip);
SendClientMessage(playerid, -1, string);
return 1;
}
else
{
format(string, sizeof(string), ""chat" Names found with %s IP. :", ip);
SendClientMessage(playerid, -1, string);
new count = 1, foundname[MAX_PLAYER_NAME];
while(cache_get_row_count())
{
cache_get_field_content(0, "Username",foundname);
strmid(foundname, query, 0, strlen(query)); // READ NOTE
format(string, sizeof(string), ""chat" %d: %s", count, foundname);
SendClientMessage(playerid, -1, string);
count = count + 1;
}
}
return 1;
}
Thanks