SA-MP Forums Archive
score & money sometimes doesn't save - 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: score & money sometimes doesn't save (/showthread.php?tid=474632)



score & money sometimes doesn't save - Uberanwar - 09.11.2013

Hi guys I'm very worried about score and money saving in my server. It doesn't save.. I'm very worried about this problem & my players keep complaining. I tried very hard checking if there's any problem in the script.. But I think there's no problems... I'm using Y_INI

My enum
pawn Код:
enum plInfo
{
    Password[ 129 ],
    Money,
    Score,
    Bank,
    RobSkill,
    TerSkill,
    WantedLevel2,
    Jail,
    RentalOwner,
    Drugs2,
    C4,
    Skin,
    Outside[256],
    SAPDP,
    SASDP,
    SWATP,
    FBIP,
    ArmyP,
    MedicP,
    //DRTP,
    pDonator,
    pKills,
    pDeaths,
    pArrests,
    pArrested,
    pCrimes,
    pRoadblock
}
Public Load User Data
pawn Код:
public LoadUser_data(playerid,name[],value[])
{
//INI_Int("Password",PlayerInfo[playerid][Password]);
INI_String("Password", PlayerInfo[ playerid ][ Password ], 129);
INI_Int("Money",PlayerInfo[playerid][Money]);
INI_Int("Score",PlayerInfo[playerid][Score]);
INI_Int("Bank",PlayerInfo[playerid][Bank]);
INI_Int("RobSkill",PlayerInfo[playerid][RobSkill]);
INI_Int("TerSkill",PlayerInfo[playerid][TerSkill]);
INI_Int("WantedLevel",PlayerInfo[playerid][WantedLevel2]);
INI_Int("Jail",PlayerInfo[playerid][Jail]);
INI_Int("RentalOwner",PlayerInfo[playerid][RentalOwner]);
INI_Int("Drugs",PlayerInfo[playerid][Drugs2]);
INI_Int("C4",PlayerInfo[playerid][C4]);
INI_Int("Skin",PlayerInfo[playerid][Skin]);
INI_Int("SAPDP",PlayerInfo[playerid][SAPDP]);
INI_Int("SASDP",PlayerInfo[playerid][SASDP]);
INI_Int("FBIP",PlayerInfo[playerid][FBIP]);
INI_Int("SWATP",PlayerInfo[playerid][SWATP]);
INI_Int("ArmyP",PlayerInfo[playerid][ArmyP]);
INI_Int("MedicP",PlayerInfo[playerid][MedicP]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Arrested",PlayerInfo[playerid][pArrested]);
INI_Int("Arrests",PlayerInfo[playerid][pArrests]);
INI_Int("Crimes",PlayerInfo[playerid][pCrimes]);
return 1;
}
Public OnPlayerDisconnect
pawn Код:
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File, "Money", GetPlayerMoney(playerid));
INI_WriteInt(File, "Score", GetPlayerScore(playerid));
INI_WriteInt(File, "WantedLevel", GetPlayerWantedLevel(playerid));
INI_WriteInt(File, "Bank", PlayerInfo[playerid][Bank]);
INI_WriteInt(File, "RobSkill", PlayerInfo[playerid][RobSkill]);
//INI_WriteInt(File, "Jail", PlayerInfo[playerid][Jail]);
INI_WriteInt(File, "Drugs", PlayerInfo[playerid][Drugs2]);
INI_WriteInt(File, "C4", PlayerInfo[playerid][C4]);
INI_WriteInt(File, "SAPDP",PlayerInfo[playerid][SAPDP]);
INI_WriteInt(File, "SASDP",PlayerInfo[playerid][SASDP]);
INI_WriteInt(File, "FBIP",PlayerInfo[playerid][FBIP]);
INI_WriteInt(File, "SWATP",PlayerInfo[playerid][SWATP]);
INI_WriteInt(File, "ArmyP",PlayerInfo[playerid][ArmyP]);
INI_WriteInt(File, "MedicP",PlayerInfo[playerid][MedicP]);
//INI_WriteInt(File, "DRTP",PlayerInfo[playerid][DRTP]);
INI_WriteInt(File, "Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File, "Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File, "Arrests",PlayerInfo[playerid][pArrests]);
INI_WriteInt(File, "Arrested",PlayerInfo[playerid][pArrested]);
INI_WriteInt(File, "Crimes",PlayerInfo[playerid][pCrimes]);
INI_Close(File);
My OnDialogResponse
pawn Код:
new file[128];
new name[MAX_PLAYER_NAME];
new Register[250];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
if(dialogid == DIALOG_REGISTER)
{
    if(!response) return Kick(playerid);
    if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Invalid Password\nPlease enter correct password!","Register","Disconnect");
    if(!fexist(file))
    {
        /*       dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Money", 2500);
        dini_IntSet(file, "Score", 1);
        dini_IntSet(file, "Bank", 1000);
        dini_IntSet(file, "RobSkill", 1);
        dini_IntSet(file, "TerSkill", 1);
        dini_IntSet(file, "WantedLevel", 0);
        dini_IntSet(file, "Jail", 0);
        dini_IntSet(file, "RentalOwner", 0);
        dini_IntSet(file, "Drugs", 0);
        dini_IntSet(file, "C4", 0);
        dini_IntSet(file, "Skin", -1);*/


        new hashpass[129];
        WP_Hash(hashpass,sizeof(hashpass),inputtext);
        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File,"data");
        INI_WriteString(File, "Password",hashpass);
        INI_WriteInt(File, "Money", 2500);
        INI_WriteInt(File, "Score", 1);
        INI_WriteInt(File, "Bank", 1000);
        INI_WriteInt(File, "RobSkill", 1);
        INI_WriteInt(File, "TerSkill", 1);
        INI_WriteInt(File, "WantedLevel", 0);
        INI_WriteInt(File, "Jail", 0);
        INI_WriteInt(File, "RentalOwner", 0);
        INI_WriteInt(File, "Drugs", 0);
        INI_WriteInt(File, "C4", 0);
        INI_WriteInt(File, "Skin", -1);
        INI_WriteInt(File, "SAPDP", 0);
        INI_WriteInt(File, "SASDP", 0);
        INI_WriteInt(File, "FBIP", 0);
        INI_WriteInt(File, "SWATP", 0);
        INI_WriteInt(File, "ArmyP", 0);
        INI_WriteInt(File, "MedicP", 0);
        INI_WriteInt(File, "DRTP", 0);
        INI_Close(File);


        format(Register,sizeof(Register),"Thanks for registering!\nYou may now login.",name);
        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",Register,"Login","Leave");
        GameTextForPlayer(playerid, "~r~Registered!", 3000, 1);
    }
}
if(dialogid == DIALOG_LOGIN)
{
    if(!response) return Kick(playerid);
    if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Invalid Password!\nPlease enter correct password","Login","Leave");
    if(fexist(UserPath(playerid)))
    {
        LoadData(playerid);
        new hashpass[129];
        WP_Hash(hashpass,sizeof(hashpass),inputtext);
        if( !strcmp( hashpass, PlayerInfo[ playerid ][ Password ], false ) )
        {
            IsPlayerLogged[playerid] = 1;
            //      SetPlayerMoney(playerid, dini_Int(file, "Money"));
            GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
            //      SetPlayerScore(playerid, dini_Int(file, "Score"));
            SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
            //      PlayerSkin[playerid] = dini_Int(file,"Skin");
            PlayerSkin[playerid] = PlayerInfo[playerid][Skin];
            //      SetPlayerWantedLevel(playerid, dini_Int(file, "WantedLevel"));
            SetPlayerWantedLevel(playerid, PlayerInfo[playerid][WantedLevel2]);
            SendClientMessage(playerid, GREY, "You are now logged in. Your status will be saved on your logout.");
            SendClientMessage(playerid, COLOR_GREEN, "Continuing current life...");
            GameTextForPlayer(playerid, "~r~Logged In!", 3000, 1);
        }
        else ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Wrong Password!\nPlease enter correct password","Login","Disconnect");
    }
    }
