sa-mp-fixes
sa-mp-fixes copied to clipboard
GetVehicleComponentInSlot
I updated the wiki page for this function, after testing it again. I hope I didn't miss anything.
To fix these things:
- an array is needed, to store every component per-vehicle per-slot.
- another array is needed, to store every component's type
- a hook for AddVehicleComponent and OnVehicleMod is needed, to save the components (also resetting under OnVehicleSpawn, AddStaticVehicle(Ex), CreateVehicle, etc.).
- it needs different slots ! so this fix should probably be defaulted to false.
If the fix is enabled, the existing slot IDs should be undefined and then use these ones:
enum
{
CARMODTYPE_SPOILER,
CARMODTYPE_HOOD,
CARMODTYPE_ROOF,
CARMODTYPE_SIDESKIRT_LEFT, // removed CARMODETYPE_SIDESKIRT and added
CARMODTYPE_SIDESKIRT_RIGHT, // these two
CARMODTYPE_LAMPS,
CARMODTYPE_NITRO,
CARMODTYPE_EXHAUST,
CARMODTYPE_WHEELS,
CARMODTYPE_STEREO,
CARMODTYPE_HYDRAULICS,
CARMODTYPE_FRONT_BUMPER,
CARMODTYPE_REAR_BUMPER,
CARMODTYPE_FRONT_BULLBAR, // new
CARMODTYPE_REAR_BULLBAR, // new
CARMODTYPE_VENT_RIGHT,
CARMODTYPE_VENT_LEFT,
};
Also, GetVehicleComponentType should return these new IDs too.
This wiki page could also help.
These bugs annoyed me when I made a tune system based on dialogs that show only the valid components per-slot (also showing which one is installed). Doing a similar tuning system would be a lot less frustrating without these problems.
As I remember, CARMODTYPE_SIDESKIRT and CARMODTYPE_VENT_RIGHT visually works only with double calling of AddVehicleComponent (I was fix this in my own similar tuning system). So, I think what sideskirt and vent parts should be without left and right parts because this not working at all. Also I does not want to do this because this will broke my vehice components include. But if someone wants this - send the pull request.
I'll say I also won't do this, since I don't have SA installed and know very little about the vehicle modding system compared to other people. However, I'm not sure why having to call it twice for some slots is an unfixable bug when you already explained the solution. Maybe I'm missing something (I did say I wasn't an expert).
As for the array storing component types, just call GetVehicleComponentType
and adjust for the few components changed, no need to recreate all the information. Also hook that function to return the slightly modified ones. In fact, just hook it first and call that one as well from inside fixes.inc to get the new correct slots.
So that's why side skirts looked a bit bugged for me, I didn't know what was actually happening !
I tested side skirts and vents again more careful and it looks like when I add only a side skirt/vent, the other side skirt/vent from the other side is automatically added too. But for me they are added successfully without a second AddVehicleComponent call.
I also tested tuning Bravura at "Transfeder" and side skirts and vents are being added for both sides, without a left/right additional option. This is probably a problem from GTA:SA itself. Maybe the fix should remove the two left/right vents and add only a vent type, if it isn't possible to fix this by calling RemoveVehicleComponent for the other side component ID you didn't want and just eventually add the old stored component from the side skirt/vents part after that. The bullbar separate type storing should still be added.
As I said before, this should be disabled by default, so it won't break scripts.
Fixing this would help a lot when creating tuning systems, as it looks like these functions are bugged pretty much.
But for me they are added successfully without a second AddVehicleComponent call.
Yes, this happens not always. Maybe just for first modding actions.
Is that confirmed for only those components, or even if not is there a reason not to duplicate all the applications to reduce code complexity? Or could it have something to do with streaming? To me it makes sense that skirts would be in pairs - why would you ever want just one side to have a skirt, and what is the point in programming that I the original game?