bug(es_extended): wrong wheel indexes
https://github.com/esx-framework/esx_core/blob/c80916c3e3b14e3cfce6102801b382e59c49bd27/%5Bcore%5D/es_extended/client/functions.lua#L581-L585
Here we can see that we check for wheel_count
local wheel_count = GetVehicleNumberOfWheels(vehicle);
Which could be okay if in GTA vehicles would have wheels consistently from 0 to 3 which is not true in this game, example:
Adder, has 4 wheels and GetVehicleNumberOfWheels will return 4, however IsVehicleTyreBurst will fail on rear wheels.
Adder wheels by IsVehicleTyreBurst
0 FL (front left)
1 FR (front right)
2 none (by documentation 2 = wheel_lm / in 6 wheels trailer, plane or jet is first one on left)
3 none (by documentation 3 = wheel_rm / in 6 wheels trailer, plane or jet is first one on right)
4 RL
5 RR
6 again FL
7 again RL
Now this tells us that no matter what 2 and 3 will always be intact.
Example with 1 wheel burst (front left):
Example with all wheels burst:
So our current function will always fail.
To test this theory I wrote this simple script
RegisterCommand('wh', function(_, args)
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
for i = 0, 7 do
local isBurst = IsVehicleTyreBurst(vehicle, i, false)
print('wheel: '..i, isBurst and 'burst' or 'intact')
end
local wheel = tonumber(args[1])
if wheel then
SetVehicleTyreBurst(vehicle, wheel, true, 1)
end
end, false)
Also we can see more info about native and wheels here https://docs.fivem.net/natives/?_0xEC6A202EE4960385
"To burst tyres VEHICLE::SET_VEHICLE_TYRE_BURST(vehicle, 0, true, 1000.0)
to burst all tyres type it 8 times where p1 = 0 to 7.
p3 seems to be how much damage it has taken. 0 doesn't deflate them, 1000 completely deflates them.
'0 = wheel_lf / bike, plane or jet front
'1 = wheel_rf
'2 = wheel_lm / in 6 wheels trailer, plane or jet is first one on left
'3 = wheel_rm / in 6 wheels trailer, plane or jet is first one on right
'4 = wheel_lr / bike rear / in 6 wheels trailer, plane or jet is last one on left
'5 = wheel_rr / in 6 wheels trailer, plane or jet is last one on right
'45 = 6 wheels trailer mid wheel left
'47 = 6 wheels trailer mid wheel right
So in conclusion easiest way is probably to run for wheel = 0, 7 do and it will return all wheels intact or burst, because native will return that wheel as intact if that vehicle don't have that specific wheel.
However again
We have a feature which breaks off the wheel off the vehicle, which will also return the wheel as intact by IsVehicleTyreBurst.
Example, the wheel is off, but returns as fine:
To test that I wrote this simple script:
RegisterCommand('br', function(_, args)
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local wheel = tonumber(args[1])
BreakOffVehicleWheel(vehicle, wheel, true, false, true, false)
end, false)
Breaking wheels off working as expect from 0 to 3, as how we would wish for IsVehicleTyreBurst too.
I haven't found a way to check this, so far tried GetVehicleWheelHealth, GetVehicleWheelXOffset and GetVehicleWheelYRotation, doesn't seem to have any effect is the wheel is on or off.
@iSentrie Hi! This method @itsmaty refactored. Do you know about this or has it happened to you? by the way thanks for this research @iSentrie.
We can see that old version had in mind all these things (except when wheels falls off) and properly indexes the wheels.
local numWheels = tostring(GetVehicleNumberOfWheels(vehicle))
local TyresIndex = { -- Wheel index list according to the number of vehicle wheels.
["2"] = { 0, 4 }, -- Bike and cycle.
["3"] = { 0, 1, 4, 5 }, -- Vehicle with 3 wheels (get for wheels because some 3 wheels vehicles have 2 wheels on front and one rear or the reverse).
["4"] = { 0, 1, 4, 5 }, -- Vehicle with 4 wheels.
["6"] = { 0, 1, 2, 3, 4, 5 }, -- Vehicle with 6 wheels.
}
if TyresIndex[numWheels] then
for _, idx in pairs(TyresIndex[numWheels]) do
tyreBurst[tostring(idx)] = IsVehicleTyreBurst(vehicle, idx, false)
end
end
This should be reverted https://github.com/esx-framework/esx_core/commit/a5157bd8d4e08e129d6370089218311522198cff
Hi! @iSentrie Yes, we will revert thanks for help.
fyi. wheel related natives doesn't work properly if the wheel has been deleted with the break wheel native. With recent artifacts update it will even print in F8 that the native is of no use.
And as @iSentrie pointed out, it should 100% be reverted. And u should add compatibility for 8 wheelers as well. They seem to use the same tyreIndex array as 6 wheelers but it needs to be there as the numWheels variable returns 8.
Researched more in to 8 wheelers, I never thought about these.
Missing indexes for 8 wheelers are:
412 and 416
EDIT: it might change per gamebuild
EDIT: regarding indexes per game build:
2802 547 / 549
2944 412 / 416
3095 788 / 792
@iSentrie @t1ger-scripts Hi! Thanks for research guys, we will revert last commit(https://github.com/esx-framework/esx_core/commit/a5157bd8d4e08e129d6370089218311522198cff).
Reverted 166907d The change will be available in the next release.
Hey, thanks for noticing and pointing out my mistake. I'm embarrassed and want to apologize, I should have looked closer at the code and what I was changing. I already wondered how somebody imagined this "fucked up logic" for a seemingly so simple task, well it was because the logic wasn´t fucked up.