IP Saving - 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: IP Saving (
/showthread.php?tid=661940)
IP Saving -
Chyakka - 19.12.2018
As part of my database I keep the last logged in IP stored, I used the following function to obtain the ip:
Code:
new ip[16];
GetPlayerIp(playerid, ip, sizeof(ip));
return ip;
When the player loads in I run:
Code:
userInfo[playerid][pIP][0] = EOS;
strcat(userInfo[playerid][pIP], GetPlayerIpEx(playerid), 16);
and I use the following query to save it:
Code:
mysql_format(SQLHandle, queryHandler, sizeof(queryHandler),
"UPDATE `users` SET \
`IP` = '%s'" WHERE `ID` = %d",
userInfo[playerid][pIP], userInfo[playerid][pID]);
mysql_tquery(SQLHandle, queryHandler, "OnSavePlayer", "");
Now I can't quite identify what causes the inconsistency but the saving will either;
a: save the IP just fine or
b: save the account username with the exception of the first letter? (see image)
Does anyone know what could cause such an issue and how I would resolve it?
Re: IP Saving -
admantis - 19.12.2018
The way you set the IP is a bit redundant, use this
Code:
format(userInfo[playerid][pIP], 16, "%s", GetPlayerIpEx(playerid));
https://sampwiki.blast.hk/wiki/Format
Re: IP Saving -
Chyakka - 19.12.2018
Quote:
Originally Posted by admantis
|
Seems to be saving fine now, I'll be sure to mention if any more inconsistencies occur.