Jump to content

need some help whit max speed


bandi94

Recommended Posts

i search on wiki some functions that set a car max speed (for my rpm+gear meter i wanna too make a manual gearbox if you writ /manualgear in chatbox) the problem is that function i found on wiki is only server side i need some client side function to set max speed for a car

Link to comment

There is no function like that client-side, but instead you can use setElementVelocity as work-around:

local speed = 50 
function limitSpeed() 
      local myveh = getPedOccupiedVehicle(getLocalPlayer()) 
      local vx,vy,vz = getElementVelocity(myveh) 
      if getSpeed(vx,vy,vz) > speed then  
              setElementVelocity(myveh,vx/1.05,vy/1.05,vz/1.05)--apply smooth speed limit 
      end 
end 
addEventHandler('onClientRender',getRootElement(),limitSpeed) 
  
function getSpeed( x,y,z ) 
    return math.sqrt(x^2 + y^2 + z^2) * 161 
end 

Edited by Guest
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...