Player cash keeps resetting to 0 on disconnect
#1

First of all i'm using MySQL saving system. The problem is every time I disconnect from the server my cash keeps resetting to 0. I've checked my phpmyadmin and it only occurs on onplayerdisconnect. Can you please give me idea. What could be the problem? Thanks waiting for your response!

EDIT: Only gamemode is running and no filterscript
EDIT 2: So I tried to save my score on onplayerdisconnect and it's working but not the cash.

Here is my onplayerdisconnect
PHP код:
public OnPlayerDisconnectplayeridreason )
{
    
SetPlayerAmmo(playeridWEAPON_MINIGUN0);
    if(
race_veh[playerid] != INVALID_VEHICLE_ID)
    {
        
DestroyVehicle(race_veh[playerid]);
        
race_veh[playerid] = INVALID_VEHICLE_ID;
    }
    if ( 
PlayerInfoplayerid ][ LoggedIn ] == 1)
    {
        
SavePlayerplayerid );
    }
    if ( 
PlayerInfoplayerid ][ blip ] == )
        
KillTimerBlipTimerplayerid } );
    if ( 
PlayerInfoplayerid ][ pCar ] != -)
        
CarDeleterPlayerInfoplayerid ][ pCar ] );
    if( 
DuelInfo[player1] == playerid ||  DuelInfo[player2] == playerid)
    {
        if(
DuelInfo[stat]==2)
        {
          if(
playerid == DuelInfo[player1]) EndDuel(DuelInfo[player2],DuelInfo[player1]);
          else if(
playerid == DuelInfo[player2]) EndDuel(DuelInfo[player1],DuelInfo[player2]);
        }
        else
        {
            
DuelInfo[stat]=0,DuelInfo[player1]=-225,DuelInfo[player2]=-1;
        }
    }
    
DestroyVehicleSecV[playerid] );
    
formatgsQuery500"UPDATE `achievements` SET Ach1 = '%i', Ach2 = '%i', Ach3 = '%i', Ach4 = '%i', Ach5 = '%i', Ach6 = '%i', Ach7 = '%i', Ach8 = '%i', Ach9 = '%i', Ach10 = '%i', Ach11 = '%i', Ach12 = '%i', Ach13 = '%i', Ach14 = '%i', Ach15 = '%i', Ach16 = '%i', AchsCompleted = '%i' WHERE Username = '%s'",
    
AInfo[playerid][Ach1], AInfo[playerid][Ach2], AInfo[playerid][Ach3], AInfo[playerid][Ach4], AInfo[playerid][Ach5], AInfo[playerid][Ach6], AInfo[playerid][Ach7], AInfo[playerid][Ach8]
    , 
AInfo[playerid][Ach9], AInfo[playerid][Ach10], AInfo[playerid][Ach11], AInfo[playerid][Ach12], AInfo[playerid][Ach13], AInfo[playerid][Ach14], AInfo[playerid][Ach15], AInfo[playerid][Ach16], AInfo[playerid][AchsCompleted], GetPName(playerid));
    
mysql_querygsQueryTHREAD_NONEplayerid );
    
// Reseting the achievement variables
    
AInfo[playerid][Ach1] = 0AInfo[playerid][Ach2] = 0AInfo[playerid][Ach3] = 0AInfo[playerid][Ach4] = 0AInfo[playerid][Ach5] = 0AInfo[playerid][Ach6] = 0AInfo[playerid][Ach7] = 0AInfo[playerid][AchsCompleted] = 0;
    
AInfo[playerid][Ach8] = 0AInfo[playerid][Ach9] = 0AInfo[playerid][Ach10] = 0AInfo[playerid][Ach11] = 0AInfo[playerid][Ach12] = 0AInfo[playerid][Ach13] = 0AInfo[playerid][Ach14] = 0,AInfo[playerid][Ach15] = 0AInfo[playerid][Ach16] = 0;
    if(
SecV[playerid] != INVALID_VEHICLE_ID)
    {
      if(
SCar[SecV[playerid]]!=0DestroyVehicleEX(SecV[playerid]);
      
SCar[SecV[playerid]] = 0;
    }
    for(new 
i=0i<MAX_PLAYER_ATTACHED_OBJECTSi++)
    {
            if(
IsPlayerAttachedObjectSlotUsed(playeridi)) RemovePlayerAttachedObject(playeridi);
    }
    
SetPlayerSpecialActionplayeridSPECIAL_ACTION_NONE );
    
ClearAnimations(playerid);
    
PlayerTextDrawDestroy(playerid,pmTD[playerid][0]);
    
PlayerTextDrawDestroy(playerid,pmTD[playerid][1]);
    for(new 
i=0i<MAX_PLAYER_ATTACHED_OBJECTSi++)
    {
            if(
IsPlayerAttachedObjectSlotUsed(playeridi)) RemovePlayerAttachedObject(playeridi);
    }
    if(
GetPVarInt(playerid,"Signed4Lms")) Remove_From_Lms(playerid,0);
    
