SA-MP Forums Archive
OnGameModeExit problems. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnGameModeExit problems. (/showthread.php?tid=323804)



OnGameModeExit problems. - 2KY - 07.03.2012

Why does this reset all values to 0.0?

pawn Code:
public  OnGameModeExit( ) {
    new
        vPath[48];
       
    for( new v = 0; v < MAX_OWNED_VEHICLES; v++ ) {
        format( vPath, sizeof( vPath ), VEHICLE_PATH, v);
        if( fexist ( vPath ) ) {
            printf("vPath: %s", vPath);
            new
                mStr[48],
                Float:vPos[4],
                C1,         C2,
                INI:vehFile = INI_Open( vPath );
               
            GetVehiclePos( v, vPos[0], vPos[1], vPos[2] );
            GetVehicleZAngle( v, vPos[3] );
            GetVehicleColor( v, C1, C2 );
               
            INI_SetTag(vehFile, "vehicle");
           
            INI_WriteInt(vehFile, "ModelID",            vehInfo[v][ModelID]);
            INI_WriteInt(vehFile, "PrimaryColour",      C1);
            INI_WriteInt(vehFile, "SecondaryColour",    C2);
           
            INI_WriteInt(vehFile, "Locked",             vehInfo[v][Locked]);
           
            for( new m = 0; m < MAX_VEHICLE_MODS; m++ ) {
                format( mStr, sizeof( mStr ), "Modification%d", m);
                INI_WriteInt(vehFile, mStr,             vehInfo[v][Modification][m]);
            }
           
            INI_WriteString(vehFile, "Owner",           vehInfo[v][Owner]);
            INI_WriteString(vehFile, "LicensePlate",    vehInfo[v][LicensePlate]);

            INI_WriteFloat(vehFile, "XPOS",             vPos[0]);
            printf("vPos[0]: %f", vPos[0]);
            INI_WriteFloat(vehFile, "YPOS",             vPos[1]);
            INI_WriteFloat(vehFile, "ZPOS",             vPos[2]);
            INI_WriteFloat(vehFile, "APOS",             vPos[3]);
               
            INI_Close( vehFile );
        }
    }
    return true;
}



Re: OnGameModeExit problems. - Shabi RoxX - 07.03.2012

Same happens to me , it is cuz when server restart it dels all veh , all variable sets to 0, u may create a fuction to save data and then timer for gmx.......

Hope u understand


Re: OnGameModeExit problems. - T0pAz - 07.03.2012

Never worked on INI before but I think there is something wrong with the max owned vehicles variable.


Re: OnGameModeExit problems. - 2KY - 07.03.2012

Quote:
Originally Posted by Shabi RoxX
View Post
Same happens to me , it is cuz when server restart it dels all veh , all variable sets to 0, u may create a fuction to save data and then timer for gmx.......

Hope u understand
I will give a try, thank you.

Quote:
Originally Posted by T0pAz
View Post
Never worked on INI before but I think there is something wrong with the max owned vehicles variable.
That's not the problem as MAX_OWNED_VEHICLES is a number (1,000 in this case), and I've debugged it, and the loop DOES get called, it just resets all of my values to zero.