[Release] [Free] Elevator Script for ESX & QBCore

Add something like this to the script.

CreateThread(function()
    local Player = PlayerPedId()
    while true do
        local Sleep = 2000
        for elevatorName, elevatorFloors in pairs(Config.Elevators) do
            for index, floor in pairs(elevatorFloors) do
                local Pos = GetEntityCoords(Player)
                local Dist = #(Pos - vector3(floor.coords.x, floor.coords.y, floor.coords.z))
                if Dist <= 4 then
                    Sleep = 100
                    if Dist <= 1.5 then
                        ESX.ShowHelpNotification('You are near the '..floor.level.. ' elevator')
                        Sleep = 5000
                    end
                end            
            end
        end
        Wait(Sleep)
    end
end)
1 Like

works <3 thank you so much

I did something similar to @angelicxs for you, but slightly different to prevent repeating notifications while staying in the elevator zone and itā€™s a bit more configurable.

Add this to config.lua:

Config.Notify = {
	enabled = true,
	distance = 3.0,
	message = "Target the elevator to use"
}

Edit the thread in client.lua:

CreateThread(function()
	for elevatorName, elevatorFloors in pairs(Config.Elevators) do
		for index, floor in pairs(elevatorFloors) do
			exports["qtarget"]:AddBoxZone(elevatorName .. index, floor.coords, 5, 4, {
				name = elevatorName,
				heading = floor.heading,
				debugPoly = false,
				minZ = floor.coords.z - 1.5,
				maxZ = floor.coords.z + 1.5
			},
			{
				options = {
					{
						event = "angelicxs_elevator:showFloors",
						icon = "fas fa-hand-point-up",
						label = "Use Elevator From " .. floor.level,
						elevator = elevatorName,
						level = index
					},
				},
				distance = 1.5 
			})
		end
	end

	if Config.Notify.enabled then
		local wasNotified = false
		while true do
			local sleep = 3000
			local nearElevator = false
			local playerCoords = GetEntityCoords(PlayerPedId())
			for elevatorName, elevatorFloors in pairs(Config.Elevators) do
				for index, floor in pairs(elevatorFloors) do
					local distance = #(playerCoords - floor.coords)
					if distance <= 10.0 then
						sleep = 10
						if distance <= Config.Notify.distance then
							nearElevator = true
							break
						end
					end
				end
			end
			if nearElevator then
				if not wasNotified then
					ESX.ShowHelpNotification(Config.Notify.message)
					wasNotified = true
				end
			else
				wasNotified = false
			end
			Wait(sleep)
		end
	end

end)

This was rushed because I am finishing up at work, but give it a go!

2 Likes

oha so much thanks. that screams to a update.

itā€™s always so good when you find great people like angelicxs and you and together create something great from different ideas and a simple script that was once made

2 Likes

probably not lmao

Did the script work once you updated to the newest nh-context?

yes :smiley:

this script can use for teleport ?

Not entirely sure what you mean, sorry.
This script is for placing zones that open a context menu when targeted, and you are teleported to the other zone you select in that menu. So it simulates an elevator.
Walk up to it, select a floor, teleport to that floor.
If you are asking whether this can be used to teleport in ways other than elevators, yes, yes it can.
Give it a shot!

i mean this sirā€¦ i want put other zonesā€¦ then go other zones

This script is used to teleport yes
from a menu
its like an elevator

Give us more info and so we can help you

Fixed. Apparently QBCore PlayerData was returning with nil jobs on first connect, so the OP updated the repo to fix it, but had a space between ā€œ~ā€ and ā€œ=ā€ causing that error. I donā€™t even know why QBCore would be returning nil jobs anyway. Thatā€™s not how QBCore should workā€¦ Perhaps an older version of qb-core had an issue.

Anyway, it should be good now! ā†’ GitHub - GouveiaXS/elevators: elevator script for fivem

i got problem sir ā€¦ 2022-04-22 04-38-27

There is nothing in our script about a safe zone and you didnā€™t show F8 console.
So I donā€™t know if there are errors being thrown.
But those safe zone messages are another script, not ours.

yes i knowā€¦ i put safezone in hospitalā€¦ i cant use elevator . nothing error in f8 or cmdā€¦
or script elevator cant use in safezone ?

Not sure, I donā€™t know how your safe zone script works. You tell me :stuck_out_tongue:
Stop your safe zone script and try to use the elevator. If it works while the safe zone script is stopped, but not when running, you know your issue.
If it still doesnā€™t run, share your elevator config file with me, please.

okey sirā€¦ tomorrow i try againā€¦ thank so much sirā€¦ i like you scriptā€¦ because use qtargetā€¦

Yes :slight_smile: