Jump to content

What The Damn Wrong there?


Recommended Posts

hi guys ......

what the damn wrong with this code

im trying to take a vehicle move alone with speed

60

function setElementSpeed(element, unit, speed) -- only work if element is moving! 
    if (unit == nil) then unit = 0 end 
    if (speed == nil) then speed = 0 end 
    speed = tonumber(speed) 
    local acSpeed = getElementSpeed(element, unit) 
    if (acSpeed~=false) then -- if true - element is valid, no need to check again 
        local diff = speed/acSpeed 
        local x,y,z = getElementVelocity(element) 
        setElementVelocity(element,x*diff,y*diff,z*diff) 
        return true 
    end 
  
    return false 
end 
  
-------------- let's make car move alone  
  
function M() 
  
  local veh = getPedOccupiedVehicle(localPlayer) 
   
  local acSpeed = getElementSpeed(veh, tonumber(0)) 
   
  if (veh) and (acSpeed) then 
   
  setElementSpeed(veh,"kph",tonumber(60)) ---- set speed 60 
   
end 
end 
addEventHandler("onClientRender",getRootElement(),M) 
addEventHandler("onClientVehicleEnter",root,M) 
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...