Player Exp/level not saving
#4

Quote:
Originally Posted by JasonTurkey
Посмотреть сообщение
pawn Код:
enum Info
{
    pLevel,
    pExp,
};
new PlayerInfo[MAX_PLAYERS][Info]; // You must have this.

// Loading
SetPVarInt(playerid, "pLevel", DOF2_GetInt(string, "level"));
SetPVarInt(playerid, "pExp", DOF2_GetInt(string, "Exp"));

// Saving
DOF2_SetInt(string, "level", GetPVarInt(playerid, "level"));
DOF2_SetInt(string, "Exp", GetPVarInt(playerid, "Exp"));
First of all, as you see, you are loading it via PVars, while you earlier used normal variables.
Second, you are using "pLevel" and "pExp" to load the variables, while using "level" and "Exp" to save them.

This way you will save everything with "pLevel" and "pExp" and loading from unsigned names.
I'd suggest you to use one type of var, and also put the same names when loading and saving data:
pawn Код:
public OnPlayerLogin(playerid,password[])
{
    if(GetPVarInt(playerid, "PlayerLogged") != 0) return true;
    new string[128];
    format(string, sizeof(string), "users/%s.ini", PlayerName(playerid));
    Hash(password);
    if(strcmp(DOF2_GetString(string, "Key"), password, true) == 0)
    {
        if(DOF2_GetInt(string, "Convert") != 5) return Kick(playerid);
        // Load Ints //
        SetPVarInt(playerid, "Level", DOF2_GetInt(string, "pLevel"));
        SetPVarInt(playerid, "Exp", DOF2_GetInt(string, "pExp"));
        new score = PlayerInfo[playerid][pLevel];
        SetPlayerScore(playerid, score);
    }
}

public OnPlayerDataSave(playerid)
{
    if(IsPlayerConnected(playerid) && GetPVarInt(playerid, "PlayerLogged") == 1)
    {
        new string[128];
        format(string, sizeof(string), "users/%s.ini", PlayerName(playerid));
        if(DOF2_FileExists(string))
        {
            DOF2_SetInt(string, "pLevel", GetPVarInt(playerid, "Level"));
            DOF2_SetInt(string, "pExp", GetPVarInt(playerid, "Exp"));
        }
        return 0;
    }
}
Reply


Messages In This Thread
Player Exp/level not saving - by JasonTurkey - 02.11.2013, 07:19
Re: Player Exp/level not saving - by -Prodigy- - 02.11.2013, 07:38
Re: Player Exp/level not saving - by JasonTurkey - 02.11.2013, 07:45
Re: Player Exp/level not saving - by Dragonsaurus - 02.11.2013, 08:58
Re: Player Exp/level not saving - by JasonTurkey - 02.11.2013, 16:15
Re: Player Exp/level not saving - by JasonTurkey - 02.11.2013, 17:04
Re: Player Exp/level not saving - by JasonTurkey - 02.11.2013, 23:51
Re: Player Exp/level not saving - by JasonTurkey - 03.11.2013, 00:29

Forum Jump:


Users browsing this thread: 2 Guest(s)