Jump to content

Vehicle Speed


TorNix~|nR

Recommended Posts

function SetSpeed()
    for k,v in ipairs(getElementsByType("vehicle")) do
    vehs = getElementModel(v)
    setModelHandling(vehs, "maxVelocity", 900)
    end
  end
addEventHandler("onResourceStart", resourceRoot,SetSpeed)

not tested but it sould work

Edited by #BrosS
  • Like 1
Link to comment

#BrosS sorry for that

#BrosS sorry for that word xD

I made it, it works fine, but there is a little thing I want to remove, on 

engineAcceleration

the vehicle drifts, I want only speed not drift, any help please?

Code:

function SetSpeed()
    for k,v in ipairs(getElementsByType("vehicle")) do
    vehs = getElementModel(v)
    setModelHandling(vehs, "engineAcceleration", 50)
    end
  end
addEventHandler("onResourceStart", resourceRoot,SetSpeed)

function RemoveSpeed()
    for k,v in ipairs(getElementsByType("vehicle")) do
    vehs = getElementModel(v)
    setModelHandling(vehs, "engineAcceleration", nil)
    end
  end
addEventHandler("onResourceStop", resourceRoot,RemoveSpeed)

 

Link to comment
  • MTA Anti-Cheat Team

Check this out:

https://community.multitheftauto.com/index.php?p=resources&s=details&id=13636

(you can set handling for vehicles as you desire) It might even be better, as vehicles react differently to the same handling parameter tuning. You will run into problems if you just raise acceleration + max velocity for each vehicle, better make a selection for custom speed handling and on a case by case basis by that script I linked.

-- For handling flags and value range refer to https://wiki.multitheftauto.com/wiki/SetModelHandling
-- Add any handling value type not included below, by simply adding its string in below format followed by = value as below. Get valid strings from https://wiki.multitheftauto.com/wiki/SetModelHandling
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,
	},

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

Also by your question it seems you don't really understand how to achieve that ''speed boost'' you're talking about, so I will give you a bit of information:

- In order to have a noticable speed effect by anything (like acceleration or max velocity) you better lower the Drag Multiplier value (the performance gain from all later tweaks will increase in effect with that, setting it to 0 will give practically infinite top speed and accel that reflects the new values)

After lowering the Drag multiplier, you can raise the acceleration and possibly increase max velocity (say, to 600..) and aslong you don't set Drag multiplier to 0, it won't ever reach 600kph, so dont be afraid of that as you said a good top speed isnt what you want - however it's needed because max velocity, acceleration and drag multiplier co-interact (they decide the end result where all 3 are factors, although the values wont be practically achieved unless you tweak the next bottleneck - traction..)

A good generic handling (for ''speed boost'' you want) using the linked/pasted script would be this table:

        ["engineAcceleration"] = 23,
        ["dragCoeff"] = 1,
        ["maxVelocity"] = 700,
        ["tractionMultiplier"] = 0.9,
        ["tractionLoss"] = 1.1,

Because the bottlenecks (drag mult, traction) are already improved, you can easily just increase Acceleration if you want it even faster, from that template.

@TorNix~|nR

 

Edited by Dutchman101
  • Like 1
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...