SA-MP Forums Archive
Data doesn't change ip - 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: Data doesn't change ip (/showthread.php?tid=641314)



Data doesn't change ip - Loinal - 14.09.2017

PHP код:
public OnPlayerConnectSafe(playerid)
{
    new 
query[128];
    
GetPlayerIp(playeridIP[playerid], 16);
    
mysql_format(mysqlquerysizeof(query),"SELECT `IP`, `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1"pName(playerid));
    
mysql_tquery(mysqlquery"OnAccountCheck""i"playerid);
    return 
1;

If the player is not banned the OnPlayerConnectSafe is requested it works
2) when the data is loaded i requested the script to saveplayerdata which means to update the player ip and variables
PHP код:
    if(IsLoggedIn[playerid] == 1)
    {
    
SavePlayerData(playerid);
    
IRC_GroupSay(groupIDIRC_aCHANNEL"data saved and updated ip");
    } 
3) i checked the saveplayerdata its fine but it doesn't update the ip
PHP код:
stock SavePlayerData(playerid)
{
    if(
IsLoggedIn[playerid] == 1)
    {
    new 
query[300];
    
mysql_format(mysqlquerysizeof(query), "UPDATE `players` SET `IP` = '%e', `Admin` = %d, `Tokens` = %d, `Kills` = %d,`Deaths` = %d, `Score` = %d, `Money` = %d, `Hours` = %d,\
    `Minutes` = %d, `RaceWon` = %d WHERE `ID` = %d"
,
    
IP[playerid], pData[playerid][Admin], pData[playerid][Tokens], pData[playerid][Kills],pData[playerid][Deaths], GetPlayerScore(playerid),\
    
pData[playerid][Money], pData[playerid][pHours], pData[playerid][pMinutes],pData[playerid][RaceWon], pData[playerid][ID]);
    
mysql_tquery(mysqlquery);
    }
    return 
1;




Re: Data doesn't change ip - Threshold - 14.09.2017

Are you joining with a different IP? When you say it doesn't update... you mean the value doesn't change or it doesn't have a value?


Re: Data doesn't change ip - Loinal - 14.09.2017

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Are you joining with a different IP? When you say it doesn't update... you mean the value doesn't change or it doesn't have a value?
My ip changes, yeah the value doesn't change


Re: Data doesn't change ip - Threshold - 14.09.2017

Have you tried debugging to see what the value of 'IP[playerid]' is?


Re: Data doesn't change ip - Loinal - 14.09.2017

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Have you tried debugging to see what the value of 'IP[playerid]' is?
Nope, the IP[playerid] to store the player ip in the new one


Re: Data doesn't change ip - JasonRiggs - 14.09.2017

I didn't totally understand what you're trying to say, Can you explain more with details?


Re: Data doesn't change ip - Loinal - 14.09.2017

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
I didn't totally understand what you're trying to say, Can you explain more with details?
When the player connect the database doesn't save the new ip and remove the old one


Re: Data doesn't change ip - JasonRiggs - 14.09.2017

IP[playerid] is a variable, which means that you must set for it a value each time used.

That's why it is not updated when the player reconnects, You must make a function to get the player's IP using this function first.

PHP код:
GetPlayerIp(playeridIP[playerid], 16); 
Do that before the "UPDATE" of mysql query.

Then go ahead


Re: Data doesn't change ip - Loinal - 14.09.2017

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
IP[playerid] is a variable, which means that you must set for it a value each time used.

That's why it is not updated when the player reconnects, You must make a function to get the player's IP using this function first.

PHP код:
GetPlayerIp(playeridIP[playerid], 16); 
Do that before the "UPDATE" of mysql query.

Then go ahead
Now facing other problem when player leaves it changes his ip to: 255.255.255.255


Re: Data doesn't change ip - JasonRiggs - 14.09.2017

Does it change it over the database? or when you check in game? btw this means invalid player IP.

EDIT:

Quote:

PAWN is case-sensitive. GetPlayerIP will not work.
This function does not work when used in OnPlayerDisconnect because the player is already disconnected. It will return an invalid IP (255.255.255.255). Save players' IPs under OnPlayerConnect if they need to be used under OnPlayerDisconnect.

That's what I've found over SA:MP Wiki, I believe it helps much.