[RELEASE] esx_vehicleTeleportPads

Hello all. I was asked earlier for a script that had the ability to teleport vehicles (and people). I could not find any actual script releases that addressed this request, so I figured I would put this here. If I have missed anything to do with credits, please be nice and let me know, it is not my intention to cause any issues #firstpost.

CREDITS

@Hawaii_Beach aka ElPumpo for the upload of the original esx_teleportpads script, without this I could not have modified the script. @TheStonedTurtle for the ground detection function. BossManNz for the modification of this script. If I have missed anyone please contact me.

DISCLAIMER

This is not my script, I simply used resources available on the FiveM forums. I do not own this script nor do I claim to have created it. I just figured I would release this as many people ask about this sort of thing.

DESCRIPTION

This is a very modular vehicle teleport pad script for ESX (you can also simply just teleport people without a vehicle if you wish). You can very easily add new vehicle teleport pads in the config.lua. This is not my script, I simply used resources available on the FiveM forums. This version incorporates TheStonedTurtle’s ground detection function from the Mello Trainer.

Github repository

8 Likes

Perfect, thx without twenty char but oe heart :wink:

1 Like

I’m having an issue with using this when I teleport into an underground interior. I spawns you basically just underground, but above the interior, anyone know what needs done to fix this?

Hi I’m having the same issue, did you manage to fix it?

I have not been able to figure it out.

Hi @Boss1

Could you rewrite this script so that when you go over and over again a message was displayed on the press? and this your script during the teleportation dimmed screen

have you figured it out yet? i’m having that same issue too :open_mouth:

Did any one have this working every time i go in to a map building whitch it base under the ground it TP’s me and car on top of ground and not in building under the ground please help here

Did you fixed it already ??

I got it fixed. Copy these into the files I listed below, this SHOULD fix the location and the dropping through the world and or above the city with your car. If it don’t work, let me know because I don’t want to spread false information but the location I provided in the config works for me.

Config.lua

--Script Name: esx_vehicleTeleportPads.
--Description: Teleport vehicles with people, or just people without a vehicle from one location to another location.
--Author: Unknown.
--Modified by: BossManNz.
--Credits: ElPumpo, TheStonedTurtle.

Config              = {}

Config.DrawDistance = 100.0

Config.Marker = {
	Type = 1,
	x = 3.5, y = 3.5, z = 1.0,
	r = 255, g = 155, b = 355
}

Config.Pads = {

	MartinHouseIn = {
		Text = 'Press ~INPUT_CONTEXT~ to enter ~y~Garage~s~.',
		Marker = { x = -82.48, y = 79.3, z = 70.64 },
		TeleportPoint = { x = 231.16, y = -1004.12, z = -98.0 }
	},

	MartinHouseOut = {
		Text = 'Press ~INPUT_CONTEXT~ to exit ~y~Garage~s~.',
		Marker = { x = 231.16, y = -1004.12, z = -99.95 },
		TeleportPoint = { x = -88.98, y = 71.1, z = 70.63 }
	}

}

Client.lua

--Script Name: esx_vehicleTeleportPads.
--Description: Teleport vehicles, from one location to another location.
--Author: Unknown.
--Modified by: BossManNz.
--Credits: ElPumpo, TheStonedTurtle.

local Keys = {
  ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}

local HasAlreadyEnteredMarker = false
local LastPad                 = nil
local LastAction              = nil
local LastPadData             = nil
local CurrentAction           = nil
local CurrentActionMsg        = ''
local CurrentActionData       = nil
local ClickedInsideMarker     = false

ESX                           = nil

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
end)

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
  PlayerData = xPlayer
end)

RegisterNetEvent('esx_vehicleteleportpads:hasEnteredMarker')
AddEventHandler('esx_vehicleteleportpads:hasEnteredMarker', function(currentPad, padData)
	CurrentAction = 'pad.' .. string.lower(currentPad)
	CurrentActionMsg = padData.Text
	CurrentActionData = { padData = padData }
end)

RegisterNetEvent('esx_vehicleteleportpads:hasExitedMarker')
AddEventHandler('esx_vehicleteleportpads:hasExitedMarker', function()
	ESX.UI.Menu.CloseAll()
	
	CurrentAction = nil
	ClickedInsideMarker = false
end)

-- Draw marker
Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		
		local playerPed = PlayerPedId()
		local coords = GetEntityCoords(playerPed)

		for pad, padData in pairs(Config.Pads) do
			if GetDistanceBetweenCoords(coords, padData.Marker.x, padData.Marker.y, padData.Marker.z,  true) < Config.DrawDistance then
				DrawMarker(Config.Marker.Type, padData.Marker.x, padData.Marker.y, padData.Marker.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Marker.x, Config.Marker.y, Config.Marker.z, Config.Marker.r, Config.Marker.g, Config.Marker.b, 100, false, true, 2, false, false, false, false)
			end
		end
	end
