oip is returning "NULL"
#1

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;
}
Reply
#2

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)