Wrong IP -
x96664 - 17.11.2013
I'm using the last (R34) BlueG's( or by the current developer maddinat0r) mysql plugin, I'm not even sure if the problems is from the mysql part, but I'm trying to save player's IP when player leaves. The problem is that everybody's IP goes
255.255.255.255. There is part of my code:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
if(Logged[playerid] == 1)
{
new query[512];
format(query, sizeof(query), "UPDATE players SET IP = '%s' WHERE Name = '%s'", GetIP(playerid), GetPName(playerid));
mysql_function_query(IMDb, query, false, "", "");
}
return 1;
}
stock GetPName(playerid)
{
GetPlayerName(playerid,gName,sizeof gName);
return gName;
}
stock GetIP(playerid)
{
new gIP[16];
GetPlayerIp(playerid, gIP, sizeof gIP);
return gIP;
}
I know that getting IP wasn't working either on the onplayerconnect or onplayerdisconnect callback, but I don't remember which one. So what is the solution there ?
Thanks in advance.
AW: Wrong IP -
BigETI - 17.11.2013
Store the player's IP at OnPlayerConnect(), and use it in OnPlayerDisconnect().
Re: Wrong IP -
Konstantinos - 17.11.2013
pawn Код:
new
Player_Ip[ MAX_PLAYERS ][ 16 ]
;
// OnPlayerConnect:
GetPlayerIp( playerid, Player_Ip[ playerid ], 16 );
// Anywhere else you want to use the IP (such as passing it as an argument to format):
Player_Ip[ playerid ]
Everytime I used to get the IP at localhost, 255.255.255.255 was returned. I fixed the problem by getting the IP only ONCE and using it then
Re: Wrong IP -
x96664 - 17.11.2013
Quote:
Originally Posted by Konstantinos
pawn Код:
new Player_Ip[ MAX_PLAYERS ][ 16 ] ;
// OnPlayerConnect: GetPlayerIp( playerid, Player_Ip[ playerid ], 16 );
// Anywhere else you want to use the IP (such as passing it as an argument to format): Player_Ip[ playerid ]
Everytime I used to get the IP at localhost, 255.255.255.255 was returned. I fixed the problem by getting the IP only ONCE and using it then
|
Still 255.255.255.255, I used to get the IP when I connected and I sent an UPDATE query when I logged in (where I use to load player stats).
EDIT: I deleted my user account and the IP field is empty.
Re: Wrong IP -
Memoryz - 17.11.2013
What happens if you SendClientMessage the query, does it show IP = '255.255.255.255' or does it show the correct IP?
What field type are you using to store the IP in your table?
Re: Wrong IP -
x96664 - 17.11.2013
Quote:
Originally Posted by Memoryz
What happens if you SendClientMessage the query, does it show IP = '255.255.255.255' or does it show the correct IP?
What field type are you using to store the IP in your table?
|
I will use to debug the query and I will tell you the result, it's varchar(16) with collation latin_swedish_ci (if it even matters).
EDIT: the size of the query wasnt big enough (64) and I made it 128 so it works now, thank you both.