SA-MP Forums Archive
Problem with saving files upon restarting server. (Filterscript.) - 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: Problem with saving files upon restarting server. (Filterscript.) (/showthread.php?tid=421817)



Problem with saving files upon restarting server. (Filterscript.) - rangerxxll - 11.03.2013

So I have my register system, admin system, and my "Talent System" <--(Not relevant.) all in one filterscript. And the main game mode is totally seperate.

Anyways, the problem is; When I restart the filterscript (/rcon reloadfs) it removes everyone's stats. Admin, Vip, Score, Etc.

How would I go about saving these statistics? Is it possible? If not, why? What would you recommend? 0_o

Thank you.


Re: Problem with saving files upon restarting server. (Filterscript.) - Scrillex - 11.03.2013

I recomend you to put it in gm... So you will not to relode all stats again.. because it could be it's rewriting them....


Re: Problem with saving files upon restarting server. (Filterscript.) - rangerxxll - 11.03.2013

Is there a way to avoid doing all of that...? I've invested hours of time into this script. It would take a arm and a leg to just copy and paste.


Re: Problem with saving files upon restarting server. (Filterscript.) - Scrillex - 11.03.2013

Umm maybe.. Show please your onplayerlogin! And saving part OnPlayerConnect


Re: Problem with saving files upon restarting server. (Filterscript.) - rangerxxll - 11.03.2013

Under OnDialogResponse.
pawn Код:
switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Vip",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Ban",0);
                INI_WriteInt(File,"Score",0);
                INI_WriteInt(File,"Talent",0);
                INI_Close(File);
Under OnPlayerConnect.
pawn Код:
if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
    }



Re: Problem with saving files upon restarting server. (Filterscript.) - Scrillex - 11.03.2013

And part of login too.. this looks good... and loading part will be needed too.. i had the same issue.. Just I checked everything if it's loading current stats and everything.. Then just was some mistakes.


Re: Problem with saving files upon restarting server. (Filterscript.) - rangerxxll - 11.03.2013

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("Vip",PlayerInfo[playerid][pVip]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Ban",PlayerInfo[playerid][pBan]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Talent",PlayerInfo[playerid][pTalent]);
    return 1;
}
That's what I'm using to load their data.


Re: Problem with saving files upon restarting server. (Filterscript.) - Scrillex - 11.03.2013

Btw did you tryed this:
OnGamemeModeInit
pawn Код:
SendRconCommand("reloadfs FSNAME");
OnGameModeExit
pawn Код:
SendRconCommand("unloadfs name");
It will automaticly load and unload fs... on server restart! + are you using timer on command /gmx?
Or you just restart server like closing it?


Re: Problem with saving files upon restarting server. (Filterscript.) - rangerxxll - 11.03.2013

i do /rcon reloadfs. And no, I don't have a timer.


Re: Problem with saving files upon restarting server. (Filterscript.) - rangerxxll - 11.03.2013

You know what, If I restart it via my mod cp - it works. So I guess I'll just stick to that.