Jump to content

Handling for RP?


lockdw

Recommended Posts

Hey, you guys have some handling for police cars that is not too ridiculous? I have a RP server and i want all the police cars to be faster then the default, but not too much.

In case yes how could i modify this on the resources? Someone can help me ?

 

note: idk if this is the right forum.

Edited by lockdw
Link to comment
  • Administrators

There's handling documentation here: http://projectcerbera.com/gta/sa/tutorials/handling

To get started with handlings you can use hedit (or create your own script; of which i cannot help you with): https://community.multitheftauto.com/index.php?p=resources&s=details&id=3716

Wiki: https://wiki.multitheftauto.com/wiki/SetVehicleHandling

I'll be able to answer questions specific to vehicle handling, but not able to help coding it. Also I've moved your thread to Scripting section.

Link to comment
9 hours ago, lockdw said:

In case yes how could i modify this on the resources? Someone can help me ?

Hello lockdw,

you have to use the setVehicleHandling function. On the wiki page there is an excellent example on how to do so:

local predefinedHandling = {
	[411] = {
		["engineAcceleration"] = 14,
		["dragCoeff"] = 0,
		["maxVelocity"] = 100000,
		["tractionMultiplier"] = 0.9,
		["tractionLoss"] = 1.1,
	},
	[415] = {
		["engineAcceleration"] = 14,
		["dragCoeff"] = 0,
		["maxVelocity"] = 100000,
		["tractionMultiplier"] = 0.9,
		["tractionLoss"] = 1.1,
	},
		[562] = { -- Universal drift handling
		["driveType"] = "rwd",
		["engineAcceleration"] = 200,
		["dragCoeff"] = 1.5,
		["maxVelocity"] = 300,
		["tractionMultiplier"] = 0.7,
		["tractionLoss"] = 0.8,
		["collisionDamageMultiplier"] = 0.4,
		["engineInertia"] = -175,
		["steeringLock"] = 75,
		["numberOfGears"] = 4,
		["suspensionForceLevel"] = 0.8,
		["suspensionDamping"] = 0.8,
		["suspensionUpperLimit"] = 0.33,
		["suspensionFrontRearBias"] = 0.3,
		["mass"] = 1800,
		["turnMass"] = 3000,
		["centerOfMass"] = { [1]=0, [2]=-0.2, [3]=-0.5 }, -- Good example to understand centerOfMass parameter usage
	},

	--next model below etc (copy rows)
}

for i,v in pairs (predefinedHandling) do
	if i then
		for handling, value in pairs (v) do
			if not setModelHandling (i, handling, value) then
				outputDebugString ("* Predefined handling '"..tostring(handling).."' for vehicle model '"..tostring(i).."' could not be set to '"..tostring(value).."'")
			end
		end
	end
end

for _,v in ipairs (getElementsByType("vehicle")) do
	if v and predefinedHandling[getElementModel(v)] then
		for k,vl in pairs (predefinedHandling[getElementModel(v)]) do
			setVehicleHandling (v, k, vl)
		end
	end
end

function resetHandling()
	for model in pairs (predefinedHandling) do
		if model then
			for k in pairs(getOriginalHandling(model)) do
				setModelHandling(model, k, nil)
			end
		end
	end

	for _,v in ipairs (getElementsByType("vehicle")) do
		if v then
			local model = getElementModel(v)
			if predefinedHandling[model] then
				for k,h in pairs(getOriginalHandling(model)) do
					setVehicleHandling(v, k, h)
				end
			end
		end
	end
end
addEventHandler("onResourceStop", resourceRoot, resetHandling)

I recommend that you first play around with the hedit resource and then just copy the values over to your script. ;) 

Edited by The_GTA
Link to comment
  • MTA Anti-Cheat Team

It's usually error and trial, you could ask someone with experience creating handlings to help you as they should know how to tweak even the default GTA handlings to be more realistic, let alone allow a speed boost in acceptable ways (e.g let the vehicle climb to a higher top speed, so no acceleration overkill). I'd call it a performance boost rather than speed boost, and I've seen plenty of roleplay servers that managed to provide an entirely different vehicle experience in terms of handling and road behavior..

I advise you to focus on road behavior rather than top speed if you want to create realistic handlings. But like i said, you would need a good understanding of the effects of each handling parameter and flag, and how they interact with eachother (since GTA does weird things).

If you can't find anyone for that, or you have no time to learn it, then maybe one of these "Realistic handling packs" is a good starting point:

https://www.google.com/search?q=gta+sa+realistic+handling

But i can't vouch for them, or how close individual ones would come to what is required for RP in terms of realism. I tested none of them.

Protip: for RP servers and realism, you can see that the default GTA vehicle top speeds are nothing too crazy. So the overarching change would be road behavior and driving characteristics, and climb to the desired top speed/gear phases.

 

.. and yes, like The_GTA mentioned.. if  you download such a "realistic handling pack", you would need to load the values using the MTA scripting functions instead, or create your own handling.cfg parser (where you feed the resource the .cfg content) if you're lazy.

Link to comment
13 hours ago, The_GTA said:

Hello lockdw,

you have to use the setVehicleHandling function. On the wiki page there is an excellent example on how to do so:


