Jump to content

[HELP] Changing Wheel Size


Recommended Posts



Hello dear friends, first of all, I am writing this text using translate. I apologize to everyone for my bad English. Forgive me if I put the issue in the wrong section. - I want to enlarge the wheels of the vehicles and make camber adjustments and I came across this content in the forum https://forum.multitheftauto.com/topic/92222-custom-wheel/ but the system in this content applies only to the front wheels and it goes underground when the wheel grows and how I will fix these errors from you I want your help, thank you very much in advance. :)



-- Table containing vehicles that have custom wheels
local createdCustomWheels = { }

--[[ /customwheels [ number tilt, number scale ]
	 Adds custom wheels to your currently occupied vehicle and optionally applies a tilt angle and wheel scale. ]]
addCommandHandler( 'customwheels',
	function( _, tilt, scale )
		-- Let's get our vehicle
		local vehicle = getPedOccupiedVehicle( localPlayer )

		-- Oh, we have a vehicle!
		if ( vehicle ) then
			-- Let's give it a wheel now
			addVehicleCustomWheel( vehicle, 1075, tilt, scale )

-- Let's bind that command to F2 as requested by OP
bindKey( 'f2', 'down', 'customwheels' )

--[[ void addVehicleCustomWheel ( vehicle vehicle, number model [ , number tilt, number scale ] )
	 Adds custom wheels to the vehicle. ]]
function addVehicleCustomWheel( vehicle, model, tilt, scale )
	-- If we've given the object's model number
	if ( tonumber( model ) ) then
		-- Let's delete any old ones
		for _, wheel in pairs( createdCustomWheels[ vehicle ] or { } ) do
			destroyElement( wheel.object )

		-- And let's nil it to be clear
		createdCustomWheels[ vehicle ] = nil

		-- Let's set some component names we want to customize
		local wheels = { 'wheel_lf_dummy', 'wheel_rf_dummy' }

		-- Let's iterate through those components
		for i = 1, #wheels do
			-- Let's hide the existing component
			setVehicleComponentVisible( vehicle, wheels[ i ], false )

			-- Initialize our wheel table
			local wheel = {
				tilt = tonumber( tilt ) or 0, -- We'll default a non-number tilt angle to 0
				name = wheels[ i ], -- Let's store the component name
				object = createObject( model, Vector3( ) ) -- Let's make a new wheel object

			-- Let's set the vehicle as the wheel object's parent
			setElementParent( wheel.object, vehicle )

			-- Let's make sure the wheel is not colliding with the vehicle
			setElementCollidableWith( wheel.object, vehicle, false )

			-- Let's change the scale
			setObjectScale( wheel.object, tonumber( scale ) or 0.7 )

			-- Let's update that original table
			wheels[ i ] = wheel

		-- And let's store all of those wheels now
		createdCustomWheels[ vehicle ] = wheels

--[[ void calculateVehicleWheelRotation ( vehicle vehicle, table wheel )
	 Let's calculate the wheel rotation for given wheel(s). ]]
function calculateVehicleWheelRotation( vehicle, wheel )
	-- If we have many wheels in the given argument
	if ( type( wheel ) == 'table' ) and ( #wheel > 0 ) then
		-- Let's iterate through them all
		for i = 1, #wheel do
			-- Let's call the method alone with just the iterator
			calculateVehicleWheelRotation( vehicle, wheel[ i ] )

		-- Let's stop here now

	-- If we have an object
	if ( wheel.object ) then
		-- Let's get the rotation vector of the original component
		local rotation = Vector3( getVehicleComponentRotation( vehicle, wheel.name, 'world' ) )

		-- Let's set our tilt angle
		rotation.y = wheel.tilt

		-- Let's make sure the wheel is at the original component's position
		setElementPosition( wheel.object, Vector3( getVehicleComponentPosition( vehicle, wheel.name, 'world' ) ) )

		-- Let's finally set the rotation (in ZYX order, important!)
		setElementRotation( wheel.object, rotation, "ZYX" )

-- Render-time!
addEventHandler( 'onClientPreRender', root,
	function( )
		-- Let's iterate through all the vehicles
		for vehicle, wheels in pairs( createdCustomWheels ) do
			-- If we have a vehicle, it's streamed in and it has wheels
			if ( vehicle ) and ( isElementStreamedIn( vehicle ) ) and ( #wheels > 0 ) then
				-- Let's calculate wheel rotation!
				calculateVehicleWheelRotation( vehicle, wheels )



Link to comment
  • 2 years later...
  • Tut locked this topic
  • Administrators

Locking this thread as it's starting to age and hasn't seen any activity for a few years.

OP - please see user331323's post on how to set physical/visible wheel sizes, this is a relative new function introduced after your post. If this is still an issue feel free to create a new thread!

  • Like 1
Link to comment
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...