y_ini saving problem
#1

Alright so i'm still new to scripting, i'm finally starting to understand the basics... Last night i converted my script from dini to y_ini. Now score and cash aren't saving or atleast they aren't loading whenever you login. I'm not sure if its a problem with the account code or my server sided cash code (for the money not loading) so i'll be showing both below.

pawn Код:
Top of the script:

enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pScore,
    pVip
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
pawn Код:
Under OnPlayerConnect

if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
    ///////////////////////////////////////////////////////////////////////
    PlayerInfo[playerid][pCash] = 0;
pawn Код:
OnPlayerDisconnect

PlayerInfo[playerid][pCash] = 0;
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"VIP",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
    INI_Close(File);
pawn Код:
OnPlayerSpawn

    if(!GetPVarInt(playerid, "Spawned"))
    {
        ResetPlayerMoney(playerid);
        Einstein_GiveMoney(playerid, 50000);
        SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                SetPVarInt(playerid, "Spawned", 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_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,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Score",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Thanks for registering! You have been given $5000 and some score.","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Welcome Back!",""COL_GREEN"You have successfully logged in!","Ok","");
                    SetPVarInt(playerid, "Logged", 1);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
My Server sided cash code.

pawn Код:
stock Einstein_GiveMoney(playerid, money)
{
    PlayerInfo[playerid][pCash] += money; //Will increase the string: "+="
    GivePlayerMoney(playerid, money); //Give's the player money... DUH :P Don't use "a_GivePlayerMoney" here.
}
stock Einstein_SetMoney(playerid, money)
{
    PlayerInfo[playerid][pCash] = money; //Will set the string to the money ammount
    ResetPlayerMoney(playerid); //Reset's player money
    GivePlayerMoney(playerid); //Will give the player money. no a_GivePlayerMoney needed!
}
Reply
#2

anyone?
Reply
#3

Put the code, inside public OnPlayerConnect

GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)