Password saves "0"
#1

Hey guys,

My saving system (Using Y_INI and tutorial from Kush), the problem started lately, it wasn't there .. I don't know how to fix it. The password saves as 0 if a player disconnects/quits the server. I need somebody to help me over TeamViewer.

This is when the player registers:

pawn Code:
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,"PlayerData");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",-1);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Zombie",0);
                INI_WriteInt(File,"Score",1);
                INI_WriteInt(File,"Team",-1);
                INI_WriteInt(File,"Registered",1);
                INI_WriteInt(File,"Logged",1);
               
                PlayerInfo[playerid][pTeam] = -1;
                PlayerInfo[playerid][pAdmin] = -1;
                //PlayerInfo[playerid][pPass] = (inputtext);
               
                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"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
            }
        }
This is when the player quits(The problem happens when the player quits/leaves the server:

pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    PlayerInfo[playerid][pLogged] = 0;
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"PlayerData");
    INI_WriteInt(File,"Password",PlayerInfo[playerid][pPass]);
    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,"Starter",PlayerInfo[playerid][pStarter]);
    INI_WriteInt(File,"Zombie",PlayerInfo[playerid][pZombie]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
    INI_WriteInt(File,"Registered",PlayerInfo[playerid][pReg]);
    INI_WriteInt(File,"Logged",PlayerInfo[playerid][pLogged]);
    INI_Close(File);
    return 1;
}
Another "SavePlayerStats" for for example commands like /setlevel etc.. to save the level.

pawn Code:
forward SavePlayerStats(playerid);
public SavePlayerStats(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"PlayerData");
    INI_WriteInt(File,"Password",PlayerInfo[playerid][pPass]);
    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,"Starter",PlayerInfo[playerid][pStarter]);
    INI_WriteInt(File,"Zombie",PlayerInfo[playerid][pZombie]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
    INI_WriteInt(File,"Registered",PlayerInfo[playerid][pReg]);
    INI_WriteInt(File,"Logged",PlayerInfo[playerid][pLogged]);
    INI_Close(File);
    print("\n----------------------------------");
    print(" Players' accounts saved! On SavePlayerStats");
    print("----------------------------------\n");
    return 1;
}
Reply


Messages In This Thread
Password saves "0" [Added the codes] - by Guitar - 07.09.2012, 11:08
Re: Password saves "0" - by doreto - 07.09.2012, 11:37
Re: Password saves "0" - by HuSs3n - 07.09.2012, 11:40
Re: Password saves "0" - by Guitar - 07.09.2012, 11:49
Re: Password saves "0" - by Guitar - 07.09.2012, 11:59
Re: Password saves "0" - by HuSs3n - 07.09.2012, 12:00
Re: Password saves "0" - by Guitar - 07.09.2012, 12:02
Re: Password saves "0" - by HuSs3n - 07.09.2012, 12:06
Re: Password saves "0" - by Guitar - 07.09.2012, 12:14
Re: Password saves "0" - by Cjgogo - 07.09.2012, 13:06
Re: Password saves "0" - by JaKe Elite - 07.09.2012, 13:10
Re: Password saves "0" - by Guitar - 07.09.2012, 20:27
Re: Password saves "0" - by RedFusion - 07.09.2012, 20:37
Re: Password saves "0" - by sniperwars - 07.09.2012, 20:37
Re: Password saves "0" - by Guitar - 08.09.2012, 06:04
Re: Password saves "0" - by Guitar - 08.09.2012, 10:15
Re: Password saves "0" - by JaKe Elite - 08.09.2012, 10:31
Re: Password saves "0" - by Guitar - 08.09.2012, 10:49
Re: Password saves "0" - by Kush - 08.09.2012, 10:54
Re: Password saves "0" - by JaKe Elite - 08.09.2012, 10:59
Re: Password saves "0" - by Guitar - 08.09.2012, 11:01
Re: Password saves "0" - by Aprezt - 08.09.2012, 11:03
Re: Password saves "0" - by JaKe Elite - 08.09.2012, 11:04
Re: Password saves "0" - by Guitar - 08.09.2012, 11:06
Re: Password saves "0" - by Kush - 08.09.2012, 11:11
Re: Password saves "0" - by Guitar - 08.09.2012, 11:14
Re: Password saves "0" - by Kush - 08.09.2012, 11:20
Re: Password saves "0" - by Guitar - 08.09.2012, 11:26
Re: Password saves "0" - by JaKe Elite - 08.09.2012, 11:31
Re: Password saves "0" - by Guitar - 08.09.2012, 11:36
Re: Password saves "0" - by Glint - 08.09.2012, 12:02

Forum Jump:


Users browsing this thread: 26 Guest(s)