PlayerTextDrawDestroy(playerid,pInfoText[playerid]);
    if( 
GetPVarInt(playerid,"inFallout"))
    {
        
RemoveFromFallout(playerid,0);
    }
    
DestroyVehObjectplayerid );
    
PlayerTextDrawDestroy(playerid,pInfoTD[playerid]);
    
gsString] = EOS;
    switch ( 
reason )
    {
        case 
0formatgsStringsizeofgsString ), ""R"<> "S"%s(%d) {c8c8c8}has left the server "O"[%d/%d] {c8c8c8}(Crash)"PlayerNameplayerid ), playeridConnectedPlayers( ) - 1MAX_PLAYERS );
        case 
1formatgsStringsizeofgsString ), ""R"<> "S"%s(%d) {c8c8c8}has left the server "O"[%d/%d] {c8c8c8}(Leaving)"PlayerNameplayerid ), playeridConnectedPlayers( ) - 1MAX_PLAYERS );
        case 
2formatgsStringsizeofgsString ), ""R"<> "S"%s(%d) {c8c8c8}has left the server "O"[%d/%d] {c8c8c8}(Kick/Ban)"PlayerNameplayerid ), playeridConnectedPlayers( ) - 1MAX_PLAYERS );
    }
    
SendClientMessageToAllCOLOR_GREYgsString );
    if ( 
hitplayerid ] > )
    {
        
formatgsStringsizeofgsString ), "The hit on {FF0000}%s (%i) {33CCFF}has been cancelled {FF0000}(Disconnected)"PlayerNameplayerid ), playerid );
        
SendClientMessageToAllCOLOR_LIGHTBLUEgsString );
        
hitplayerid ] = 0;
    }
    if ( 
PlayerInfoplayerid ][ HaveGPS ] )
    {
        
KillTimerGPSTimerplayerid ] );
        
PlayerInfoplayerid ][ HaveGPS ] = false;
        
GPSTimerplayerid ] = 0;
    }
    
KillTimerGotoTimerplayerid ] );
    
Iter_Remove(GodListplayerid);
    if ( 
griderplayerid ][ ] )
    {
        
DestroyObjectgriderplayerid ][ ] );
        
DestroyObjectgriderplayerid ][ ] );
        
DestroyObjectgriderplayerid ][ ] );
        
griderplayerid ][ ] = 0;
    }
    
TextDrawDestroySpecTDplayerid ][ ] );
    
TextDrawDestroySpecTDplayerid ][ ] );
    if ( 
PlayerInfoplayerid ][ ActionID ] == // ( Derby )
    
{
        
Iter_Remove(PlayerInDerbyplayerid);
        
PlayerInfoplayerid ][ ActionID ] = 0;
        
BloodringFullPlayerInfoplayerid ][ PlayerInBloodring ] ] = 0;
           
PlayerInfoplayerid ][ PlayerInBloodring ] = -1;
           
SetPlayerVirtualWorldplayerid);
    }
    if ( 
PlayerInfoplayerid ][ ActionID ] == 12 )
        
DestroyVehicleSF_PK_Carplayerid ] );
    foreach(new 
xPlayer)
        if ( 
GetPlayerState) == PLAYER_STATE_SPECTATING && PlayerInfo][ SpecID ] == playerid )
            
AdvanceSpectate);
    if ( 
PlayerInfoplayerid ][ ActionID ] == )
    {
        
JoinCount--;
        
PlayerInfoplayerid ][ ActionID ] = ( );
        
DestroyVehicle(CreatedRaceVeh[playerid]);
        
DisablePlayerRaceCheckpoint(playerid);
        for ( new 
011i++ )
              
PlayerTextDrawHideplayeridRace_InfoTD] );
        
CPProgess[playerid] = 0;
        
KillTimerInfoTimerplayerid ] );
        
#if defined RACE_IN_OTHER_WORLD
        
SetPlayerVirtualWorld(playeridRaceWorld);
        
SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), RaceWorld);
        
#endif
    
}
     return ( 
);

Reply
#2

Use mysql_format(...);
Reply
#3

Show your SavePlayer( playerid );
Reply
#4

Guys! After removing SavePlayer from the script it solves the problem. But i'm still not sure what's exactly problem is and I wanna fix it.

EDIT: I change PlayerInfo[playerid][pMoney] to GetPlayerMoney(playerid) and it solves the problem.


PHP код:
SavePlayerplayerid )
{
    new
        
Ratio]
    ;
    
Ratio] = PlayerInfoplayerid ][ PKicks ] + PlayerInfoplayerid ][ PBans ];
    
Ratio] = Ratio] + PlayerInfoplayerid ][ PWarns ];
    
Ratio] = Ratio] + PlayerInfoplayerid ][ PJails ];
    
Ratio] = Ratio] + PlayerInfoplayerid ][ PClearCH ];
    
Ratio] = Ratio] + PlayerInfoplayerid ][ PReactions ];
    
