#Al-Ha[J]aRii Posted June 15, 2013 Share Posted June 15, 2013 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
iPrestege Posted June 15, 2013 Share Posted June 15, 2013 Because ( setElementSpeed ) Useful function requires a ( getElement Speed ) . Also check if is player in a vehicle because set and get speed function's need that . Link to comment
#Al-Ha[J]aRii Posted June 15, 2013 Author Share Posted June 15, 2013 Because ( setElementSpeed ) Useful function requires a ( getElement Speed ) . Also check if is player in a vehicle because set and get speed function's need that . ah ..... thank you bro . I was saw in the code setElementSpeed there was getElementSpeed speed = tonumber(speed) local acSpeed = getElementSpeed(element, unit) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now