'Bug' I could never fix
#1

I've had this issue for like a year now. Player stats DON'T save when you get kicked or banned, or even crash. I really hate this, and so do my fellow beta testers. I'm scripting from scratch, using y_ini if they makes any difference. I would really, really apperciate it if people told me how to ensure player account ALWAYS saves no matter if you get kicked, time out, crash, banned(then unbanned) and possibly even restarts if possible of course.

Thanks in advance and I really hope someone will have methods to help me out.
Reply
#2

Your code, perhaps?
Reply
#3

Which codes are needed? I'd assume you would want to see onplayerdisconnect?
Reply
#4

The code where you save the stuff?
Well yeah I guess it's in your OnPlayerDisconnect callback.
Reply
#5

Alright, here it is:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new string[ 124 ];
    GetPlayerPos(playerid, PlayerInfo[playerid][pPosX] ,PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
    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_WriteFloat(File,"X", PlayerInfo[playerid][pPosX]);
    INI_WriteFloat(File,"Y", PlayerInfo[playerid][pPosY]);
    INI_WriteFloat(File,"Z", PlayerInfo[playerid][pPosZ]);
    INI_WriteInt(File, "Int", GetPlayerInterior(playerid));
    INI_WriteInt(File, "VW", GetPlayerVirtualWorld(playerid));
    INI_WriteInt(File, "Gender", PlayerInfo[playerid][pGender]);
    INI_WriteInt(File, "Skin", GetPlayerSkin(playerid));
    INI_WriteInt(File, "Age", PlayerInfo[playerid][pAge]);
    INI_WriteInt(File, "Tut", PlayerInfo[playerid][pTut]);
    INI_WriteInt(File, "APass", PlayerInfo[playerid][pAPass]);
    INI_WriteInt(File, "Leader", PlayerInfo[playerid][pLeader]);
    INI_WriteInt(File, "Member", PlayerInfo[playerid][pMember]);
    INI_WriteInt(File, "Rank", PlayerInfo[playerid][pRank]);
    INI_WriteInt(File, "Job", PlayerInfo[playerid][pJob]);
    INI_WriteInt(File, "Muted", PlayerInfo[playerid][pMuted]);
    INI_WriteInt(File, "Warned",PlayerInfo[playerid][pWarned]);
    INI_WriteInt(File, "PDSkin",PlayerInfo[playerid][pPDutySkin]);
    INI_WriteInt(File, "Number",PlayerInfo[playerid][pNumber]);
    INI_WriteInt(File, "Phonetype",PlayerInfo[playerid][pPhone]);
    INI_WriteInt(File, "PDKey",PlayerInfo[playerid][pPDKey]);
    INI_WriteInt(File, "BankAcc",PlayerInfo[playerid][pBankAcc]);
    INI_WriteString(File, "BankNum",PlayerInfo[playerid][pBankNum]);
    INI_WriteInt(File, "BankAmount",PlayerInfo[playerid][pBankAmount]);
    INI_WriteInt(File, "Frozen",PlayerInfo[playerid][pFrozen]);
    INI_WriteInt(File, "PayCheck",PlayerInfo[playerid][pPayCheck]);
    INI_WriteInt(File, "PayTime",PlayerInfo[playerid][pPayTime]);
    INI_WriteInt(File, "PayTotal",PlayerInfo[playerid][pPayTotal]);
    INI_Close(File);
   
    PlayerInfo[playerid][pALogged] = 0;
    PlayerInfo[playerid][pADuty] = 0;
    PlayerInfo[playerid][pPDuty] = 0;
   
    foreach(Player, x)
    {
        if(PlayerInfo[x][pAdmin] >= 2)
        {
            format(string, 124, "[%i]%s has disconnected from the server.", playerid,pName(playerid));
            SendClientMessage(x, COLOR_PURPLE, string);
        }
    }
    PlayerInfo[playerid][pPhoneCall] = 0;


    return 1;
}
Reply
#6

If you want stats to save when the server restarts, you'll have to save it periodically i.e. every 5 or 10 minutes. You could also save it as soon as they are rewarded score/cash, so they don't lose anything.

Also, if stats aren't saving, the problem could be in the loading also, not necessarily in the saving.
Reply
#7

Loads perfectly fine for normal logins and etc. I attempt to save ongamemodeexit, but no work.

pawn Код:
public OnGameModeExit()
{
    for(new i=0;i<MAX_PLAYERS; i++)
    {
        if(i != INVALID_PLAYER_ID)
        {
              SavePlayer(i);
        }
    }
    return 1;
}
Keep in mind I get the same issue with kick(playerid), doesn't save them while being kicked
Reply
#8

OnGameModeExit isn't called when the server crashes. Nothing is called after a server crash because, needless to say really, the server's off.
Also that loop won't work because you're looping through VALID player IDs. You need to use IsPlayerConnected().
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)