ip saving( fixed it my self) -
JeaSon - 25.11.2014
hello so im saving player ip into database (mysql)
but it is not saving i mean updating
pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `IP`='%s', `Admin`=%d, `Kills`=%d, `Deaths`=%d, `Cookie`=%d,`Notify`=%d, `TotalTime`=%d,`Money`=%d WHERE `ID`=%d",\
pInfo[playerid][IP],pInfo[playerid][Admin],pInfo[playerid][Kills],pInfo[playerid][Deaths], pInfo[playerid][Cookie],pInfo[playerid][Notify], pInfo[playerid][ConnectTime], pInfo[playerid][Money], pInfo[playerid][ID]);
public OnPlayerConnect(playerid)
{
GetPlayerIp(playerid, pInfo[playerid][IP], 16); //Getting layer's IP
return 1;
}
i load them into enum pInfo[playerid][IP]
pInfo[playerid][IP] = cache_get_field_content_int(0,"IP");
Re: ip saving -
Vince - 25.11.2014
IP is (generally) a string, and must be handled as such. Not every sequence of numbers with dots is classified as a number. If you want to save the IP as a number (e.g. for easier use of the BETWEEN clause) then you can do so by using INET_ATON() and INET_NTOA().
Pawn implementation:
pawn Код:
inet_aton(ip[])
{
new parts[4];
sscanf(ip, "p<.>a<i>[4]", parts);
return (parts[3] << 24 | parts[2] << 16 | parts[1] << 8 | parts[0]);
}
Re: ip saving -
JeaSon - 25.11.2014
i just fixed little bit it and now its saving like this " 92.168.1.2" but my ip is "192.168.1.2"
Re : ip saving -
Dutheil - 25.11.2014
pawn Код:
GetPlayerIp(playerid, pInfo[playerid][IP], 16); // pInfo[playerid][IP] is a string ?
pInfo[playerid][IP] = cache_get_field_content_int(0,"IP"); // because, here you store an integer
Re: ip saving -
OsteeN - 25.11.2014
Quote:
Originally Posted by Namer
i just fixed little bit it and now its saving like this " 92.168.1.2" but my ip is "192.168.1.2"
|
92.168.1.2 would be your public IP. 192.168.1.2 is a local IP.
Re: Re : ip saving -
JeaSon - 25.11.2014
Quote:
Originally Posted by Dutheil
pawn Код:
GetPlayerIp(playerid, pInfo[playerid][IP], 16); // pInfo[playerid][IP] is a string ? pInfo[playerid][IP] = cache_get_field_content_int(0,"IP"); // because, here you store an integer
|
Not worked and as
pawn Код:
pInfo[playerid][IP] cache_get_field_content(0, "IP", pInfo[playerid][IP], mysql, 16); // this is savin ip like "92.168.1.2 insteed of 192.168.1.2"
Re: ip saving -
iZN - 25.11.2014
Is your pInfo[playerid][IP] is even long enough to hold up the IP?
Re: ip saving -
JeaSon - 25.11.2014
this is not right Ip[16]; ?
Re: ip saving -
AnthonyTimmers - 25.11.2014
Quote:
Originally Posted by Namer
this is not right Ip[16]; ?
|
IP[16] is right (15 to be exact, but it doesn't matter that much).
Don't use cache_get_field_content_int, as an IP address is a string and not an int.
Where does it say this wrong IP address? IG or in the database?
Add a debug cmd that shows PlayerInfo[playerid][IP] and use a printf() for your UPDATE query to see what exactly is entered into your database.
Re: ip saving -
MD5 - 25.11.2014
[
https://sampforum.blast.hk/showthread.php?tid=485633]