[ESX] Teleport menu for admins

this doesn’t work for me can you send the whole client.lua?

I dont support this code you get what you see on github and thats it.
Code above worked for me if it doesnt work for you i will not support that.

ok no problem i just edit it and it works finaly.Thanks :grinning: :+1:

Is there the possibility to put this menu at a specific point and open it by pressing the “E” key for example? Like a block of flats and their rooms

Thanks very much. This still works great on the menu and with the waypoint tp.

It would be possible to change the coordinates and names for my own use?

It does not work for me, what is the problem?

U have tutorial how to add more or change current coordinates in client.lua file

Can’t seem to get this to openwith the F5 key

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
                if group  ~= nil print(group) end

		if IsControlJustReleased(1, 166) then --WHEN YOU PRESS F5
			if group  ~= nil and group ~= "user" then
				OpenTpMenu()
			end
		end
	end
end)

Change your thread and see if your group is user or something else

Hey umm how can i set it so everyone can use it i tried but it doesnt work

Replace this

	if group  ~= nil and group ~= "user" then
		OpenTpMenu()
	end

with this

	OpenTpMenu()

image

Can u send me the whole client.lua? please

You left end tag below OpenTpMenu()

SEND ME THE WHOLE CLIENT.LUA PLEASE

–[[ TELEPORT MENU BY ADRA ]]–
ESX = nil

Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)
Citizen.Wait(50)
end
end)

local elements = {}
local lastlocation = nil
table.insert(elements, { label = ‘Last location’ })

–[[
TELEPORT MENU COORDINATES
Below you have lines of code that you need to change based on your use
LABEL - label of location that you can find in menu
OTHER lines are the actual coordinates
]]–

table.insert(elements, { label = ‘Police station’, x = 425.1, y = -979.5, z = 30.7 })
table.insert(elements, { label = ‘Airport Los Santos’, x = -1037.51, y = -2963.24, z = 13.95 })
table.insert(elements, { label = ‘Airport Sandy Shores’, x = 1718.47, y = 3254.40, z = 41.14})
table.insert(elements, { label = ‘Mount Chiliad’, x = 501.76, y = 5604.28, z = 797.91})
table.insert(elements, { label = ‘Vinewood Sign’, x = 663.41, y = 1217.21, z = 322.94})
table.insert(elements, { label = ‘Benny’s’, x = -205.73, y = -1303.71, z = 31.24 })
table.insert(elements, { label = ‘Los Santos Customs’, x = -360.91, y = -129.46, z = 38.70 })
table.insert(elements, { label = ‘Top of Maze Bank’, x = -75.20, y = -818.95, z = 326.18 })

–[[
TELEPORT MENU LOCALE
You can change notification messages based on your language
]]–

local Locale = {
[‘teleported’] = ‘You have teleported to ~b~’,
[‘teleported_last’] = ‘You have teleported to ~r~Last Location’,
[‘teleported_last_empty’] = ‘You didn’t visit any location with this menu.’,
}

RegisterNetEvent(‘tpmenu:open’)
AddEventHandler(‘tpmenu:open’, function()
ESX.UI.Menu.CloseAll() --Close everything ESX.Menu related

ESX.UI.Menu.Open(
    'default', GetCurrentResourceName(), 'tpmenu',
    {
        title    = 'Teleport menu',
        align    = 'bottom-right',
        elements = elements
    },
    function(data, menu)						--on data selection
        if data.current.label == "Last location" then
            if lastlocation ~= nil then  
                ESX.Game.Teleport(PlayerPedId(), lastlocation) 
                ESX.ShowNotification(Locale['teleported_last'])
            else 
                ESX.ShowNotification(Locale['teleported_last_empty'])
            end
        else
            lastlocation = GetEntityCoords(GetPlayerPed(-1))
            local coords = { x = data.current.x,  y = data.current.y, z = data.current.z}
            ESX.Game.Teleport(PlayerPedId(), coords)
            ESX.ShowNotification(Locale['teleported'] .. data.current.label)
        end
        menu.close()							--close menu after selection
      end,
      function(data, menu)
        menu.close()
      end
    )

end)

local group = “user”

function OpenTpMenu()
ESX.UI.Menu.CloseAll()

