[Release] [Standalone] Boost's simple numpad


Hey today i’m releasing my first UI made resource. It’s a simple numpad for your application needs.
UI is made with tailwind.

THIS IS AN EXAMPLE OF WHAT YOU CAN DO

Usage

exports['Boost-Numpad']:openNumpad(code,show,function(correct)
  if correct then
    -- Do something
  end
end)

exports['Boost-Numpad']:openNumpad(1234,true,function(correct)
  if correct then
    -- Do something
  end
end)


18 Likes

Nice, gonna add this to the locks for the armory in PD , black market, and a few other places.

1 Like

good job seems like a great idea, how is it configured?

1 Like

Check usage in the readme. There is no config file atm

put this but how do you put the door that you want to lock?

Usage

exports['Boost-Numpad']:openNumpad(code,length,function(correct)
  if correct then
    -- Do something
  end
end)

You would need to put the unlock function inside the if statement

I still don’t know how to do it, you could set the example with the door of the video, it would be easier to follow the pattern, a thousand thanks for the help

If you have a door lock script already, you can add the export to it and add the trigger for unlock/lock function for your door lock script. I think that is how this is supposed to be used.

exports['Boost-Numpad']:openNumpad(1234,4,function(correct)
  if correct then
    TriggerServerEvent("Doors:JobLocked",closest,_s)
  end
end)

That is for my door locking resource.

thx
I am going to try

Very cool thank you man!

1 Like

Awesome, good job! I think it could be better if the password should be hidden on the ui, eg: from 1234 to ****

1 Like

Will add this as config :slight_smile:

1 Like

How do l configure this?

ESX = nil

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

while not ESX.GetPlayerData().job do
	Citizen.Wait(10)
end

ESX.PlayerData = ESX.GetPlayerData()

-- Update the door list
ESX.TriggerServerCallback('esx_doorlock:getDoorState', function(doorState)
	for index,state in pairs(doorState) do
		Config.DoorList[index].locked = state
	end
end)

end)

RegisterNetEvent(‘esx:setJob’)
AddEventHandler(‘esx:setJob’, function(job) ESX.PlayerData.job = job end)

RegisterNetEvent(‘esx_doorlock:setDoorState’)
AddEventHandler(‘esx_doorlock:setDoorState’, function(index, state) Config.DoorList[index].locked = state end)

Citizen.CreateThread(function()
while true do
local playerCoords = GetEntityCoords(PlayerPedId())

	for k,v in ipairs(Config.DoorList) do
		v.isAuthorized = isAuthorized(v)

		if v.doors then
			for k2,v2 in ipairs(v.doors) do
				if v2.object and DoesEntityExist(v2.object) then
					if k2 == 1 then
						v.distanceToPlayer = #(playerCoords - GetEntityCoords(v2.object))
					end

					if v.locked and v2.objHeading and ESX.Math.Round(GetEntityHeading(v2.object)) ~= v2.objHeading then
						SetEntityHeading(v2.object, v2.objHeading)
					end
				else
					v.distanceToPlayer = nil
					v2.object = GetClosestObjectOfType(v2.objCoords, 1.0, v2.objHash, false, false, false)
				end
			end
		else
			if v.object and DoesEntityExist(v.object) then
				v.distanceToPlayer = #(playerCoords - GetEntityCoords(v.object))

				if v.locked and v.objHeading and ESX.Math.Round(GetEntityHeading(v.object)) ~= v.objHeading then
					SetEntityHeading(v.object, v.objHeading)
				end
			else
				v.distanceToPlayer = nil
				v.object = GetClosestObjectOfType(v.objCoords, 1.0, v.objHash, false, false, false)
			end
		end
	end

	Citizen.Wait(500)
end

end)

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local letSleep = true

	for k,v in ipairs(Config.DoorList) do
		if v.distanceToPlayer and v.distanceToPlayer < 50 then
			letSleep = false

			if v.doors then
				for k2,v2 in ipairs(v.doors) do
					FreezeEntityPosition(v2.object, v.locked)
				end
			else
				FreezeEntityPosition(v.object, v.locked)
			end
		end

		if v.distanceToPlayer and v.distanceToPlayer < v.maxDistance then
			local size, displayText = 1, _U('unlocked')

			if v.size then size = v.size end
			if v.locked then displayText = _U('locked') end
			if v.isAuthorized then displayText = _U('press_button', displayText) end

			ESX.Game.Utils.DrawText3D(v.textCoords, displayText, size)

			if IsControlJustReleased(0, 38) then
				if v.isAuthorized then
					v.locked = not v.locked
					TriggerServerEvent('esx_doorlock:updateState', k, v.locked) -- broadcast new state of the door to everyone
				end
			exports['Boost-Numpad']:openNumpad(1234,4,function(correct))
				if correct then
					TriggerServerEvent('esx_doorlock:updateState',v_ilev_ph_door01)
				end
			end
		end
	end

	if letSleep then
		Citizen.Wait(500)
	end
end

end

function isAuthorized(door)
if not ESX or not ESX.PlayerData.job then
return false
end

for k,job in pairs(door.authorizedJobs) do
	if job == ESX.PlayerData.job.name then
		return true
	end
end

return false

end

Update !

  • Fixed some bugs
  • Updated the export
  • Added option to hide the code
1 Like

is it possible to use nui_doorlock to set other pins instead of just 1234?

Because if every door has 1234 as a pin, the whole thing is rather useless.

You would need to adapt nui_doorlock to add pin codes to the config :slight_smile:

Oh dear, that exceeds my level of knowledge XD

Maybe I could make a fork with the pin code edit

that would be awesome!
Or a complete package? with the door lock?