mtasa-blue
mtasa-blue copied to clipboard
getVehicleWheelFrictionState not working on bikes
Describe the bug
getVehicleWheelFrictionState throws ERROR: script/file.lua:line Invalid vehicle type when used in non "Automobile" vehicle types, this function is very useful to detect vehicle behavior and should work in all vehicle types, ~~or return false instead~~
Steps to reproduce
-
enable
debugscript 3 -
run:
addEventHandler("onClientRender", root, function ()
local veh = getPedOccupiedVehicle (localPlayer)
if not veh then
return false
end
dxDrawRectangle (0, 0, 300, 140, tocolor (0, 0, 0, 150))
dxDrawText ("FRICTION FRONT LEFT = ".. getVehicleWheelFrictionState (veh, 0), 8, 10, 290, 40, tocolor (255, 255, 255), 1.5)
dxDrawText ("FRICTION FRONT RIGHT = ".. getVehicleWheelFrictionState (veh, 2), 8, 40, 290, 70, tocolor (255, 255, 255), 1.5)
dxDrawText ("FRICTION REAR LEFT = ".. getVehicleWheelFrictionState (veh, 1), 8, 70, 290, 100, tocolor (255, 255, 255), 1.5)
dxDrawText ("FRICTION REAR RIGHT = ".. getVehicleWheelFrictionState (veh, 3), 8, 100, 290, 130, tocolor (255, 255, 255), 1.5)
end)
- enter a bike
- see errors
Version
Client: v1.6-release-22894 (Windows 10, 64-bit) Server: v1.6-release-22649 (Linux, 64-bit)
Additional context
No response
Relevant log output
Security Policy
- [x] I have read and understood the Security Policy and this issue is not security related.
this should fix it ? didn't test
int CLuaVehicleDefs::GetVehicleWheelFrictionState(CClientVehicle* pVehicle, unsigned char wheel)
{
if (wheel < 0 || wheel > 3)
throw std::invalid_argument("Invalid wheel number");
const auto type = CClientVehicleManager::GetVehicleType(pVehicle->GetModel());
if (type != CLIENTVEHICLE_CAR &&
type != CLIENTVEHICLE_BIKE &&
type != CLIENTVEHICLE_QUADBIKE &&
type != CLIENTVEHICLE_MONSTERTRUCK)
throw std::invalid_argument("Invalid vehicle type");
return pVehicle->GetWheelFrictionState(wheel);
}
this should fix it ? didn't test
It's a bit complicated, but figured out and works.