Vehicle System playing up
#1

I'm posting this in a new thread because although its the same issue my weapon system had, I think its a different cause, this time its not assigning the values correctly. I just implemented a car system and it has the exact same problem, the file for the car isn't being created unless I shut the server down while I am ingame, and when they are, they aren't receiving any names for the cars, (its meant to be "%d.ini(in the case of id 0 = 0.ini) But its just being saved as .ini)

Код:
stock VehicleGet(vehicleID)
{
	GetVehiclePos(VehicleInfo[vehicleID][vID], VehicleInfo[vehicleID][vX], VehicleInfo[vehicleID][vY], VehicleInfo[vehicleID][vZ]);
    GetVehicleZAngle(VehicleInfo[vehicleID][vID], VehicleInfo[vehicleID][vA]);
}
stock VehicleLoad(vehicleID, file[])
{
	INI_ParseFile(file, "LoadVehicleData", .bExtra = true, .extra = vehicleID);
	VehicleCreate(VehicleInfo[vehicleID][vModel], VehicleInfo[vehicleID][vX], VehicleInfo[vehicleID][vY], VehicleInfo[vehicleID][vZ], VehicleInfo[vehicleID][vA], VehicleInfo[vehicleID][vColor1], VehicleInfo[vehicleID][vColor2], VehicleInfo[vehicleID][vRespawn], VehicleInfo[vehicleID][vOwner]);
}
forward LoadVehicleData(vehicleID, name[], value[]);
public LoadVehicleData(vehicleID, name[], value[])
{
    INI_Int("model", VehicleInfo[vehicleID][vModel]);
	INI_Float("xloc", VehicleInfo[vehicleID][vX]);
	INI_Float("yloc", VehicleInfo[vehicleID][vY]);
	INI_Float("zloc", VehicleInfo[vehicleID][vZ]);
	INI_Float("aloc", VehicleInfo[vehicleID][vA]);
	INI_Int("color1", VehicleInfo[vehicleID][vColor1]);
    INI_Int("color2", VehicleInfo[vehicleID][vColor2]);
    INI_Int("respawn", VehicleInfo[vehicleID][vRespawn]);
    INI_String("owner", VehicleInfo[vehicleID][vOwner], MAX_PLAYER_NAME);
    return 1;
}
stock VehicleSave(vehicleID)
{
    new INI:dFile = INI_Open(VehiclePath(vehicleID));
    INI_WriteInt(dFile, "model", VehicleInfo[vehicleID][vModel]);
	INI_WriteFloat(dFile, "xloc", VehicleInfo[vehicleID][vX]);
	INI_WriteFloat(dFile, "yloc", VehicleInfo[vehicleID][vY]);
	INI_WriteFloat(dFile, "zloc", VehicleInfo[vehicleID][vZ]);
	INI_WriteFloat(dFile, "aloc", VehicleInfo[vehicleID][vA]);
  	INI_WriteInt(dFile, "color1", VehicleInfo[vehicleID][vColor1]);
    INI_WriteInt(dFile, "color2", VehicleInfo[vehicleID][vColor2]);
    INI_WriteInt(dFile, "respawn", VehicleInfo[vehicleID][vRespawn]);
    INI_WriteString(dFile, "owner", VehicleInfo[vehicleID][vOwner]);
    INI_Close(dFile);
    return 1;
}
stock VehicleLoadAll()
{
    new index = 0;
    while(fexist(VehiclePath(index)))
    {
        VehicleLoad(index, VehiclePath(index));
        index++;
	}
    printf("Vehicles Loaded: %d", index);
}
stock VehicleSaveAll()
{
    new index = 0;
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(vCreated[i])
        {
            VehicleGet(index);
            VehicleSave(index);
            index++;
        }
    }
    printf("Vehicles Saved: %d", index);
}
Its just not saving the vehicle correctly, I'm pretty sure it'll load fine when it saves, but it just refuses to save correctly, but produces no errors, any advice would be helpful, thanks.
Reply
#2

Sorry for the bump, but I did a debug and found out the loading system is working fine, its the saving system that is the issue, I did the debug to see exactly what it was picking up,

It said its X, Y and Z coords were 0, 0, 0 and its angle was 0 too, it said its id was 0, which isn't right, the car I made is like ID11 or something, and its making .ini for the vehicle, not 0.ini, for example, I cant figure out whats wrong though.
Reply
#3

12 hours later and another bump, because I've narrowed the issue down,

It seems to be to do with the car being created in a command, then it won't save anything to do with it, but if it's made when the GM starts, it'll save everything fine apart from the Model of the vehicle, I'm not sure why it won't save the model though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)