SA-MP Forums Archive
Yini Saving Stats on every logout - 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: Yini Saving Stats on every logout (/showthread.php?tid=548039)



Yini Saving Stats on every logout - JonathanW - 27.11.2014

Can't figure out why.


This, is under OnPlayerDisconnect.
pawn Код:
stock SaveUser(playerid)
{
    PlayerInfo[playerid][Money] = GetPlayerMoney(playerid);
    PlayerInfo[playerid][Level] = GetPlayerScore(playerid);
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"====[PLAYER INFORMATION]====");
    INI_WriteString(File,"Name",PlayerInfo[playerid][Name]);
    INI_WriteInt(File,"Password",PlayerInfo[playerid][Password]);
    INI_WriteInt(File,"Level",PlayerInfo[playerid][Level]);
    INI_WriteInt(File,"Money",PlayerInfo[playerid][Money]);
    INI_WriteInt(File,"AdminLevel",PlayerInfo[playerid][AdminLevel]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][Age]);
    INI_WriteInt(File,"Gender",PlayerInfo[playerid][Gender]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][Skin]);
    INI_WriteInt(File,"RegDate",PlayerInfo[playerid][RegDate]);
    INI_WriteInt(File,"RegMonth",PlayerInfo[playerid][RegMonth]);
    INI_WriteInt(File,"RegYear",PlayerInfo[playerid][RegYear]);
    INI_WriteInt(File,"TimesKicked",PlayerInfo[playerid][TimesKicked]);
    INI_WriteInt(File,"Banned",PlayerInfo[playerid][Banned]);
    INI_WriteString(File,"BannedBy",PlayerInfo[playerid][BannedBy]);
    INI_WriteString(File,"BanReason",PlayerInfo[playerid][BanReason]);
    INI_WriteInt(File,"TimesBanned",PlayerInfo[playerid][TimesBanned]);
    INI_Close(File);
    return 1;
}



Re: Yini Saving Stats on every logout - JonathanW - 28.11.2014

Anybody?


Re: Yini Saving Stats on every logout - PowerPC603 - 28.11.2014

Try removing the [ and ] from it.
Seems like the INI system adds them automatically at both ends of your tag and it might confuse the INI system.
Like:

INI_SetTag(File,"====PLAYER INFORMATION====");

Perhaps the INI system sees your tag in the file as

[====[PLAYER INFORMATION]

because it presumably stops at the first ] and therefore cannot find your tag and creates a new tag.


Re: Yini Saving Stats on every logout - iOxide - 28.11.2014

I am wondering, if you set your tag like that, what would your loading function be? I am guessing thats the problem, cause you must use the same tag with your loading function that you used while saving user's stats.

Example, if you have [userdata] tag, your loading function should be something like LoadPlayer_userdata(id, name[], value[]);


Re: Yini Saving Stats on every logout - JonathanW - 28.11.2014

PowerPC603 & iOxide.
Love you.


Re: Yini Saving Stats on every logout - zT KiNgKoNg - 28.11.2014

I also suggest that you Hash your passwords, having them as a plain text is a breach of user information (Regardless if you think it isn't)


Re: Yini Saving Stats on every logout - JonathanW - 28.11.2014

Quote:

I also suggest that you Hash your passwords, having them as a plain text is a breach of user information (Regardless if you think it isn't)

I do, hash. When they enter their password in 'Register Dialog', it hashes them and stores in PlayerInfo[playerid][Password]. On Disconnect, it automatically saves it.