31.01.2017, 13:31
Hello, I'm trying to add car modifications. I have made these basic system to test it after to implement in the gamemode (MySQL based).
Debug:
Problem: Only loads the first five.
I know AddVehicleComponent 0 will crash, but I have an if statement to check this:
But then, when I respawn the vehicle, all components gets added, I've added in the OnVehicSpawn function the same process when CreateVehicleTest();
Anyone can help me?
Код:
// ModTest will be the string in MySQL stored and VehicleToImplement will be the MODEL to show the components. new ModTest[100] = "1000,1004,1006,1007,1013,0,1018,1078,0,1087,0,0,0,1143"; new VehicleToImplement = 496; // This is called from OnGameModeInit because I create the cars from MySQL. 'idx' is the id of the car in MySQL. CreateVehicleTest(idx) { Car[idx][VehicleID] = CreateVehicle(Car[idx][Model], Car[idx][pX], Car[idx][pY], Car[idx][pZ], Car[idx][pA], Car[idx][Color1], Car[idx][Color2], -1); SetVehicleNumberPlate(Car[idx][VehicleID], VehiclePlate(idx)); SetVehicleHealth(Car[idx][VehicleID], Car[idx][Health]); UpdateVehicleDamageStatus(Vehicle[idx][VehicleID], 0, 0, 0, 0); if(Car[idx][Model] == VehicleToImplement) { printf("SQL: %i", Car[idx][ID]); new a[14]; sscanf(ModTest, "p<,>a<i>[14]", a); for (new s; s < 14; ++s) { if (a[s] > 0) { AddVehicleComponent(Car[idx][VehicleID], a[s]); printf("Component: %i", a[s]); } } printf("-------------- END"); } }
Код:
[14:03:54] SQL: 69 [14:03:54] Component: 1000 [14:03:54] Component: 1004 [14:03:54] Component: 1006 [14:03:54] Component: 1007 [14:03:54] Component: 1013 [14:03:54] Component: 1018 [14:03:54] Component: 1078 [14:03:54] Component: 1087 [14:03:54] Component: 1143 [14:03:54] -------------- END
Код:
1000, -> Loads 1004, -> Loads 1006, -> Loads 1007, -> Loads 1013, -> Loads 0, -> Stops and is not applying the rest of components 1018, 1078, 0, 1087, 0, 0, 0, 1143
Код:
if (a[s] > 0) // <- Here, if component is > 0 will apply the component ant get printed. { AddVehicleComponent(Car[idx][VehicleID], a[s]); printf("Component: %i", a[s]); }
Anyone can help me?