WHat is wrong in this code?
#1

Okey, this is my vehicle initation process...

Код:
stock InitVehicles()
{
print("Initiating vehicle initiation process");
	new Vehicle[16];
	for(new i = 0; i < 500; i++)
	{
	
	    format(Vehicle, sizeof(Vehicle), "V_%d", i);
	    if(djIsSet(VEHICLES_FILE, Vehicle) )
	    {
	    
	        format(Vehicle, sizeof(Vehicle), "V_%d/PosX", i);
	        Vehicles[i][CarPosX] = djFloat(VEHICLES_FILE, Vehicle, true);
	        
	        format(Vehicle, sizeof(Vehicle), "V_%d/PosY", i);
	        Vehicles[i][CarPosY] = djFloat(VEHICLES_FILE, Vehicle, true);
	        
	        format(Vehicle, sizeof(Vehicle), "V_%d/PosZ", i);
	        Vehicles[i][CarPosZ] = djFloat(VEHICLES_FILE, Vehicle, true);
	        
	        format(Vehicle, sizeof(Vehicle), "V_%d/ZAngle", i);
	        Vehicles[i][CarZAngle] = djFloat(VEHICLES_FILE, Vehicle, true);
	        
	        format(Vehicle, sizeof(Vehicle), "V_%d/Model", i);
	        Vehicles[i][CarModel] = djInt(VEHICLES_FILE, Vehicle, true);
	        
	        format(Vehicle, sizeof(Vehicle), "V_%d/Owner", i);
	        Vehicles[i][Owner] = djInt(VEHICLES_FILE, Vehicle, true);
	        
	        format(Vehicle, sizeof(Vehicle), "V_%d/Plate", i);
	        Vehicles[i][Plate] = djInt(VEHICLES_FILE, Vehicle, true);
	        
	        format(Vehicle, sizeof(Vehicle), "V_%d/Col1", i);
	        Vehicles[i][CarColour1] = djInt(VEHICLES_FILE, Vehicle, true);
	        
	        format(Vehicle, sizeof(Vehicle), "V_%d/Col2", i);
	        Vehicles[i][CarColour2] = djInt(VEHICLES_FILE, Vehicle, true);
	        
	        format(Vehicle, sizeof(Vehicle), "V_%d/Group", i);
	        Vehicles[i][CarGroup] = djInt(VEHICLES_FILE, Vehicle, true);
	        
	        format(Vehicle, sizeof(Vehicle), "V_%d/Locked", i);
	        Vehicles[i][Locked] = djInt(VEHICLES_FILE, Vehicle, true);
	        
	        format(Vehicle, sizeof(Vehicle), "V_%d/Alarm", i);
	        Vehicles[i][Alarm] = djInt(VEHICLES_FILE, Vehicle, true);
	        
	        CarCount++;
	        
            if(Vehicles[i][CarModel] != 537 && Vehicles[i][CarModel] != 538 && Vehicles[i][CarModel] != 569 && 570 && Vehicles[i][CarModel] != 590 )
            {
            	Vehicles[i][GameID] = AddStaticVehicleEx(Vehicles[i][CarModel], Vehicles[i][CarPosX], Vehicles[i][CarPosY], Vehicles[i][CarPosZ], Vehicles[i][CarZAngle], Vehicles[i][CarColour1], Vehicles[i][CarColour2], 3600 );
            	SetVehicleNumberPlate(i, Vehicles[i][Plate]);
            	new engine,lights,alarm,doors,bonnet,boot,objective;
                GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(i,engine,lights,Vehicles[i][Alarm],Vehicles[i][Locked],bonnet,boot,objective);
            }
            
            printf( "[system] InitVehicles(): Vehicle %d has spawned (spawned from %s).", i, VEHICLES_FILE);
     }
 }
}
It doesn't give any errors or warnings, but it seems that if(djIsSet(VEHICLES_FILE, Vehicle) ) is blocking it... My problem is that the cars don't spawn. I've checked my file, and I'm sure they are all set. Here is something out of my file for you to see
Код:
"V_1":{"Col1":-1,"Col2":-1,"Group":1,"Model":596,"Plate":LSGV-DMV,"Locked":0,"Alarm":0,"Owner":0,"PosX":1545.589233,"PosY":-1680.213623,"PosZ":5.612060,"ZAngle":91.456855}
So what is wrong here? Is it a bug maybe?
Reply
#2

Debug everything.
Reply
#3

I guess everything, what's that supposed to do?
Reply
#4

It's supposed to load the vehicles from the Vehicles.json file and add them to the server.