return 0;
}
Is there any solutions?


Re: score & money sometimes doesn't save - Crayder - 09.11.2013

I have the same problem, but on my old server I have it the same exact way as the new, but the new one is the only one with problems


Re: score & money sometimes doesn't save - Uberanwar - 09.11.2013

Found it. I'm using another admin system fs which has money and score saving system. Disabled it - And it works now. FS can conflict


Re: score & money sometimes doesn't save - Uberanwar - 15.11.2013

I still have this problem.
But I think...
(public onplayerdisconnect)
Quote:

INI_WriteInt(File, "Money", GetPlayerMoney(playerid));
INI_WriteInt(File, "Score", GetPlayerScore(playerid));
INI_WriteInt(File, "WantedLevel", GetPlayerWantedLevel(playerid));

should be

Quote:

INI_WriteInt(File, "Money", PlayerInfo[playerid][Money]);
INI_WriteInt(File, "Score", PlayerInfo[playerid][Score]);
INI_WriteInt(File, "WantedLevel", PlayerInfo[playerid][WantedLevel2]);

right?

Need help asap..


Re: score & money sometimes doesn't save - XStormiest - 15.11.2013

yes, that's what i wanted to told you.


Re: score & money sometimes doesn't save - Uberanwar - 15.11.2013

omg. its still doesn't save


Re: score & money sometimes doesn't save - Tuntun - 15.11.2013

Lol same here!! maybe sa-mp bugged? now i replaced my server to old version of my server and now it's ok D:


Re: score & money sometimes doesn't save - Uberanwar - 15.11.2013

Tuntun do you use Y_INI, and what do you mean replaced your server to old version?

Any expert scripters can check this? I really need to fix this ASAP I tried many times but still fail


Re: score & money sometimes doesn't save - Reera - 15.11.2013

Quote:
Originally Posted by Uberanwar
Посмотреть сообщение
I still have this problem.
But I think...
(public onplayerdisconnect)

should be

right?

Need help asap..
It have to be like
pawn Код:
INI_WriteInt(File, "Money", GetPlayerMoney(playerid));
INI_WriteInt(File, "Score", GetPlayerScore(playerid));
INI_WriteInt(File, "WantedLevel", GetPlayerWantedLevel(playerid));
I think at least, if not it can't save when you disconnect. But does everyting else save correct? And it's nothing wrong with samp, savings work for me


Re: score & money sometimes doesn't save - Beckett - 16.11.2013

Quote:
Originally Posted by Uberanwar
Посмотреть сообщение
I still have this problem.
But I think...
(public onplayerdisconnect)


should be



right?

Need help asap..
No this not right, the script wont know how many money got in his HAND unless you add it as in your commands [GivePlayerMoney = PlayerInfo[playerid][Money] keep the GetPlayerMoney, but it's a known issue when you crash(disconnect) or restart the server the player's stats wont save somehow, what I did is creating a timer on player request spawn which will start saving all stats each one second, which will make the chance of losing data is 1%.