Jump to content

Marker that teleports player and vehicle


Dekonpriv

Recommended Posts

Posted

- Create a marker at the desired location using the createMarker function
- Use addEventHandler to create an event handler function that will be called when the marker is triggered

- Use the setElementPosition function in the event handler function to move the player and vehicle to the desired location

Posted (edited)
local myMarker = createMarker(...)

addEventHandler("onClientMarkerHit", myMarker, function(hit, dim)
    local vehicle = getPedOccupiedVehicle(localPlayer)
    if hit == localPlayer or hit == vehicle then
       if vehicle then
          setElementPosition(vehicle, x, y, z)
          setElementPosition(localPlayer, x, y, z)
       else
          setElementPosition(localPlayer, x, y, z)
       end
    end
end)

 

Edited by Hydra
Posted
19 hours ago, Dekonpriv said:

I wold like to create a marker that teleports the player to a location the vehicle to another location.
The marker, I already know how to create it

local marker = createMarker (...)

addEventHandler ("onMarkerHit", marker, function(el, dim)
	if not dim then return end
	if getElementType(el) ~= "player" then return end
		
	local veh = getPedOccupiedVehicle (el)
	
	if veh then
		if getVehicleOccupant(veh) ~= el then return end
		
		setElementPosition (veh, x, y, z)
	else
		setElementPosition (el, x, y, z)
	end
end)

 

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