SA-MP Forums Archive
[HELP]Vehicle damage status not saving correctly - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP]Vehicle damage status not saving correctly (/showthread.php?tid=564404)



[HELP]Vehicle damage status not saving correctly - WingedFrostWolf - 21.02.2015

Hello, I've been trying to create a system that saves the visible damage of a vehicle.

Here's the pastebin for the saving: http://pastebin.com/0y3Gngr6

When I log in-game and wreck a vehicle, and then save it using the script, it only saves the panels portion of it. Is that normal behavior?
When I then look into the file it's supposed to save in I see:

Panels=35717121
Doors=0
Lights=0
Tires=0 (I didn't pop the tires, so I don't expect it to be different from 0)

How do I save the doors, lights and tires? Any help would be greatly appreciated, thanks for reading!


Re: [HELP]Vehicle damage status not saving correctly - DarK_FeneR - 19.03.2015

In "Tires="
If value is 5 (0101 bit numbers) (remember 0=non damaged and 1= damaged):
front left tire (0) isn't damaged
Front right tire (1) is damaged
Rear left tire (0) isn't damaged
Rear right tire (1) is damaged

I think the saving function based on this for all vehicle damage status...

But in different way


Re: [HELP]Vehicle damage status not saving correctly - PowerPC603 - 20.03.2015

Why do you create an array which can hold all vehicle's (2000 of them) while you only save 1 vehicle?

pawn Код:
new VehiclePanels, VehicleDoors, VehicleLights, VehicleTires;

GetVehicleDamageStatus(vehicleid, VehiclePanels, VehicleDoors, VehicleLights, VehicleTires);

printf("Saving vehicle-id: %i", vehicleid);
printf("Panels: %i, Doors: %i, Lights: %i, Tires: %i", VehiclePanels, VehicleDoors, VehicleLights, VehicleTires);

format(line, sizeof(line), "Panels=%d\r\n", VehiclePanels); fwrite(handle, line);
format(line, sizeof(line), "Doors=%d\r\n", VehicleDoors); fwrite(handle, line);
format(line, sizeof(line), "Lights=%d\r\n", VehicleLights); fwrite(handle, line);
format(line, sizeof(line), "Tires=%d\r\n", VehicleTires); fwrite(handle, line);
This would do.

The printf statements I added could be used to debug your variables so that you can check if they are filled with proper data before saving.

Other than this, I see no reason why only the panels are saved.