y_ini saving problem!
#1

My Saving system player info enum!
pawn Код:
enum pInfo
{
    pPass,
    pAdmin,
    pCash,
    pKills,
    pDeaths

};
new PlayerInfo[MAX_PLAYERS][pInfo];
OnPlayerConnect
pawn Код:
public OnPlayerConnect(playerid)
{
    JustLogin[playerid] = 0;
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"[CW:WW3] Login in to your account.",""COL_WHITE"Please Type your password below to login.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_WHITE"[CW:WW3] Registering a new account.",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
    return 1;
}
OnDialogResponse!!
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,"Admin",0);
                INI_WriteInt(File,"Cash", 0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);
            }
        }
        case DIALOG_CHANGEPASS:
        {
            new INI:File = INI_Open(UserPath(playerid));
            INI_SetTag(File,"data");
            INI_WriteInt(File,"Password",udb_hash(inputtext));
            INI_Close(File);
            new str[128];
            format(str, sizeof(str), "[CW:WW3] Your password has been changed to %s",inputtext);
            SendClientMessage(playerid, COLOR_RED, str);
        }
        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]);
                    JustLogin[playerid] = 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;
}
pawn Код:
forward LoadUser_data(playerid,name[],value[]); // If i set Cash , That works.
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}
OnPlayerDisconnect
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]);
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    return 1;
}
OnPlayerDeath
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(  killerid, playerid, reason );
    PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
    return 1;
}
But the problem is ! When ever i kill myself to test, it doesnt increment the death to 1 and when i disconnect! The Death's arent saved. When i set Cash to 5000 or anything and save the .ini file and go InGame. It shows the money to me. I dont know whats the problem. If somone can figure it out! Will be glad.

Thanks alot for reading!

- Ballu Miaa
Reply
#2

I tested it with /stats! The death counts doesnt increases by 1 when i die in /stats? Wtf is the fault. Someone please help me. Ive added PlayerInfo[playerid][pDeaths]++; Under OnPlayerDeathalso
- Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)