Vehicle System: Vehicle spawns with saved Modelid and color1+2 but not on the XYZA
#1

ISSUE STATUS: SOLVED!!

Hi there, I have made a script with a vehicle system which ALMOST works 100%.
I can create and remove vehicles while in-game and the info will be saved and loaded succesfully on respawns and such. But now if I restart my server the vehicles get loaded on their saved Modelid and Color1 + Color2 but not the X, Y, Z, & A.

I am using Y_INI as my saving system since I never had trouble with saving/loading INI files.
My Enums XYZA are with "Float:" in front of it. Aswell in Saving stats and Loading stats its INI_WriteFloat and INI_Float so that should be good in my opnion.

Here is my Loader:
Код:
//------------------------------------------------------------[ VEHICLE LOADER ]

{
    for(new v = 0; v < sizeof(VehicleInfo); v++) //loop
    {
        new vFile[128];
        format(vFile, 50, VEHICLE_FOLDER ,v);
        if(fexist(vFile))
        {
        	INI_ParseFile(dFile, "LoadVehicle", .bExtra = true, .extra = v);
         	if(VehicleInfo[v][vModel] != 0)
			{
				VehicleInfo[v][vID] = AddStaticVehicleEx(VehicleInfo[v][vModel], VehicleInfo[v][vX], VehicleInfo[v][vY], VehicleInfo[v][vZ], VehicleInfo[v][vA],VehicleInfo[v][vColor1],VehicleInfo[v][vColor2], 0);
			}
        }
    }
}

//------------------------------------------------------------[ VEHICLE LOADER ]
I Have solved the issue by:
Changing the loader and saver a bit..
From:
Код:
//SAVING VEHICLES
forward SaveVehicle(fileid); 
public SaveVehicle(fileid)
{
    new vFile[128]; 
    format(vFile, sizeof(vFile),VEHICLE_FOLDER,fileid);
    new INI:File = INI_Open(vFile);
    INI_WriteInt(File,"vID",VehicleInfo[fileid][vID]);
    INI_WriteInt(File,"Model",VehicleInfo[fileid][vModel]);
    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,"Type",VehicleInfo[fileid][vType]);
	INI_WriteInt(File,"Owner",VehicleInfo[fileid][vOwner]);
	INI_Close(File);
    return 1;
}
//SAVING VEHICLES ^
//////////////////
//LOADING VEHICLES
forward LoadVehicle(fileid, name[], value[]); 
public LoadVehicle(fileid, name[], value[])
{
	INI_Int("vID",VehicleInfo[fileid][vID]);
    INI_Int("Model",VehicleInfo[fileid][vModel]);
    INI_Float("X",VehicleInfo[fileid][vX]);
    INI_Float("Y",VehicleInfo[fileid][vY]);
    INI_Float("Z",VehicleInfo[fileid][vZ]);
    INI_Float("A",VehicleInfo[fileid][vA]);
    INI_Int("Color1",VehicleInfo[fileid][vColor1]);
    INI_Int("Color2",VehicleInfo[fileid][vColor2]);
    INI_Int("Type",VehicleInfo[fileid][vType]);
    INI_Int("Owner",VehicleInfo[fileid][vOwner]);
    return 1;
}
//LOADING VEHICLES ^
to:
Код:
//SAVING VEHICLES
forward SaveVehicle(fileid); 
public SaveVehicle(fileid)
{
    new vFile[128];
    format(vFile, sizeof(vFile),VEHICLE_FOLDER,fileid);
    new INI:File = INI_Open(vFile);
    INI_WriteInt(File,"vID",VehicleInfo[fileid][vID]);
    INI_WriteInt(File,"vModel",VehicleInfo[fileid][vModel]);
    INI_WriteFloat(File,"vX",VehicleInfo[fileid][vX]);
    INI_WriteFloat(File,"vY",VehicleInfo[fileid][vY]);
    INI_WriteFloat(File,"vZ",VehicleInfo[fileid][vZ]);
    INI_WriteFloat(File,"vA",VehicleInfo[fileid][vA]);
    INI_WriteInt(File,"vColor1",VehicleInfo[fileid][vColor1]);
    INI_WriteInt(File,"vColor2",VehicleInfo[fileid][vColor2]);
	INI_WriteInt(File,"vType",VehicleInfo[fileid][vType]);
	INI_WriteInt(File,"vOwner",VehicleInfo[fileid][vOwner]);
	INI_Close(File);
    return 1;
}
//SAVING VEHICLES ^
//////////////////
//LOADING VEHICLES
forward LoadVehicle(fileid, name[], value[]); 
public LoadVehicle(fileid, name[], value[])
{
	INI_Int("vID",VehicleInfo[fileid][vID]);
    INI_Int("vModel",VehicleInfo[fileid][vModel]);
    INI_Float("vX",VehicleInfo[fileid][vX]);
    INI_Float("vY",VehicleInfo[fileid][vY]);
    INI_Float("vZ",VehicleInfo[fileid][vZ]);
    INI_Float("vA",VehicleInfo[fileid][vA]);
    INI_Int("vColor1",VehicleInfo[fileid][vColor1]);
    INI_Int("vColor2",VehicleInfo[fileid][vColor2]);
    INI_Int("vType",VehicleInfo[fileid][vType]);
    INI_Int("vOwner",VehicleInfo[fileid][vOwner]);
    return 1;
}
//LOADING VEHICLES ^
Reply
#2

