First of all:
Your code should be something like this:
pawn Код:
enum PlayerData
{
IP[16],
//...
}
new pInfo[MAX_PLAYERS][PlayerData];
Secondly, you cannot retrieve a player's ip on OnPlayerDisconnect. (Which should be noted in the SA-MP wiki...)
Normally this would return a bad value such as 0 or 255.255.255.255, therefore writing the wrong data into your player files.
Thirdly, you are writing and saving the ip as an INTEGER, it is in fact a STRING, hence why we add the [16] on the end of the variable. So instead of using INI_WriteInt, or INI_Int, you must use INI_WriteString and INI_String.
There is however, one way to fix it. Do something like the following:
pawn Код:
//Rather than get the player's ip OnPlayerConnect, you should retrieve it when they login. That way, you KNOW it is the actual player connecting with the ip, not someone trying to impersonate them.
public OnPlayerConnect(playerid)
{
//Send them to the login
return 1;
}
//When they login, successful password etc.
GetPlayerIp(playerid, pInfo[playerid][IP], 16);
public OnPlayerDisconnect(playerid, reason)
{
//Check if they are logged in before saving the ip
if(pInfo[playerid][LoggedIn] == 1) //Example to say if Player is logged in == true
{
//Player is logged in, save ip to their file
INI_WriteString("IP", pInfo[playerid][IP]);
}
return 1;
}
//Lets say for example that you have a command that retrieves a player's ip while their offline or something
CMD:getip(playerid, params[])
{
//if(sscanf etc. etc.
INI_String("IP", pInfo[playerid][IP], 16); //INI_String(variabletoload[], savetovariable, maxstringsize);
//You would need to make your own way around making this command NOT replace the current IP saved to this player, by using a different variable such as pInfo[playerid][TIP] (Temporary IP).
return 1;
}
In short:
Save IP when a player logs in.
When they disconnect, check if logged in and then save to player file.
IP is a STRING, not an integer.
EDIT: Got OnPlayerConnect and OnPlayerDisconnect mixed up, my bad.