ESX.UI.Menu.Open(
    'default', GetCurrentResourceName(), 'tpmenu',
    {
        title    = 'Teleport menu',
        align    = 'bottom-right',
        elements = elements
    },
    function(data, menu)						--on data selection
        if data.current.label == "Last location" then
            if lastlocation ~= nil then  
                ESX.Game.Teleport(PlayerPedId(), lastlocation) 
                ESX.ShowNotification(Locale['teleported_last'])
            else 
                ESX.ShowNotification(Locale['teleported_last_empty'])
            end
        else
            lastlocation = GetEntityCoords(GetPlayerPed(-1))
            local coords = { x = data.current.x,  y = data.current.y, z = data.current.z}
            ESX.Game.Teleport(PlayerPedId(), coords)
            ESX.ShowNotification(Locale['teleported'] .. data.current.label)
        end
        menu.close()							--close menu after selection
      end,
      function(data, menu)
        menu.close()
      end
    )

end

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

	if IsControlJustReleased(1, 166) then --WHEN YOU PRESS F5
			OpenTpMenu()

RegisterNetEvent(‘es_admin:setGroup’)
AddEventHandler(‘es_admin:setGroup’, function(g)
group = g
end)

Doesnt work it says

hello! found out how to teleport vehicles and the player inside the vehicle ill leave the code here since i’ve seen in the past there has been people asking for it first of all thank @Amar_Gurzil for creating the script and replying to someone with the code i used but he had 1 simple error he put the ESX.Game.Teleport(playerPed, coords) after the end and not before the ESX.Game.Teleport(vehicle, coords)

here’s the code:

--[[ TELEPORT MENU BY ADRA ]]--
ESX = nil

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

local elements = {}
local lastlocation = nil
table.insert(elements, { label = 'Last location' })

--local teleportwithveh = false
--table.insert(elements, { label = 'Teleport with car' })


--[[
    TELEPORT MENU COORDINATES
    Below you have lines of code that you need to change based on your use
    LABEL - label of location that you can find in menu
    OTHER lines are the actual coordinates
]]--

table.insert(elements, { label = 'Police station', x = 425.1, y = -979.5, z = 30.7  })
table.insert(elements, { label = 'Airport Los Santos', x = -1037.51, y = -2963.24, z = 13.95 })
table.insert(elements, { label = 'Airport Sandy Shores', x = 1718.47, y = 3254.40, z = 41.14})
table.insert(elements, { label = 'Mount Chiliad', x = 501.76, y = 5604.28, z = 797.91})
table.insert(elements, { label = 'Vinewood Sign', x = 663.41, y = 1217.21, z = 322.94})
table.insert(elements, { label = 'Benny\'s', x = -205.73, y = -1303.71, z = 31.24 })
table.insert(elements, { label = 'Los Santos Customs', x = -360.91, y = -129.46, z = 38.70 })
table.insert(elements, { label = 'Top of Maze Bank',  x = -75.20, y = -818.95, z = 326.18 })


--[[
    TELEPORT MENU LOCALE
    You can change notification messages based on your language
]]--


local Locale = {
    ['teleported']  = 'You have teleported to ~b~',
    ['teleport_tpwithcar']  = 'You teleportation with car is ',
    ['teleported_last']  = 'You have teleported to ~r~Last Location',
    ['teleported_last_empty']  = 'You didn\'t visit any location with this menu.',
}

