Mvrat Posted April 15, 2020 Share Posted April 15, 2020 (edited) I have a code checks the player in water continuously. But this code teleporting player to specific location. How can I teleport the player to the nearest road? setTimer( function( ) for _, aVehicle in next, getElementsByType 'vehicle' do if isElementInWater( aVehicle ) then setElementPosition( aVehicle, 0, 0, 5 ) setVehicleEngineState ( aVehicle, true ) setVehicleRotation(aVehicle, 0, 0, 0) end end end, 50, 0 ) Edited April 15, 2020 by Lukas Link to comment
_Ace Posted April 15, 2020 Share Posted April 15, 2020 use the table with roads/paths from eXo-OpenSource / ml_pathfind: https://raw.githubusercontent.com/eXo-MTA/ml_pathfind/master/test/sa_nodes.json or add a table and insert the car position xyz in this table (inside your timer) from past 10 second should be enough, then when you fall in the water do a for loop in the table from last index to first, passing a processlineofsight (https://wiki.multitheftauto.com/wiki/ProcessLineOfSight) on the positions, if the material id (https://wiki.multitheftauto.com/wiki/Material_IDs) provided by the processlineofsight is some of the road related ids (I guess id 1 to 5) then teleport to the coords 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