24.01.2018, 06:42
To ban an player offline
used cache_get_value_name too but still the value of the targetip is null
used cache_get_value_name too but still the value of the targetip is null
PHP Code:
CMD:oban(playerid, params[])
{
if(pInfo[playerid][AdminLvl] < 1) return -1;
if(pInfo[playerid][AdminLvl] >= 4)
{
new target[MAX_NICK_LENGTH + 1], reason[50], time;
if(sscanf(params, "s[20]dS(No reason given)[50]", target, time, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /oban [NAME] [DAYS] [REASON]") ;
if(time < 0 || time > 365) return SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"Invalid ban time, must be between 0 ~ 365 (0 = permanent ban).") ;
new query[65];
mysql_format(gSQL, query, sizeof query, "SELECT * FROM `Users` WHERE `Name` = '%e'", target);
if(mysql_tquery(gSQL, query, "OnAccountExist", "i", playerid))
{
new str[144], expiretime = (gettime() + (((time * 24) * 60) * 60));
if(time > 0) format(str, sizeof str, "* ADMIN %s has offline banned %s for \"%s\" till %s.", pName[playerid], target, reason, ReturnDate(expiretime));
else format(str, sizeof str, "* ADMIN %s has permanently offline banned %s for \"%s\".", pName[playerid], target, reason);
SendClientMessageToAll(COLOR_PINK, str);
mysql_format(gSQL, query, sizeof(query), "SELECT * FROM `Users` WHERE `Name` = '%s'", target);
mysql_tquery(gSQL, query);
new targetip[12];
cache_get_value(0, "IP", targetip);
SendClientMessage(playerid,COLOR_RED,targetip);
OfflineBanPlayer(targetip, target, pName[playerid], reason, (!time) ? 0 : expiretime);
}
else
{
SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"That account doesn't exist.");
}
}