SA-MP Forums Archive
GetVehicleComponentInSlot bug with bullbars and bumpers - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP (https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: GetVehicleComponentInSlot bug with bullbars and bumpers (/showthread.php?tid=418964)



GetVehicleComponentInSlot bug with bullbars and bumpers - Basssiiie - 26.02.2013

Hi all,

The bug is that front bullbars and front bumpers have the same slot: CARMODTYPE_FRONT_BUMPER. The same goes for rear bullbars and rear bumpers: CARMODTYPE_REAR_BUMPER. This can bug in GetVehicleComponentInSlot, as you can have both bullbar and bumper components installed at the same time, but the function will only return the last installed one. Detecting if the other one is installed, is impossible.

A small showcase to reproduce this bug:
If you do this, while "vehid" refers to a vehicle with a Slamvan model:
pawn Код:
AddVehicleComponent(vehid, 1117); // Installs Chrome Bumper for Slamvan.
AddVehicleComponent(vehid, 1115); // Installs Chrome Bullbars for Slamvan.
Both items will be visible on the Slamvan.

But now, if you do this a while later:
pawn Код:
new compid = GetVehicleComponentInSlot(vehid, CARMODTYPE_FRONT_BUMPER);
printf("Front bumper component ID: %i", compid);
This will print "Front bumper component ID: 1115", which are the Bullbars.

Now if you this, instead of the above code:
pawn Код:
AddVehicleComponent(vehid, 1115); // Installs Chrome Bullbars for Slamvan
AddVehicleComponent(vehid, 1117); // Installs Chrome Bumper for Slamvan

new compid = GetVehicleComponentInSlot(vehid, CARMODTYPE_FRONT_BUMPER);
printf("Front bumper component ID: %i", compid);
Both will be visible, but now "Front bumper component ID: 1117" will now be printed in the console, which is the Bumper.

It will only remember the last installed one. This while both items are still on the vehicle, "using" the same slot. The same happens for rear bullbars and rear bumpers: you can have two items installed at the same time, but they still "use" the same slot.

If I may suggest a solution: add two extra slots to GetVehicleComponentInSlot. One for the front bullbars and one for the rear bullbars. Save the front bullbars in their "front bullbar" slot, instead of saving them in the CARMODTYPE_FRONT_BUMPER slot. Same goes for the rear bullbars: save them in a "rear bullbar" slot, instead of CARMODTYPE_REAR_BUMPER.

Would be awesome if this could be fixed.
Thanks in advance!

Regards,
Basssiiie


Re: GetVehicleComponentInSlot bug with bullbars and bumpers - beckzy - 26.02.2013

I've always wondered what caused this! Nice find!


Re: GetVehicleComponentInSlot bug with bullbars and bumpers - MP2 - 27.02.2013

Can't you make a fix for this using OnVehicleMod?


Re: GetVehicleComponentInSlot bug with bullbars and bumpers - Basssiiie - 27.02.2013

To my knowledge OnVehicleMod isn't called when you use AddVehicleComponent. It's only called when you mod inside a modshop (or via hacks).


Re: GetVehicleComponentInSlot bug with bullbars and bumpers - MP2 - 27.02.2013

Hooks.


Re: GetVehicleComponentInSlot bug with bullbars and bumpers - Basssiiie - 27.02.2013

Of course I can hook stuff. But if I'm making a filterscript that should work on every server, I can't check if people have other AddVehicleComponent/GetVehicleComponentType/GetVehicleComponentInSlot/RemoveVehicleComponent-functions in other scripts too. Some people might not even know if their own server uses it. I can't just ask "yeah, also include this file in every script you've got". I'm just reporting the bugs here. Maybe Kalcor or one of the Beta Testers will write this down in some notes or something, so they can look at it for the next update.


Re: GetVehicleComponentInSlot bug with bullbars and bumpers - leong124 - 28.02.2013

I can confirm this. I think a separate slot for either bullbar or bumper is needed. It needs a large array (2000 x 14 = 28000 cells for all vehicles) to store every components if it's suggested to be fixed by script again.