IP is not got from MYSQL DB
#1

To ban an player offline

used cache_get_value_name too but still the value of the targetip is null
PHP Code:
CMD:oban(playeridparams[])
{
    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]"targettimereason)) return SendClientMessage(playeridCOLOR_RED"USAGE: /oban [NAME] [DAYS] [REASON]") ;
        if(
time || time 365) return SendClientMessage(playeridCOLOR_RED"ERROR: "COL_GREY"Invalid ban time, must be between 0 ~ 365 (0 = permanent ban).") ;
        new 
query[65];
        
mysql_format(gSQLquerysizeof query"SELECT * FROM `Users` WHERE `Name` = '%e'"target);
        if(
mysql_tquery(gSQLquery"OnAccountExist""i"playerid))
        {
            new 
str[144], expiretime = (gettime() + (((time 24) * 60) * 60));
            if(
time 0format(strsizeof str"* ADMIN %s has offline banned %s for \"%s\" till %s."pName[playerid], targetreasonReturnDate(expiretime));
            else 
format(strsizeof str"* ADMIN %s has permanently offline banned %s for \"%s\"."pName[playerid], targetreason);
            
SendClientMessageToAll(COLOR_PINKstr);
            
mysql_format(gSQLquerysizeof(query), "SELECT * FROM `Users` WHERE `Name` = '%s'"target);
            
mysql_tquery(gSQLquery);
            new 
targetip[12];
            
cache_get_value(0"IP"targetip);
            
SendClientMessage(playerid,COLOR_RED,targetip);
            
OfflineBanPlayer(targetiptargetpName[playerid], reason, (!time) ? expiretime);
        }
        else
        {
            
SendClientMessage(playeridCOLOR_RED"ERROR: "COL_GREY"That account doesn't exist.");    
        }
    } 
Reply
#2

mysql_tquery: Sends a query which will be executed in another thread and call a callback (if there was one specified) when the execution is successfully finished. - click here
mysql_query: This native sends a non-threaded query to the MySQL server. The SA:MP server (the main PAWN thread) waits until the query has been executed and then returns the stored cache handle. - Click here

Simply use mysql_query (don't forget to delete cache when you don't code anymore to treated) or create public forwarded functions with your actually code.
Reply
#3

also, an ip can extend up to 16.

255.255.255.255 = (3*4)+3 = 15 + 1 ( for \0 )
Reply
#4

Sorry got my mistake thanks rep++ for both
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)