Jump to content

handling car


Recommended Posts

 
I would like to know how to do it for the car, I already came with the handling I want for when I spawn, like a drift handling and just get the car in f1 and I already came with the handling without putting it on the panel again. If anyone can tell me how to do it I would appreciate it.
I would like to know how to do it for the car, I already came with the handling I want for when I spawn, like a drift handling and just get the car in f1 and I already came with the handling without putting it on the panel again. If anyone can tell me how to do it I would appreciate it.
I would like to know how to do it for the car, I already came with the handling I want for when I spawn, like a drift handling and just get the car in f1 and I already came with the handling without putting it on the panel again. If anyone can tell me how to do it I would appreciate it.
Link to comment
7 hours ago, JAY.ANN said:

If you are talking about the spawning vehicle with already modified handling then there you go: https://wiki.multitheftauto.com/wiki/SetVehicleHandling

(The last one server-side example, down of the page)

 


But I prefer to use a bit modified version of that code:
 

local modifiedHandling = {
	
	[412] = {
	--Engine
	["numberOfGears"] = 5,
	["maxVelocity"] = 320,
	["engineAcceleration"] = 12,
	["engineInertia"] = 240,
	["driveType"] = "awd",
	["steeringLock"] = 35,
	["collisionDamageMultiplier"] = 0.4,
	--Body
	["mass"] = 4000,
	["turnMass"] = 5800,
	["dragCoeff"] = 2,
	["centerOfMass"] = { [1]=0, [2]=0, [3]=-0.3 },
	["percentSubmerged"] = 75,
	["seatOffsetDistance"] = 0.25,
	--Wheels
	["tractionMultiplier"] = 0.7,
	["tractionLoss"] = 0.84,
	["tractionBias"] = 0.42,
	["brakeDeceleration"] = 6.2,
	["brakeBias"] = 0.4,
	["suspensionForceLevel"] = 1,
	["suspensionDamping"] = 0.05,
	["suspensionHighSpeedDamping"] = 0.5,
	["suspensionUpperLimit"] = 0.4,
	["suspensionLowerLimit"] = -0.3,
	["suspensionAntiDiveMultiplier"] = 0.05,
	["suspensionFrontRearBias"] = 0.5,
	--Vehicle Flags
	["modelFlags"] = 0x220000,
	["handlingFlags"] = 0x1000000,
	},
	
}

function setServerVehicleModifiedHandling( vehicle )
	if vehicle and modifiedHandling[ getElementModel( vehicle ) ] then -- Check if there is our vehicle and it has a modified handling
		for k, vl in pairs ( modifiedHandling[ getElementModel( vehicle ) ] ) do -- Create a loop through all our modified handlings
			if isElement( vehicle ) then -- Check if our vehicle exist 
			setVehicleHandling( vehicle, k, vl ) -- Set vehicle handling
			end
		end
	end
end

function getServerVehicleModifiedHandling( modelID ) -- Function to get our new handling from modifiedHandling table
local id = tonumber( modelID ) -- Set modelID tonumber to avoid some bugs
	if modelID then -- Check if there is a value of modelID
	local handlingTable = modifiedHandling[ modelID ] -- Set a local variable with our new handling of specific vehicle ID
		if handlingTable then -- Check if there is a variable
		return handlingTable -- Return modified handling from specific ID
		else
		return getOriginalHandling( modelID ) -- Return vehicle standart handling
		end
	end
end

local car = createVehicle( 412, 0, 0, 0 ) -- Create our test vehicle
local car_handling = getServerVehicleModifiedHandling( getElementModel( car ) ) -- Get vehicle handling in cause of we need to send that handling to somewhere else
setServerVehicleModifiedHandling( car ) -- Set vehicle modified handling

 

Edited by JAY.ANN
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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