It's 0.3c so it's supposed to fix doors and car alarm of the vehicle, and plates too.
Reply
#5

Sorry for double post, but I can't figure what's wrong here. I don't think the error is in this code, but yeah.
Reply
#6

Vehicles[i][CarPosX], show us those enum.
be sure that. fx:
pawn Код:
enum VehicleInfo
{
Float:CarPosX,
}
ALSO there is a edit button for something,
double post again and i WONT help you.
And "What is wrong with this title?",
please put a descriptive title next time.

Hope i helped.
Reply
#7

[QUOTE=Kyle_Olsen;946302]Okey, this is my vehicle initation process...

pawn Код:
stock InitVehicles()
{
print("Initiating vehicle initiation process");
    new Vehicle[16];
    for(new i = 0; i < 500; i++)
    {
   
        format(Vehicle, sizeof(Vehicle), "V_%d", i);
        if(djIsSet(VEHICLES_FILE, Vehicle) )
        {
       
            format(Vehicle, sizeof(Vehicle), "V_%d/PosX", i);
            Vehicles[i][CarPosX] = djFloat(VEHICLES_FILE, Vehicle, true);
           
            format(Vehicle, sizeof(Vehicle), "V_%d/PosY", i);
            Vehicles[i][CarPosY] = djFloat(VEHICLES_FILE, Vehicle, true);
           
            format(Vehicle, sizeof(Vehicle), "V_%d/PosZ", i);
            Vehicles[i][CarPosZ] = djFloat(VEHICLES_FILE, Vehicle, true);
           
            format(Vehicle, sizeof(Vehicle), "V_%d/ZAngle", i);
            Vehicles[i][CarZAngle] = djFloat(VEHICLES_FILE, Vehicle, true);
           
            format(Vehicle, sizeof(Vehicle), "V_%d/Model", i);
            Vehicles[i][CarModel] = djInt(VEHICLES_FILE, Vehicle, true);
           
            format(Vehicle, sizeof(Vehicle), "V_%d/Owner", i);
            Vehicles[i][Owner] = djInt(VEHICLES_FILE, Vehicle, true);
           
            format(Vehicle, sizeof(Vehicle), "V_%d/Plate", i);
            Vehicles[i][Plate] = djInt(VEHICLES_FILE, Vehicle, true);
           
            format(Vehicle, sizeof(Vehicle), "V_%d/Col1", i);
            Vehicles[i][CarColour1] = djInt(VEHICLES_FILE, Vehicle, true);
           
            format(Vehicle, sizeof(Vehicle), "V_%d/Col2", i);
            Vehicles[i][CarColour2] = djInt(VEHICLES_FILE, Vehicle, true);
           
            format(Vehicle, sizeof(Vehicle), "V_%d/Group", i);
            Vehicles[i][CarGroup] = djInt(VEHICLES_FILE, Vehicle, true);
           
            format(Vehicle, sizeof(Vehicle), "V_%d/Locked", i);
            Vehicles[i][Locked] = djInt(VEHICLES_FILE, Vehicle, true);
           
            format(Vehicle, sizeof(Vehicle), "V_%d/Alarm", i);
            Vehicles[i][Alarm] = djInt(VEHICLES_FILE, Vehicle, true);
           
            CarCount++;
           
            if(Vehicles[i][CarModel] != 537 && Vehicles[i][CarModel] != 538 && Vehicles[i][CarModel] != 569 && 570 && Vehicles[i][CarModel] != 590 )
            {
                Vehicles[i][GameID] = AddStaticVehicleEx(Vehicles[i][CarModel], Vehicles[i][CarPosX], Vehicles[i][CarPosY], Vehicles[i][CarPosZ], Vehicles[i][CarZAngle], Vehicles[i][CarColour1], Vehicles[i][CarColour2], 3600 );
                SetVehicleNumberPlate(i, Vehicles[i][Plate]);
                new engine,lights,alarm,doors,bonnet,boot,objective;
                GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(i,engine,lights,Vehicles[i][Alarm],Vehicles[i][Locked],bonnet,boot,objective);
            }
           
            printf( "[system] InitVehicles(): Vehicle %d has spawned (spawned from %s).", i, VEHICLES_FILE);
     }
     else
     {
          print("Cars Not Found!")
     }
 }
}
the indentation got messed up so tidy it up before you use it.


See what i added at the bottom of the script, if it prints that in the console, then you know its djIsSet

Why did you remove the MAX_VEHICLES define? just use it for simplicity.


PS: djInt is for integers. You should change that.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)