problem retrieving ip from mysql rows
#1

So i made a command /playerslist that gives with a dialog a list of registered players and their ip's. But it doesn't work, it gives instead of 172.0.0.10 it gives only "172".

PHP Code:
stock players(playerid)
{
    new 
gString[2500], get_name[MAX_PLAYER_NAME], get_ip;
    
mysql_query(g_SQL,  "SELECT * FROM players");
     new 
rows cache_num_rows();
    if (
rows)
    {
        
format(gStringsizeof(gString), "Player Name\tIP\n"get_nameget_ip);
        for (new 
0rows++)
        {
            
cache_get_value(i"username"get_nameMAX_PLAYER_NAME);
            
cache_get_value_int(i"ip"get_ip);
            
format(gStringsizeof(gString), "%s%s\t%d\n"gStringget_nameget_ip);
        }
        
ShowPlayerDialog(playeridDIALOG_ADMINSDIALOG_STYLE_TABLIST_HEADERS"Players"gString"Back""");
    }
return 
1;

Reply
#2

IP is a string not integer
PHP Code:
new get_ip[16];
//
//
cache_get_value(i"ip"get_ip16); 
//
//
format(gStringsizeof(gString), "%s%s\t%s\n"gStringget_nameget_ip); 
One more thing, in your first format you dont need variables
PHP Code:
format(gStringsizeof(gString), "Player Name\tIP\n"get_nameget_ip);
format(gStringsizeof(gString), "Player Name\tIP\n"); 
Reply
#3

Thanks, works now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)