Randomly score reset
#1

Hello, this is a problem that im expecting from some days, having a server with a medium playerbase is a problem. Sometimes players lose their score and cash, i dont know why. This is the dialog of the login:

pawn Код:
if(dialogid == dlogin)
    {
        if(!response)
        {
        ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"{FFDD00}Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");
        return 1;
        }
        if(response)
        {
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            if(!strcmp(hashpass,pInfo[playerid][Pass]))
            {
                INI_ParseFile(Path(playerid),"loadaccount_user",.bExtra = true, .extra = playerid);
                SetPlayerScore(playerid, pInfo[playerid][Scores]);
                GivePlayerMoney(playerid, pInfo[playerid][Cash]);
                SetPlayerWantedLevel(playerid, pInfo[playerid][Rank]);
                new kname[24];
                GetPlayerName(playerid, kname, 24);
                new welcome1[128];
                format(welcome1, sizeof(welcome1), "Welcome back ~r~%s!",kname);
                GameTextForPlayer(playerid,welcome1,5000,4);
                SetTimerEx("CheckBan", 1000, false, "i", playerid);
                new string[150];
                format(string,sizeof(string),"** System: Logged in as {F70505}%s {FFFFFF}- Level: {F70505}%d",AdminLevelToName(playerid),pInfo[playerid][Admin]);
                SCM(playerid,-1,string);
                new lll[200];
                format(lll, sizeof(lll), "%s (%d) - %s (%d)", RankName(playerid),pInfo[playerid][Rank],AdminLevelToName(playerid),pInfo[playerid][Admin]);
                Update3DTextLabelText(RankLabel[playerid], GetTeamColor(playerid), lll);
                Attach3DTextLabelToPlayer(RankLabel[playerid], playerid, 0.0, 0.0, 0.6);
                Rules(playerid);
                return 1;
            }
            else
            {
                ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"{FFDD00}Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");
                new Year, Month, Day, Hour, Minute, Second;
                getdate(Year, Month, Day);
                gettime(Hour, Minute, Second);
                new echo[270];
                new kname[24];
                GetPlayerName(playerid, kname, 24);
                new IP[16];
                GetPlayerIp(playerid, IP, 16);
                format(echo,sizeof(echo),"0,3%s (%d) (IP: %s) failed to login in his account - %02d:%02d:%02d - %02d:%02d:%02d",kname,playerid,IP,Day,Month,Year,Hour,Minute,Second);
                FailedLogins(echo);
            }
        }
    }
This is OnPlayerConnect that ask if the player is registered or not:

pawn Код:
GetPlayerName(playerid,name,sizeof(name));
    if(fexist(Path(playerid)))
    {
        INI_ParseFile(Path(playerid),"loadaccount_user", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"{FFDD00}Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"{FFDD00}Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
        return 1;
    }
Can you guys find some mistakes? I dont see nothing, sometimes if i login my score and money are resetted to 0. I have saving variables when a player disconnect, also a timer that save players stats every 5 minutes.
Reply
#2

Ok. You know possible cause since I told you on IRC and I'm gonna post it here just in case someone gets in same problem. The most logical cause of this is that you are saving wrong variables. Normally when player connects his score is 0, same as all other stats (by stats we mean kills, deaths, money...). Now if your timer of 5 minutes expires before he logs in his old stats will be over-written by 0s. Since chances of this situation to happen are ~1:1 000 000 next possible scenario is that someone tries to enter on someone else's nick. Ex. I enter under your nick, I don't know password and I leave. Remember that stats are still 0 in Variables. OnPLayerDisconnect gets called and all original data are overwritten with 0s.

Solution: Save player data only if he is logged in.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)