Jump to content

[HELP] Teleporting player to nearest road when falls the water.


Mvrat

Recommended Posts

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 by Lukas
Link to comment

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

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...