SA-MP Forums Archive
Save player IP Y_Ini - 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: Save player IP Y_Ini (/showthread.php?tid=425759)



Save player IP Y_Ini - msvu - 26.03.2013

Hi all

I need help with saving a player's IP.

The problem is that I don't know anything about saving the IP. So I will be really thankful if you do it for me :/

I am using this Login/Register system: https://sampforum.blast.hk/showthread.php?tid=273088

Thanks in advance


Re: Save player IP Y_Ini - kamzaf - 26.03.2013

create a new enum called IP[16],

then under
pawn Код:
onplayerconnect: GetPlayerIp(playerid, PlayerInfo[playerid][IP], 16);
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("IP",PlayerInfo[playerid][IP]);
    return 1;
}
change your loading public to that^^

then under onplayer disconnect:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"IP",PlayerInfo[playerid][IP]);
    INI_Close(File);
    return 1;
}



Re: Save player IP Y_Ini - glbracer - 26.03.2013

The only problem is that an IP is stored as a string, not integer. Y_INI confuses me and I've had my problems with it in the past, but use GetPlayerIp, then use INI_WriteString to store it.


Re: Save player IP Y_Ini - msvu - 26.03.2013

Thanks to both of you