Vehicle system nulls on restart
#1

Vehicle enum.
PHP код:
enum vInfo
{
    
vID,
    
vHasKey,
    
vKeyID,
    
vModel,
    
vFuel,
    
vUsingFuel,
    
vOil,
    
vCanRun,
    
vInsured,
    
Float:vX,
    
Float:vY,
    
Float:vZ,
    
Float:vA,
    
vColor1,
    
vColor2,
    
vFaction,
    
vOwner[MAX_PLAYER_NAME],
    
vPrevOwners,
    
vLocked,
    
vRegdate[24],
    
vCash,
    
vWeapon,
    
vPot,
    
vCrack
}; 
The code for how the vehicles are created from the vehicle system files on start up under OnGameModeInit.
PHP код:
new string[40], vCount 0bCount 0;
    
    for(new 
0sizeof(VehicleInfo); i++)
    {
        new 
vFile[35];
        
format(vFile50vPATH ,i);
        if(
fexist(vFile))
        {
            
INI_ParseFile(vFile"LoadVehicle", .bExtra true, .extra i);
            if(
VehicleInfo[i][vModel] != 0)
            {
                
vCount++;
        
VehicleInfo[i][vID] = CreateVehicle(VehicleInfo[i][vModel], VehicleInfo[i][vX],VehicleInfo[i][vY],VehicleInfo[i][vZ],VehicleInfo[i][vA], VehicleInfo[i][vColor1], VehicleInfo[i][vColor2], -1);
        
SetVehicleParamsEx(i0000000);
            }
        }
    }
    
    
format(stringsizeof(string), " %i vehicles have been loaded!\n"vCount);
    print(string); 
The code for how the vehicles are saved.
PHP код:
function SaveVehicle(fileid)
{
    new 
vFile[128], Float:vsXFloat:vsYFloat:vsZFloat:vsA;
    
format(vFilesizeof(vFile),vPATH,fileid);
    
GetVehiclePos(VehicleInfo[fileid][vID], vsXvsYvsZ);
    
GetVehicleZAngle(VehicleInfo[fileid][vID], vsA);
    
VehicleInfo[fileid][vX] = vsX;
    
VehicleInfo[fileid][vY] = vsY;
    
VehicleInfo[fileid][vZ] = vsZ;
    
VehicleInfo[fileid][vA] = vsA;
    new 
INI:File INI_Open(vFile);
    
INI_WriteInt(File,"KeyID",VehicleInfo[fileid][vKeyID]);
    
INI_WriteInt(File,"HasKey",VehicleInfo[fileid][vHasKey]);
    
INI_WriteInt(File,"Model",VehicleInfo[fileid][vModel]);
    
INI_WriteInt(File,"Fuel",VehicleInfo[fileid][vFuel]);
    
INI_WriteInt(File,"UsingFuel",VehicleInfo[fileid][vUsingFuel]);
    
INI_WriteInt(File,"Oil",VehicleInfo[fileid][vOil]);
    
INI_WriteInt(File,"CanRun",VehicleInfo[fileid][vCanRun]);
    
INI_WriteInt(File,"Insured",VehicleInfo[fileid][vInsured]);
    
INI_WriteFloat(File,"X",VehicleInfo[fileid][vX]);
    
INI_WriteFloat(File,"Y",VehicleInfo[fileid][vY]);
    
INI_WriteFloat(File,"Z",VehicleInfo[fileid][vZ]);
    
INI_WriteFloat(File,"A",VehicleInfo[fileid][vA]);
    
INI_WriteInt(File,"Color1",VehicleInfo[fileid][vColor1]);
    
INI_WriteInt(File,"Color2",VehicleInfo[fileid][vColor2]);
    
INI_WriteInt(File,"Faction",VehicleInfo[fileid][vFaction]);
    
INI_WriteString(File,"Owner",VehicleInfo[fileid][vOwner]);
    
INI_WriteInt(File,"PrevOwners",VehicleInfo[fileid][vPrevOwners]);
    
INI_WriteString(File,"RegDate",VehicleInfo[fileid][vRegdate]);
    
INI_WriteInt(File,"Cash",VehicleInfo[fileid][vCash]);
    
INI_WriteInt(File,"Weapon",VehicleInfo[fileid][vWeapon]);
    
INI_WriteInt(File,"Pot",VehicleInfo[fileid][vPot]);
    
INI_WriteInt(File,"Crack",VehicleInfo[fileid][vCrack]);
    
INI_Close(File);
    return 
1;

Issue: Vehicle data saves perfectly fine. I even tested it to make sure it wasn't the file saving system by turning off the server and manually checking each vehicle file and the coordinates are saved as needed.
The issue I am running into is when I load up the server all the vehicles spawn at 0.0, 0.0, 0.0 in the middle of that field and after I start it I check the files again and the cords they are saved to are 0.0, 0.0, 0.0 now but now before I start the server.

I took a break from this project about 6 months ago because of this issue and I've had the itch to play with it again, so I thought I'd ask for some help.
Anybody have any idea?

Note: This system worked previously, but I cannot figure out if I messed up the loading code above or its something else.

Thank you guys for taking the time to look.
Reply


Messages In This Thread
Vehicle system nulls on restart - by DevHarden - 20.03.2017, 00:05
Re: Vehicle system nulls on restart - by Mencent - 20.03.2017, 12:41
Re: Vehicle system nulls on restart - by DevHarden - 21.03.2017, 00:57
Re: Vehicle system nulls on restart - by DevHarden - 21.03.2017, 14:37
Re: Vehicle system nulls on restart - by Toroi - 21.03.2017, 14:40
Re: Vehicle system nulls on restart - by DevHarden - 21.03.2017, 14:55
Re: Vehicle system nulls on restart - by Bolex_ - 21.03.2017, 15:02
Re: Vehicle system nulls on restart - by DevHarden - 21.03.2017, 15:25
Re: Vehicle system nulls on restart - by Toroi - 21.03.2017, 15:27
Re: Vehicle system nulls on restart - by DevHarden - 21.03.2017, 15:29

Forum Jump:


Users browsing this thread: 2 Guest(s)