RegisterNetEvent('tpmenu:open')
AddEventHandler('tpmenu:open', function()
    ESX.UI.Menu.CloseAll()          --Close everything ESX.Menu related 

    ESX.UI.Menu.Open(
        'default', GetCurrentResourceName(), 'tpmenu',
        {
            title    = 'Teleport menu',
            align    = 'top-left',
            elements = elements
        },
        function(data, menu)            --on data selection
            if data.current.label == "Last location" then
                if lastlocation ~= nil then 
                menu.close() 
                  local playerPed = GetPlayerPed(-1) 
                    local vehicle = GetVehiclePedIsIn(playerPed, false)
                    ESX.Game.Teleport(playerPed, lastlocation)
                    ESX.Game.Teleport(vehicle , lastlocation)
                    SetPedIntoVehicle(playerPed , vehicle , -1)
                    ESX.ShowNotification(Locale['teleported_last'])
                else 
                    ESX.ShowNotification(Locale['teleported_last_empty'])
                end
            elseif data.current.label == "Teleport with car" then
                  if teleportwithveh == false then 
                    teleportwithveh = true 
                    ESX.ShowNotification(Locale['teleport_tpwithcar'] .. '~g~ON')
                  else 
                    teleportwithveh = false 
                    ESX.ShowNotification(Locale['teleport_tpwithcar'] .. '~r~OFF')
                  end
            else
            	menu.close()
                  local playerPed = GetPlayerPed(-1)
                  lastlocation = GetEntityCoords(playerPed )
                  local coords = { x = data.current.x,  y = data.current.y, z = data.current.z}
                  if teleportwithveh == true then
                    local vehicle = GetVehiclePedIsIn(playerPed, false)
                    ESX.Game.Teleport(playerPed, coords)
                    ESX.Game.Teleport(vehicle , coords)
                    SetPedIntoVehicle(playerPed , vehicle , -1)
                  end
                  --ESX.Game.Teleport(playerPed, coords)
         
                  ESX.ShowNotification(Locale['teleported'] .. data.current.label)
            end
           -- menu.close()              --close menu after selection
          end,
          function(data, menu)
            menu.close()
          end
        )
    
end)

local group = "user"

function OpenTpMenu()
   ESX.UI.Menu.CloseAll()			
    
    ESX.UI.Menu.Open(
        'default', GetCurrentResourceName(), 'tpmenu',
        {
            title    = 'Teleport menu',
            align    = 'top-left',
            elements = elements
        },
        function(data, menu)						--on data selection
            if data.current.label == "Last location" then
                if lastlocation ~= nil then
                	menu.close()
                  local playerPed = GetPlayerPed(-1) 
                    local vehicle = GetVehiclePedIsIn(playerPed, false)
                    ESX.Game.Teleport(playerPed, lastlocation)
                    ESX.Game.Teleport(vehicle , lastlocation)
                    SetPedIntoVehicle(playerPed , vehicle , -1)
                    ESX.ShowNotification(Locale['teleported_last'])
                else 
                    ESX.ShowNotification(Locale['teleported_last_empty'])
                end
            else
            	menu.close()
                  local playerPed = GetPlayerPed(-1)
                  lastlocation = GetEntityCoords(playerPed )
                  local coords = { x = data.current.x,  y = data.current.y, z = data.current.z}
                  --if teleportwithveh == true then
                    local vehicle = GetVehiclePedIsIn(playerPed, false)
                    ESX.Game.Teleport(playerPed, coords)
                    ESX.Game.Teleport(vehicle , coords)
                    SetPedIntoVehicle(playerPed , vehicle , -1)
                ESX.ShowNotification(Locale['teleported'] .. data.current.label)
            end
           -- menu.close()							--close menu after selection
          end,
          function(data, menu)
            menu.close()
          end
        )
end

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

		if IsControlJustReleased(1, 166) then --WHEN YOU PRESS F5
				OpenTpMenu()
			end
		end
	end)

RegisterNetEvent('es_admin:setGroup')
AddEventHandler('es_admin:setGroup', function(g)
	group = g
end)

again thank @Amar_Gurzil for creating this script!

edit: fixing some errors here and there since last location didnt teleport vehicle + added support for keybind F5 [thanks Amar again for making the keybind part of the script]

edit2: a little edit since on my modifications i didnt have the option to turn off or on the vehicle teleport since it isnt necesary should be easy to reactivate tho i can even make it so you can reactivate it if someone wants to

edit3: since im a little dumb i didnt change a thing over here but this is the last edit [for now] and a note: its set so everyone can use it btw but should be easy too to make it so admins only can open it.

2 Likes

hey guy’s, how can I put all tp options (police station, Airport Sandy Shores, etc.) in a submenu?
Like once I clicked on submenu(exemple of the submenu name), it will show me all the tp options…

So i have made some modifications to the code in order for people to teleport inside the car instead of just teleporting the player and the car, was wondering if anyone wants me to share de code here keeping in mind i ended up merging code from one of my test scripts so this probably isnt fully optimized

2 Likes