25.07.2016, 23:44
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
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 OnPlayerDisconnect( playerid, reason )
{
SetPlayerAmmo(playerid, WEAPON_MINIGUN, 0);
if(race_veh[playerid] != INVALID_VEHICLE_ID)
{
DestroyVehicle(race_veh[playerid]);
race_veh[playerid] = INVALID_VEHICLE_ID;
}
if ( PlayerInfo[ playerid ][ LoggedIn ] == 1)
{
SavePlayer( playerid );
}
if ( PlayerInfo[ playerid ][ blip ] == 1 )
KillTimer( BlipTimer{ playerid } );
if ( PlayerInfo[ playerid ][ pCar ] != -1 )
CarDeleter( PlayerInfo[ playerid ][ 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;
}
}
DestroyVehicle( SecV[playerid] );
format( gsQuery, 500, "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_query( gsQuery, THREAD_NONE, playerid );
// Reseting the achievement variables
AInfo[playerid][Ach1] = 0, AInfo[playerid][Ach2] = 0, AInfo[playerid][Ach3] = 0, AInfo[playerid][Ach4] = 0, AInfo[playerid][Ach5] = 0, AInfo[playerid][Ach6] = 0, AInfo[playerid][Ach7] = 0, AInfo[playerid][AchsCompleted] = 0;
AInfo[playerid][Ach8] = 0, AInfo[playerid][Ach9] = 0, AInfo[playerid][Ach10] = 0, AInfo[playerid][Ach11] = 0, AInfo[playerid][Ach12] = 0, AInfo[playerid][Ach13] = 0, AInfo[playerid][Ach14] = 0,AInfo[playerid][Ach15] = 0, AInfo[playerid][Ach16] = 0;
if(SecV[playerid] != INVALID_VEHICLE_ID)
{
if(SCar[SecV[playerid]]!=0) DestroyVehicleEX(SecV[playerid]);
SCar[SecV[playerid]] = 0;
}
for(new i=0; i<MAX_PLAYER_ATTACHED_OBJECTS; i++)
{
if(IsPlayerAttachedObjectSlotUsed(playerid, i)) RemovePlayerAttachedObject(playerid, i);
}
SetPlayerSpecialAction( playerid, SPECIAL_ACTION_NONE );
ClearAnimations(playerid);
PlayerTextDrawDestroy(playerid,pmTD[playerid][0]);
PlayerTextDrawDestroy(playerid,pmTD[playerid][1]);
for(new i=0; i<MAX_PLAYER_ATTACHED_OBJECTS; i++)
{
if(IsPlayerAttachedObjectSlotUsed(playerid, i)) RemovePlayerAttachedObject(playerid, i);
}
if(GetPVarInt(playerid,"Signed4Lms")) Remove_From_Lms(playerid,0);
PlayerTextDrawDestroy(playerid,pInfoText[playerid]);
if( GetPVarInt(playerid,"inFallout"))
{
RemoveFromFallout(playerid,0);
}
DestroyVehObject( playerid );
PlayerTextDrawDestroy(playerid,pInfoTD[playerid]);
gsString[ 0 ] = EOS;
switch ( reason )
{
case 0: format( gsString, sizeof( gsString ), ""R"<> "S"%s(%d) {c8c8c8}has left the server "O"[%d/%d] {c8c8c8}(Crash)", PlayerName( playerid ), playerid, ConnectedPlayers( ) - 1, MAX_PLAYERS );
case 1: format( gsString, sizeof( gsString ), ""R"<> "S"%s(%d) {c8c8c8}has left the server "O"[%d/%d] {c8c8c8}(Leaving)", PlayerName( playerid ), playerid, ConnectedPlayers( ) - 1, MAX_PLAYERS );
case 2: format( gsString, sizeof( gsString ), ""R"<> "S"%s(%d) {c8c8c8}has left the server "O"[%d/%d] {c8c8c8}(Kick/Ban)", PlayerName( playerid ), playerid, ConnectedPlayers( ) - 1, MAX_PLAYERS );
}
SendClientMessageToAll( COLOR_GREY, gsString );
if ( hit[ playerid ] > 0 )
{
format( gsString, sizeof( gsString ), "The hit on {FF0000}%s (%i) {33CCFF}has been cancelled {FF0000}(Disconnected)", PlayerName( playerid ), playerid );
SendClientMessageToAll( COLOR_LIGHTBLUE, gsString );
hit[ playerid ] = 0;
}
if ( PlayerInfo[ playerid ][ HaveGPS ] )
{
KillTimer( GPSTimer[ playerid ] );
PlayerInfo[ playerid ][ HaveGPS ] = false;
GPSTimer[ playerid ] = 0;
}
KillTimer( GotoTimer[ playerid ] );
Iter_Remove(GodList, playerid);
if ( grider[ playerid ][ 0 ] )
{
DestroyObject( grider[ playerid ][ 0 ] );
DestroyObject( grider[ playerid ][ 1 ] );
DestroyObject( grider[ playerid ][ 2 ] );
grider[ playerid ][ 0 ] = 0;
}
TextDrawDestroy( SpecTD[ playerid ][ 0 ] );
TextDrawDestroy( SpecTD[ playerid ][ 1 ] );
if ( PlayerInfo[ playerid ][ ActionID ] == 4 ) // ( Derby )
{
Iter_Remove(PlayerInDerby, playerid);
PlayerInfo[ playerid ][ ActionID ] = 0;
BloodringFull[ PlayerInfo[ playerid ][ PlayerInBloodring ] ] = 0;
PlayerInfo[ playerid ][ PlayerInBloodring ] = -1;
SetPlayerVirtualWorld( playerid, 0 );
}
if ( PlayerInfo[ playerid ][ ActionID ] == 12 )
DestroyVehicle( SF_PK_Car[ playerid ] );
foreach(new x: Player)
if ( GetPlayerState( x ) == PLAYER_STATE_SPECTATING && PlayerInfo[ x ][ SpecID ] == playerid )
AdvanceSpectate( x );
if ( PlayerInfo[ playerid ][ ActionID ] == 8 )
{
JoinCount--;
PlayerInfo[ playerid ][ ActionID ] = ( 0 );
DestroyVehicle(CreatedRaceVeh[playerid]);
DisablePlayerRaceCheckpoint(playerid);
for ( new i = 0; i < 11; i++ )
PlayerTextDrawHide( playerid, Race_InfoTD[ i ] );
CPProgess[playerid] = 0;
KillTimer( InfoTimer[ playerid ] );
#if defined RACE_IN_OTHER_WORLD
SetPlayerVirtualWorld(playerid, RaceWorld);
SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), RaceWorld);
#endif
}
return ( 1 );
}