Show us the "LoadVehicle" callback and also use printf to print values of X,Y,Z and A after they are loaded too see if they are being correctly loaded or not.
Reply
#3

Here's the loader!
Код:
//LOADING VEHICLES
forward LoadVehicle(fileid, name[], value[]); 
public LoadVehicle(fileid, name[], value[])
{
	INI_Int("vID",VehicleInfo[fileid][vID]);
    INI_Int("Model",VehicleInfo[fileid][vModel]);
    INI_Float("X",VehicleInfo[fileid][vX]);
    INI_Float("Y",VehicleInfo[fileid][vY]);
    INI_Float("Z",VehicleInfo[fileid][vZ]);
    INI_Float("A",VehicleInfo[fileid][vA]);
    INI_Int("Color1",VehicleInfo[fileid][vColor1]);
    INI_Int("Color2",VehicleInfo[fileid][vColor2]);
    INI_Int("Type",VehicleInfo[fileid][vType]);
    INI_Int("Owner",VehicleInfo[fileid][vOwner]);
    return 1;
}
//LOADING VEHICLES ^
It does look at the right file since its loading the vModel and vColor1 + vColor2, but it wont load the XYZA as spawn pos.
Thanks for the reply btw, I appreciate it!
Reply
#4

What does it loads in XYZA, zeros or any other values? if not zero then maybe there is mix-up while saving like by mistake x being saved as y and y as x?
Reply
#5

I have no time to check it at the moment and am not at home right now, but I will let you know asap within the next 24 hours!
EDIT: I have checked it, view the comment below.
Reply
#6

I checked the loading and indeed, somehow the X Y Z A stay at 0 but the rest is getting loaded perfectly.
I still dont get it because the INI file I have from the vehicle is saying the normal Coordinates where I have saved it. And it is saved as float. Any idea?

Console Debug line :
Код:
[13:35:16] DEBUGGING: LOADING VEHICLE ID 29 with MODEL:420, X:0, Y:0, Z:0, A:0, COL1:6, COL2:6
(It's veh ID 29 because I got 28 pre-scripted vehicles in there. But that shouldn't be causing the issue. I tried it without the pre-scripted vehicles)

INI File info:
Код:
Color2 = 6
Color1 = 6
A = 89.973571
Z = 24.520608
Y = 948.701721
X = -1755.607177
Model = 420
vID = 29
Reply
#7

Anybody with an idea what it could be, let me know!
Reply
#8

Bump
Reply
#9

Bump - I really need help on this one xd
Reply
#10

I dont want to bump again, however this sort of is but I have no idea where else to look for help. If anybody has any idea let me know. I still didnt figure out what this causes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)