problem retrieving ip from mysql rows - 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: problem retrieving ip from mysql rows (
/showthread.php?tid=657859)
problem retrieving ip from mysql rows -
severance - 16.08.2018
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(gString, sizeof(gString), "Player Name\tIP\n", get_name, get_ip);
for (new i = 0; i < rows; i ++)
{
cache_get_value(i, "username", get_name, MAX_PLAYER_NAME);
cache_get_value_int(i, "ip", get_ip);
format(gString, sizeof(gString), "%s%s\t%d\n", gString, get_name, get_ip);
}
ShowPlayerDialog(playerid, DIALOG_ADMINS, DIALOG_STYLE_TABLIST_HEADERS, "Players", gString, "Back", "");
}
return 1;
}
Re: problem retrieving ip from mysql rows -
Shinja - 16.08.2018
IP is a string not integer
PHP Code:
new get_ip[16];
//
//
cache_get_value(i, "ip", get_ip, 16);
//
//
format(gString, sizeof(gString), "%s%s\t%s\n", gString, get_name, get_ip);
One more thing, in your first format you dont need variables
PHP Code:
format(gString, sizeof(gString), "Player Name\tIP\n", get_name, get_ip);
format(gString, sizeof(gString), "Player Name\tIP\n");
Re: problem retrieving ip from mysql rows -
severance - 16.08.2018
Thanks, works now