local predefinedHandling = {
	[411] = {
		["engineAcceleration"] = 14,
		["dragCoeff"] = 0,
		["maxVelocity"] = 100000,
		["tractionMultiplier"] = 0.9,
		["tractionLoss"] = 1.1,
	},
	[415] = {
		["engineAcceleration"] = 14,
		["dragCoeff"] = 0,
		["maxVelocity"] = 100000,
		["tractionMultiplier"] = 0.9,
		["tractionLoss"] = 1.1,
	},
		[562] = { -- Universal drift handling
		["driveType"] = "rwd",
		["engineAcceleration"] = 200,
		["dragCoeff"] = 1.5,
		["maxVelocity"] = 300,
		["tractionMultiplier"] = 0.7,
		["tractionLoss"] = 0.8,
		["collisionDamageMultiplier"] = 0.4,
		["engineInertia"] = -175,
		["steeringLock"] = 75,
		["numberOfGears"] = 4,
		["suspensionForceLevel"] = 0.8,
		["suspensionDamping"] = 0.8,
		["suspensionUpperLimit"] = 0.33,
		["suspensionFrontRearBias"] = 0.3,
		["mass"] = 1800,
		["turnMass"] = 3000,
		["centerOfMass"] = { [1]=0, [2]=-0.2, [3]=-0.5 }, -- Good example to understand centerOfMass parameter usage
	},

	--next model below etc (copy rows)
}

for i,v in pairs (predefinedHandling) do
	if i then
		for handling, value in pairs (v) do
			if not setModelHandling (i, handling, value) then
				outputDebugString ("* Predefined handling '"..tostring(handling).."' for vehicle model '"..tostring(i).."' could not be set to '"..tostring(value).."'")
			end
		end
	end
end

for _,v in ipairs (getElementsByType("vehicle")) do
	if v and predefinedHandling[getElementModel(v)] then
		for k,vl in pairs (predefinedHandling[getElementModel(v)]) do
			setVehicleHandling (v, k, vl)
		end
	end
end

function resetHandling()
	for model in pairs (predefinedHandling) do
		if model then
			for k in pairs(getOriginalHandling(model)) do
				setModelHandling(model, k, nil)
			end
		end
	end

	for _,v in ipairs (getElementsByType("vehicle")) do
		if v then
			local model = getElementModel(v)
			if predefinedHandling[model] then
				for k,h in pairs(getOriginalHandling(model)) do
					setVehicleHandling(v, k, h)
				end
			end
		end
	end
end
addEventHandler("onResourceStop", resourceRoot, resetHandling)

I recommend that you first play around with the hedit resource and then just copy the values over to your script. ;) 

Bro, i found a handling script similar to this. But everytime i exit the car i have to restart the mod on "resources". The script disable himself. You know why?

Debugscript 3 is clear.

Link to comment
13 hours ago, Dutchman101 said:

It's usually error and trial, you could ask someone with experience creating handlings to help you as they should know how to tweak even the default GTA handlings to be more realistic, let alone allow a speed boost in acceptable ways (e.g let the vehicle climb to a higher top speed, so no acceleration overkill). I'd call it a performance boost rather than speed boost, and I've seen plenty of roleplay servers that managed to provide an entirely different vehicle experience in terms of handling and road behavior..

I advise you to focus on road behavior rather than top speed if you want to create realistic handlings. But like i said, you would need a good understanding of the effects of each handling parameter and flag, and how they interact with eachother (since GTA does weird things).

If you can't find anyone for that, or you have no time to learn it, then maybe one of these "Realistic handling packs" is a good starting point:

https://www.google.com/search?q=gta+sa+realistic+handling

But i can't vouch for them, or how close individual ones would come to what is required for RP in terms of realism. I tested none of them.

Protip: for RP servers and realism, you can see that the default GTA vehicle top speeds are nothing too crazy. So the overarching change would be road behavior and driving characteristics, and climb to the desired top speed/gear phases.

 

.. and yes, like The_GTA mentioned.. if  you download such a "realistic handling pack", you would need to load the values using the MTA scripting functions instead, or create your own handling.cfg parser (where you feed the resource the .cfg content) if you're lazy.

Thank you man, removed many doubts!  I will try something like this.

9 minutes ago, The_GTA said:

When i create a car, i have to restart the handling.

My question is: I have some markers around the map, and these markers are used to spawn different vehicles. I want all the markers to restart the handling resource when the player create the vehicle. Like a OnMarkerHit. How could i trigger a event like that ?

 

Link to comment
14 minutes ago, lockdw said:

My question is: I have some markers around the map, and these markers are used to spawn different vehicles. I want all the markers to restart the handling resource when the player create the vehicle. Like a OnMarkerHit. How could i trigger a event like that ?

Restarting the resource countless of times could mess with the perfomance of your server. People that know that a resource is restarted on vehicle spawn could look into abusing your server. Thus I would rather recommend turning the handling script into a global function and calling it on each vehicle spawn, on the sole condition that you do not want to create a dynamic handling script?

But if you were to want to call restartResource, then you'd have to give access rights using the ACL.xml file for that function.

Link to comment
  • MTA Anti-Cheat Team
On 23/03/2020 at 21:00, lockdw said:

But everytime i exit the car i have to restart the mod on "resources". The script disable himself. You know why?

There are currently no known MTA bugs that will reset handling if you exit a vehicle, only when you're replacing an existing vehicle (that had modified handling) with setElementModel (https://github.com/multitheftauto/mtasa-blue/issues/1198). But since that's clearly not the case in your situation, none of the issues mentioned by The_GTA apply.

So your script probably contains a bug (where it differs from the script example, which doesn't suffer from it and will apply handling just fine to all new vehicles, and will not reset it on exit) or there is interference from other scripts. First post your code if you want help to find out why this is happening.

Link to comment
  • 3 years later...

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...