Sometimes weapons do not save properly
#1

Is GetPlayerWeaponData delayed or something? Every other variable saves, it's just weapons that don't, and it's not even every time, it's only sometimes.

pawn Код:
public OnPlayerDisconnect( playerid, reason )
{
    if( plLoggedIn [ playerid ] == true )
    {
        new
            INI:    saveFile = INI_Open( FindPlayerFile( playerid ) ),
            Float:  plPos [ 4 ],
                    plWeapons [ 13 ] [ 2 ],
                    wepStr [ 32 ],
                    ammoStr [ 32 ];
                   
        GetPlayerPos( playerid, plPos [ 0 ], plPos [ 1 ], plPos [ 2 ] );
        GetPlayerFacingAngle( playerid, plPos [ 3 ] );
                   
        INI_SetTag( saveFile,           "data" );
                   
        INI_WriteInt( saveFile,         "Access",           plStats [ playerid ] [ Access ] );
        INI_WriteInt( saveFile,         "Skin",             plStats [ playerid ] [ Skin ] );
       
        INI_WriteInt( saveFile,         "Interior",         GetPlayerInterior( playerid ) );
        INI_WriteInt( saveFile,         "VirtualWorld",     GetPlayerVirtualWorld( playerid ) );
        INI_WriteInt( saveFile,         "CellPhoneNumber",  plStats [ playerid ] [ CellPhoneNumber ] );
        INI_WriteInt( saveFile,         "CellPhoneBattery", plStats [ playerid ] [ CellPhoneBatteryLife ] );
       
        // Inventory System
        INI_WriteInt( saveFile,         "BadgeNumber",      plStats [ playerid ] [ BadgeNumber ] );
        INI_WriteInt( saveFile,         "CBRadio",          plStats [ playerid ] [ CBRadio ] );
        INI_WriteInt( saveFile,         "LottoTicket",      plStats [ playerid ] [ LottoTicket ] );
       
        // Faction System
        INI_WriteInt( saveFile,         "FactionID",        plStats [ playerid ] [ FactionID ] );
        INI_WriteInt( saveFile,         "FactionRank",      plStats [ playerid ] [ FactionRank ] );
       
        INI_WriteInt( saveFile,         "Money",            plStats [ playerid ] [ Money ] );
       
        INI_WriteString( saveFile,      "IntroSong",        plStats [ playerid ] [ IntroSong ] );
       
        INI_WriteFloat( saveFile,       "Position_X",       plPos [ 0 ] );
        INI_WriteFloat( saveFile,       "Position_Y",       plPos [ 1 ] );
        INI_WriteFloat( saveFile,       "Position_Z",       plPos [ 2 ] );
        INI_WriteFloat( saveFile,       "Position_A",       plPos [ 3 ] );
       
        for( new w; w < 12; w ++ )
        {
            GetPlayerWeaponData( playerid, w, plWeapons [ w ] [ 0 ], plWeapons [ w ] [ 1 ] );
           
            format( wepStr, sizeof wepStr, "Weapon_%d", w );
            INI_WriteInt( saveFile,     wepStr,             plWeapons [ w ] [ 0 ] );
           
            format( ammoStr, sizeof ammoStr, "Ammo_%d", w );
            INI_WriteInt( saveFile,     ammoStr,            plWeapons [ w ] [ 1 ] );
        }

        INI_Close( saveFile );
       
        plLoggedIn [ playerid ] = false;
    }
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)