Jump to content

setElementVelocity inertia


Recommended Posts

I'm not sure the math on this, but I'm trying to make the velocity not drain as fast. However this is making it continually gain speed.

 

vV = "w"

iK_v = 1.02 -- inertia power

sK_t = 50

Xperimental = true

local sorc = getLocalPlayer()

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
function(resource)
	bindKey(vV, "both", _coref_)
end
)

function _coref_(key, state)
  	local veh = getPedOccupiedVehicle(sorc)
	if (veh) then
		if (getVehicleController(veh) == sorc) then
			if key == vV then
				if state == "up" then
					if Xperimental then
						cT3 = getTickCount()
					end
					sT = setTimer(function()
						local xs, ys, zs = getElementVelocity(veh)
						setElementVelocity(veh, xs*iK_v, ys*iK_v, zs*iK_v)
				    end, sK_t, 0)
				    elseif state == "down" then
                                    return
					end
					killTimer(sT)
				end
			end
		end
	end
end

 

Edited by greentumbleweed
Link to post

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