Ratio] = Ratio] + PlayerInfoplayerid ][ PMaths ];
    
Ratio] = Ratio] + PlayerInfoplayerid ][ PMutes ];
    
//-------------------------------- Saving Stats --------------------------//
    
new
        
h,
        
m,
        
s,
        
szYear,
        
szMonth,
        
szDay
    
;
    
TotalGameTimeplayeridhm);
    
getdateszYearszMonthszDay );
    
gsString] = EOS;
    
formatgsString2048"UPDATE `accounts` SET `LoggedIn` = '0',`Admin` = '%d',`rVip` = '%d',`LastOn` = '%d-%d-%d',`Car` = '%d',`Bank` = '%d',`Cash` = '%d', `SavedSkin` = '%d', `IsSavedSkin` = '%d'"PlayerInfoplayerid ][ Level ], PlayerInfoplayerid ][ rVip ], szYearszMonthszDay,PlayerInfo[playerid][Car],PlayerInfo[playerid][Bank],PlayerInfo[playerid][pMoney], PlayerInfo[playerid][SavedSkin], PlayerInfo[playerid][IsSavedSkin]);
    
formatgsString2048"%s,`Score` = '%d',`Kills` = '%d',`Deaths` = '%d',`Online` = '%d:%d:%d',`BestKillings` = '%d', `Nickcolor` = '%d'"gsStringGetPlayerScoreplayerid ), PlayerInfoplayerid ][ Kills ], PlayerInfoplayerid ][ Deaths ],h,m,sPlayerInfoplayerid ][ bKillingSpree ], PlayerInfoplayerid ][ Nickcolor ] );
    
formatgsString2048"%s,`KillingSpree` = '%d',`Cookies` = '%d',`SAdmin` = '%d'"gsStringPlayerInfoplayerid ][ KillingSpree ], PlayerInfoplayerid ][ Cookies ], PlayerInfoplayerid ][ SAdmin ] );
    
formatgsString2048"%s,`Description` = '%s',`Cookiejar` = '%d',`Moneybag` = '%d'"gsStringPlayerInfoplayerid ][ Description ], PlayerInfoplayerid ][ cjfound ], PlayerInfoplayerid ][ mbfound ] );
    
formatgsString2048"%s,`Group` = '%s',`GroupRank` = '%d'"gsStringPlayerInfoplayerid ][ GroupName ], PlayerInfoplayerid ][ GRank ]);
    
formatgsString2048"%s,`Kicks` = '%d',`Bans` = '%d',`Jails` = '%d',`Warns` = '%d',`ClearChats` = '%d',`ReactionTest` = '%d',`MathTest` = '%d'"gsStringPlayerInfoplayerid ][ PKicks ], PlayerInfoplayerid ][ PBans ], PlayerInfoplayerid ][ PJails ], PlayerInfoplayerid ][ PWarns ], PlayerInfoplayerid ][ PClearCH ], PlayerInfoplayerid ][ PReactions ], PlayerInfoplayerid ][ PMaths ] );
    
formatgsString2048"%s,`Mutes` = '%d',`ARatio` = '%d',`Jailed` = '%d',`JailTime` = '%d:%d',`Frozen` = '%d',`FreezeTime` = '%d:%d'"gsStringPlayerInfoplayerid ][ PMutes ], Ratio], PlayerInfoplayerid ][ Jailed ], gTimeplayerid ][ ], gTimeplayerid ][ ], PlayerInfoplayerid ][ Frozen ], gTimeplayerid ][ ], gTimeplayerid ][ ] );
    
formatgsString2048"%s,`RAdmin` = '%d',`ChatColor` = '%d'"gsStringPlayerInfoplayerid ][ rAdmin ], PlayerInfoplayerid ][ TextColor ]);
    
formatgsString2048"%s, `Duelwon` = '%d',`Reportpoint` = '%d',`Eventwon` = '%d'"gsString,  PlayerInfoplayerid ][ Duelwon ],PlayerInfoplayerid ][ Reportpoint ], PlayerInfoplayerid ][ Eventwon ] );
    
formatgsString2048"%s, `TopOnline` = '%d:%d:%d',`Reactionwon` = '%d',`Mathwon` = '%d'"gsStringPlayerInfoplayerid ][ hours ], PlayerInfoplayerid ][ mins ], PlayerInfoplayerid ][ secs ], PlayerInfoplayerid ][ Reactionwon ], PlayerInfoplayerid ][ Mathwon ] );
    
formatgsString2048"%s,`Falloutwon` = '%d',`Derbywon` = '%d',`Racewon` = '%d' WHERE `Key` = '%d'"gsString,  PlayerInfoplayerid ][ Falloutwon ], PlayerInfoplayerid ][ Derbywon ], PlayerInfoplayerid ][ Racewon ],PlayerInfoplayerid ][ AccID ] );
    
mysql_querygsStringTHREAD_NONEplayerid );
    return ( 
);

Reply


Forum Jump:


Users browsing this thread: