SA-MP Forums Archive
oip is returning "NULL" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: oip is returning "NULL" (/showthread.php?tid=491492)



oip is returning "NULL" - Face9000 - 30.01.2014

Ok, this command is supposed to show the selected offline player's ip, but when i do like /oip TestAccount, i get: "NULL" instead of the IP.

Before asking me: Yes, the IP is stored in the table/row im reading with the command. Yes, the IP shows in the field (checked with phpmyadmin).

pawn Код:
CMD:oip(playerid, params[])
{
    if(Logged[playerid] == 1)
    {
    if(PlayerInfo[playerid][Admin] >= 2)
    {
    new targetAccount[MAX_PLAYER_NAME];
    if(sscanf(params, "s[24]", targetAccount)) return SCM(playerid,-1, "{F70505}Usage: /oip [account name] (Check an offline player's IP){FFFFFF}");
    new query[128];
    format(query, sizeof(query), "SELECT `user`, `IP` FROM `playerdata` WHERE `user` = '%s' LIMIT 0, 1", sanitize(targetAccount));
    mysql_function_query(mysqlc, query, true, "OfflineIPCheck", "i", playerid);
    }
    }
    return 1;
}
pawn Код:
public OfflineIPCheck(playerid)
{
    new rowCount, fieldCount, playersName[MAX_PLAYER_NAME], playersIP[17];
    cache_get_data(rowCount, fieldCount, mysqlc);

    if(!rowCount)
    {
        return SendClientMessage(playerid, red, "Account was not found in the database.");
    }

    cache_get_row(0, 0, playersName, mysqlc);
    cache_get_row(0, 24, playersIP, mysqlc);

    new clientMessage[128];

    format(clientMessage, sizeof(clientMessage), "%s's IP: %s", playersName, playersIP);
    SendClientMessage(playerid, pink, clientMessage);
    return 1;
}



Re: oip is returning "NULL" - Vince - 30.01.2014

pawn Код:
native cache_get_row(row, idx, destination[], connectionHandle = 1, max_len=sizeof(destination));
Second parameter is field index, not length.


Re: oip is returning "NULL" - MP2 - 30.01.2014

Why are you selecting `user` from the database if you already have it? (it's used in the WHERE clause).