Andres99907 Posted October 27, 2016 Share Posted October 27, 2016 some resources to get on the nearest vehicle? , Sorry , My English is bad. Link to comment
Walid Posted November 1, 2016 Share Posted November 1, 2016 On 27/10/2016 at 4:04 AM, Andres99907 said: some resources to get on the nearest vehicle? , Sorry , My English is bad. Try this local mathFloor = math.floor function getNearestVehicle( player ) if player and isElement(player) then local x, y, z = getElementPosition( player ) local vehicles = getElementsByType( "vehicle" ) local prevDistance local nearestVehicle for i=1, #vehicles do local distance = mathFloor(getDistanceBetweenPoints3D( x, y, z, getElementPosition(vehicles[i]))) if distance <= ( prevDistance or distance + 1 ) then prevDistance = distance nearestVehicle = vehicles[i] end end return nearestVehicle or false end end 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