For those who want to use qb-target instead of TextUI,
delete everything in elevators.lua except for the following lines:
local points = {}
local floors =
Place this inside elevators.lua
local QBCore = exports['qb-core']:GetCoreObject()
-- Debug mode (show zone boxes)
local debugPoly = false
-- === Base elevator locations ===
local lobbyCoords = vec4(-819.82, -699.8, 28.07, 90.216)
local lobbyTarget = vector3(-821.24, -698.91, 28.39)
local baseCoords = vec4(-824.11, -717.47, 41.57, 223.66) -- Floor 1 teleport
local baseTarget = vector3(-823.92, -718.98, 41.86) -- Floor 1 target
-- Z increment between floors
local zIncrementTeleport = 3.8
local zIncrementTarget = 3.8
-- === Generate all floors ===
local floors = {}
-- Lobby
floors[#floors + 1] = {
coords = lobbyCoords,
target = lobbyTarget,
label = "Lobby",
}
-- Floors 1 → 20
for i = 1, 20 do
local teleportZ = baseCoords.z + (zIncrementTeleport * (i - 1))
local targetZ = baseTarget.z + (zIncrementTarget * (i - 1))
floors[#floors + 1] = {
coords = vec4(baseCoords.x, baseCoords.y, teleportZ, baseCoords.w),
target = vector3(baseTarget.x, baseTarget.y, targetZ),
label = ("Floor %d"):format(i),
}
end
-- === Elevator Menu ===
local function OpenElevatorMenu(currentCoords)
local elements = {}
for _, floor in ipairs(floors) do
local currentFloor = #(currentCoords - vec3(floor.coords.x, floor.coords.y, floor.coords.z)) < 1.0
elements[#elements + 1] = {
header = floor.label,
txt = currentFloor and 'You are here' or ('Go to ' .. floor.label),
disabled = currentFloor,
params = {
event = 'elevator:teleport',
args = floor
}
}
end
exports['qb-menu']:openMenu(elements)
end
-- === Teleport Event ===
RegisterNetEvent('elevator:teleport', function(floor)
DoScreenFadeOut(800)
Wait(1000)
SetEntityCoords(PlayerPedId(), floor.coords.x, floor.coords.y, floor.coords.z - 1.0, false, false, false, false)
SetEntityHeading(PlayerPedId(), floor.coords.w)
Wait(500)
DoScreenFadeIn(800)
end)
-- === Add QB-Target zones for each floor ===
CreateThread(function()
for _, floor in ipairs(floors) do
if floor.target then
exports['qb-target']:AddBoxZone(
"elevator_" .. floor.label,
floor.target,
1.0, 1.0,
{
name = "elevator_" .. floor.label,
heading = floor.coords.w,
debugPoly = debugPoly,
minZ = floor.target.z - 1.0,
maxZ = floor.target.z + 1.5,
},
{
options = {
{
type = "client",
event = "elevator:openMenu",
icon = "fas fa-elevator",
label = "Use Elevator",
},
},
distance = 2.0
}
)
end
end
end)
-- === Open Menu Event ===
RegisterNetEvent('elevator:openMenu', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
OpenElevatorMenu(coords)
end)