end)

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		
		local playerPed      = PlayerPedId()
		local coords         = GetEntityCoords(playerPed)
		local isInMarker, currentPad, currentAction, currentPadData = false, nil, nil, nil

		for pad,padData in pairs(Config.Pads) do
			if GetDistanceBetweenCoords(coords, padData.Marker.x, padData.Marker.y, padData.Marker.z, true) < (Config.Marker.x * 1.5) then
				isInMarker, currentPad, currentAction, currentPadData = true, pad, 'pad.' .. string.lower(pad), padData
			end
		end

		local hasExited = false

		if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastPad ~= currentPad or LastAction ~= currentAction)) then
			if (LastPad ~= nil and LastAction ~= nil) and (LastPad ~= currentPad or LastAction ~= currentAction) then
				TriggerEvent('esx_vehicleteleportpads:hasExitedMarker', LastPad, LastAction)
				
				hasExited = true
			end

			HasAlreadyEnteredMarker = true
			LastPad, LastAction, LastPadData = currentPad, currentAction, currentPadData

			TriggerEvent('esx_vehicleteleportpads:hasEnteredMarker', currentPad, currentPadData)
		end

		if not hasExited and not isInMarker and HasAlreadyEnteredMarker then
			HasAlreadyEnteredMarker = false

			TriggerEvent('esx_vehicleteleportpads:hasExitedMarker', LastPad, LastAction)
		end
	end
end)

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(10)

		if CurrentAction ~= nil then

			ESX.ShowHelpNotification(CurrentActionMsg)

			if IsControlJustReleased(0, Keys['E']) then
				if ClickedInsideMarker == false then
					ClickedInsideMarker = true
					
						local targetPed = GetPlayerPed(-1)
	                    if(IsPedInAnyVehicle(targetPed))then
		                targetPed = GetVehiclePedIsUsing(targetPed)
	                    
						end
						
						local ground
		                local groundFound = false
						local x = CurrentActionData.padData.TeleportPoint.x
						local y = CurrentActionData.padData.TeleportPoint.y
						local z = CurrentActionData.padData.TeleportPoint.z

		                for height=1.0,800.0,4.0 do
		                RequestCollisionAtCoord(x, y, height)
		                Wait(0)
		                SetEntityCoordsNoOffset(targetPed, x,y,z, 0, 0, -1)
		                ground,z = GetGroundZFor_3dCoord(x,y,z)
		                if(ground) then
		                groundFound = true
		                break;
		                end
		                end

		                if(not groundFound)then
		                z = 1000
		                GiveDelayedWeaponToPed(PlayerPedId(), 0xFBAB5776, 1, 0) -- Parachute
		                SetEntityCoordsNoOffset(targetPed, x,y,z, 0, 0, -1)
		end


				end
			end
		else
			Citizen.Wait(500)
		end
	end
end)
2 Likes

I confirm it works perfectly even with interiors! Thank you.

However it remains a problem, the script seems to ignore the rotation, for me whatever the heading in the configuration, the vehicle spawn still with the same rotation

Yw. Okay, good deal. If you give me a little time I’ll sort the heading rotation out. I noticed that too and i’m working to find out why now. I’ll mess with it when I get home, try to figure out the rotations, and paste the code. Glad it worked.

how do i add more teleport? i tried to add in config.lua but not working

So i have an issue… i did the fix for teleporting… but it is now only working for me in server… player number 1… not all players

1 Like

hey, doesn’t work for me, you’r script tp me under the map but teleport me above my build, that the import / export garage ( coords with ipl 74 : 994.5925, -3002.594, -39.64699 ) so when i teleport myself, i see me fall under the map and die against the build :confused:

Did you fixed it ?

I got a racetrack up in the air and i can confirm that the fix does only work 10% of the time. it really is not the best fix. When i teleport myself there with a command, it works flawlesly

So I got two separate Pad spots and at first they were working for a tiny bit and now only one will work and its usually the bottom one. I can even switch them from top to bottom and only the bottom works.
Config.lua

--Script Name: esx_vehicleTeleportPads.
--Description: Teleport vehicles with people, or just people without a vehicle from one location to another location.
--Author: Unknown.
--Modified by: BossManNz.
--Credits: ElPumpo, TheStonedTurtle.

Config              = {}

Config.DrawDistance = 100.0

Config.Marker = {
		Type = 27,
		x = 1.5, y = 1.5, z = -5,
		r = 0, g = 100, b = 0
	}

Config.Pads = {

			MartinHouseIn = {
				Text = 'Press ~INPUT_CONTEXT~ to enter ~y~Nightclub~s~.',
				Marker = { x = 230.84, y = -3132.53, z = 5.79 },
				TeleportPoint = { x = -1629.48, y = -3001.19, z = -78.14 }
			},

			MartinHouseOut = {
				Text = 'Press ~INPUT_CONTEXT~ to leave the ~y~NightClub~s~.',
				Marker = { x = -1639.78, y = -2989.68, z = -77.27 },
				TeleportPoint = { x = 217.68, y = -3130.23, z = 5.79 }
			},
	}

	Config.Marker = {
			Type = 27,
			x = 1.5, y = 1.5, z = -5,
			r = 0, g = 100, b = 0
		}

Config.Pads = {

		MartinHouseIn = {
			Text = 'Press ~INPUT_CONTEXT~ to enter ~y~Camo HQ~s~.',
			Marker = { x = 1025.68, y = -2398.88, z = 29.42 },
			TeleportPoint = { x = 1016.74, y = -2397.99, z = 30.14 }
		},

		MartinHouseOut = {
			Text = 'Press ~INPUT_CONTEXT~ to leave the ~y~Camo HQ~s~.',
			Marker = { x = 1019.69, y = -2398.4, z = 29.72 },
			TeleportPoint = { x = 1027.75, y = -2405.85, z = 29.15 }
		},
}

BROOOO I LOVE U TO THE MOON AND BACK. THANK UUUUU

From what ive learned in my classed is that u should stop the loop for the notify wich is made with a while structure. Instead of that while you could us a if