Skip to content

Conversation

@Xenius97
Copy link
Contributor

@Xenius97 Xenius97 commented Nov 12, 2025

Closes #3955

This PR fixes an issue where getVehicleWheelFrictionState throws an "Invalid vehicle type" error when used on non-"Automobile" vehicles such as bikes, monster trucks, and quads.

Previously, this function was only usable on cars, which limited its usefulness for detecting vehicle behavior. With this change, the function now supports bikes, bicycles, quad and monster truck

Nevtelen.video.A.Clipchamppel.keszult.mp4

Test code:

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))
	if getVehicleType(veh) == "Bike" or getVehicleType (veh) == "BMX" then
		dxDrawText("FRICTION FRONT = ".. getVehicleWheelFrictionState (veh, 0), 8, 10, 290, 40, tocolor (255, 255, 255), 1.5)
		dxDrawText("FRICTION REAR = ".. getVehicleWheelFrictionState (veh, 1), 8, 40, 290, 70, tocolor (255, 255, 255), 1.5)
	else
		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
end)

Comment on lines +1478 to +1480
auto* bikeInterface = static_cast<CBikeSAInterface*>(GetVehicleInterface());
if (!bikeInterface)
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make any sense. If this was null, you it would've crashed at the switch already.
Also, return false makes even less sense, as it's just implicitly converted to 0.

case CLIENTVEHICLE_MONSTERTRUCK:
case CLIENTVEHICLE_QUADBIKE:
{
if (wheel < 0 || wheel > 3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have some enum for this? Using magic values isn't ideal.

case CLIENTVEHICLE_BIKE:
case CLIENTVEHICLE_BMX:
{
if (wheel < 0 || wheel > 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have some enum for this? Using magic values isn't ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getVehicleWheelFrictionState not working on bikes

2 participants