System won't save money?
#1

Hello, and Merry Christmas!

Since I couldn't use Y_INI , I have used DOF2 on my save/load filterscript, which works fine.
The only problem is that money doesn't save, and I know why.

I got a pMoney thing, but it isn't defined. There is no GetPlayerMoney in my script too.
(well there is one for a command I made but that's completely unrelated).

Here is my script, I really need help because I don't know how to make like..
" pMoney = GetPlayerMoney " or something....

pawn Код:
enum PInfo
{
    pAdmin,
    pVip,
    pVehicle,
    pDeaths,
    pKills,
    pMoney
}
pawn Код:
//=====[STOCK1]=====//
stock USER_FILE(playerid)
{
    new str[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(str, sizeof(str), USER_FILE_PATH, pName);
    return str;
}

//=====[STOCK2]=====//
stock Load_Player_Stats(playerid)
{
    PlayerInfo[playerid][pAdmin]    =   DOF2_GetInt(USER_FILE(playerid),    "AdminLevel");
    PlayerInfo[playerid][pVip]      =   DOF2_GetInt(USER_FILE(playerid),    "VipLevel");
    PlayerInfo[playerid][pVehicle]  =   DOF2_GetInt(USER_FILE(playerid),    "Vehicle");
    PlayerInfo[playerid][pDeaths]   =   DOF2_GetInt(USER_FILE(playerid),    "Deaths");
    PlayerInfo[playerid][pKills]    =   DOF2_GetInt(USER_FILE(playerid),    "Kills");
    PlayerInfo[playerid][pMoney]    =   DOF2_GetInt(USER_FILE(playerid),    "Money");

    GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
}
pawn Код:
public OnPlayerConnect(playerid)
{
    if(DOF2_FileExists(USER_FILE(playerid)))
    {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login",
        "Type your password here to login !", #Login, #Quit);
    }else{
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Welcome ! Please register !",
        "Type your password here to register!", #Register, #Quit);
    }
    return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    DOF2_SetInt(USER_FILE(playerid),    "AdminLevel",   PlayerInfo[playerid][pAdmin]    );
    DOF2_SetInt(USER_FILE(playerid),    "VipLevel",     PlayerInfo[playerid][pVip]      );
    DOF2_SetInt(USER_FILE(playerid),    "Vehicle",      PlayerInfo[playerid][pVehicle]  );
    DOF2_SetInt(USER_FILE(playerid),    "Deaths",       PlayerInfo[playerid][pDeaths]   );
    DOF2_SetInt(USER_FILE(playerid),    "Kills",        PlayerInfo[playerid][pKills]    );
    DOF2_SetInt(USER_FILE(playerid),    "Money",        PlayerInfo[playerid][pMoney]    );
   
    DOF2_SaveFile();
     return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login",
                "You have entered an invalid password ! \nType your password here to login !", #Register, #Quit);
               
                DOF2_CreateFile(USER_FILE(playerid), inputtext);
               
                DOF2_SetInt(USER_FILE(playerid),    "AdminLevel",   0       );
                DOF2_SetInt(USER_FILE(playerid),    "VipLevel",     0       );
                DOF2_SetInt(USER_FILE(playerid),    "Vehicle",      0       );
                DOF2_SetInt(USER_FILE(playerid),    "Deaths",       0       );
                DOF2_SetInt(USER_FILE(playerid),    "Kills",        0       );
                DOF2_SetInt(USER_FILE(playerid),    "Money",        5000    );
               
                DOF2_SaveFile();
               
                SpawnPlayer(playerid);
                GivePlayerMoney(playerid,5000);
            }
        }
        case DIALOG_LOGIN:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(DOF2_CheckLogin(USER_FILE(playerid), inputtext))
                {
                    Load_Player_Stats(playerid);
                }else{
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login",
                    "You have entered an incorrect password. \nType your password below to login", #Login, #Quit);
                }
                return 1;
            }
        }
    }
    return 1;
}
Script compiles with no errors. I don't think its because of DOF2 either.
As I said, I think this might be because pMoney isn't defined.

Please help me, I really need help with this .
Thank you!
Reply
#2

Add to your enum
pawn Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
Will look like this:

pawn Код:
enum pInfo
{
    pAdmin,
    pVip,
    pVehicle,
    pDeaths,
    pKills,
    pMoney
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#3

Yeah forgot to mention I have that too else I would have 1000 errors xD
Reply
#4

You are setting it to 5000
DOF2_SetInt(USER_FILE(playerid), "Money", 5000 );

I know, you want give 5000 to the player, but try setting it to 0
Reply
#5

It doesn't matter !

What I mean is, there is no GetPlayerMoney.
So how can this script know what pMoney is?
For example deaths are saved, because they're defined! :

pawn Код:
if(killerid != INVALID_PLAYER_ID)
    {
        PlayerInfo[playerid][pKills]++;
    }
    PlayerInfo[playerid][pDeaths]++;
Because now they are basically defined!
But I need to do kinda the same thing for the money!
I told you, it can't save because pMoney isn't known as GetPlayerMoney, but that's what I need!
I don't know how to do so pMoney will get the player money!
Reply
#6

Wait... I am stupid... money can be obtained only by jobs/commands/score etc.

So this means I will have to add PlayerInfo[playerid][pMoney] + 500 (example) to everything that gives money
I just realised. I am dumb... you can lock this...
Reply
#7

Quote:
Originally Posted by jNkk
Посмотреть сообщение
Wait... I am stupid... money can be obtained only by jobs/commands/score etc.

So this means I will have to add PlayerInfo[playerid][pMoney] + 500 (example) to everything that gives money
I just realised. I am dumb... you can lock this...
Lawl!

Good job
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)