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

Ahh, didn’t catch that it was for the newest version. Will update, test and come back.

for disable to work with the new nh-context this needs to be remade have tried but no luck


RegisterNetEvent("angelicxs_elevator:showFloors", function(data)
	local elevator = {}
	for index, floor in pairs(Config.Elevators[data.elevator]) do
		table.insert(elevator, {
			id = index,
			header = floor.level,
			txt = floor.label,
			disabled = index == data.level,
			params = {
				event = "angelicxs_elevator:movement",
				args = {
					floor = floor
				}
			}
		})
	end
	TriggerEvent("nh-context:sendMenu", elevator)
end)

@DrAceMisanthrope

Sorry, you are correct, @Smokiiee. I will update my original post again :stuck_out_tongue:
Seems they changed everything about the event, including the name. Not just adding parameters. Pays to take the time and read. My bad. So here you go, this should work! Note that it no longer passes a table of args, but each arg in order. So I had to update angelicxs_elevator:movement aswell.

RegisterNetEvent("angelicxs_elevator:showFloors", function(data)
	local elevator = {}
	for index, floor in pairs(Config.Elevators[data.elevator]) do
		table.insert(elevator, {
			header = floor.level,
			context = floor.label,
			disabled = index == data.level,
			event = "angelicxs_elevator:movement",
			args = { floor }
		})
	end
	TriggerEvent("nh-context:createMenu", elevator)
end)

RegisterNetEvent("angelicxs_elevator:movement", function(floor)
	if hasRequiredJob(floor.jobs) then
		local ped = PlayerPedId()
		DoScreenFadeOut(1500)
		while not IsScreenFadedOut() do
			Wait(10)
		end
		RequestCollisionAtCoord(floor.coords.x, floor.coords.y, floor.coords.z)
		while not HasCollisionLoadedAroundEntity(ped) do
			Citizen.Wait(0)
		end
		SetEntityCoords(ped, floor.coords.x, floor.coords.y, floor.coords.z, false, false, false, false)
		SetEntityHeading(ped, floor.heading and floor.heading or 0.0)
		Wait(3000)
		DoScreenFadeIn(1500)
	else
		TriggerEvent("angelicxs_elevator:notify", "You don't have clearance for this floor!", "error")
	end
end)
1 Like

I did a pull requests on your github to make it to the latest took the new code from @DrAceMisanthrope.

and also fix esx-qbcore to work it you change it via the config

I for some reason can not get the button to disable if they do not have the correct job for the button I not sure if I am doing something wrong or?

Please try pulling the elevator github (client only) again and ensure you are using the newest version of NH-Context as posted by Smokiee

Yeah just tried it is disabling the floor i am on just not the floors that i dont have the job for if that makes sense

get this error message. What is the reason for that? am a total noob ^^ thanks for the help

@Lilifee Have you used the newest update from the GitHub and the newest version of nh-context?

@Formulation can you share a snip of the config for the elevator you are trying to restrict?

this one?

and elevator newest yes. download 10mins before

Yes that is the correct nh-context

@angelicxs, could you please add me as a contributor to the GitHub repo, just so that I can update the script as needed, instead of my post above and needing you to update it. It still needs updating but there is a mistake as well and I am adding a new feature that @Formulation was after, which also disables if you don’t have the job.
Here is my GitHub profile → https://github.com/FlyingAce015

Recent changes!

Fixed QBCore job support (needed grade.level not just grade like ESX does);

PlayerGrade = playerData.job.grade.level

RegisterNetEvent("QBCore:Client:OnJobUpdate", function(job)
	PlayerJob = job.name
	PlayerGrade = job.grade.level
end)

Disable buttons if you don’t have the right job;

disabled = (index == data.level or not hasRequiredJob(floor.jobs)),

My original post has been updated again. I will be updating the GitHub repo if I am made a contributor.

1 Like

@DrAceMisanthrope you have been made contributor! Thanks for all your continued help on improving this!

1 Like

Thanks!
Update is pushed.
@Lilifee @Formulation, please update. The latest version is now on GitHub

1 Like

WORK <3

Excellent! I am glad its working for you!

Quite pleased with myself (and others), getting this working without ever testing it myself. I don’t even use nh-context or qtarget haha
Glad to see it works so well. Hope you all are happy and good teamwork, everyone!

Any way to write in required item for seperate elevators? For example casino penthouse you need a “members card”? That would be awesome!