Files
community_bridge/modules/doorlock/qb-doorlock/client.lua
T

26 lines
789 B
Lua
Raw Normal View History

2025-05-09 02:01:37 -04:00
---@diagnostic disable: duplicate-set-field
2025-05-18 23:45:37 -04:00
if GetResourceState('qb-doorlock') == 'missing' then return end
Doorlock = Doorlock or {}
2025-04-19 14:37:10 -04:00
---This will get the closest door to the ped
---@return string | nil
Doorlock.GetClosestDoor = function()
2025-07-28 01:37:52 -04:00
local ped = PlayerPedId()
local closestDoor = exports["qb-doorlock"]:GetClosestDoor()
if Table.CheckPopulated(closestDoor) then return closestDoor end
local allDoors = exports["qb-doorlock"]:GetDoorList()
2025-07-28 01:37:52 -04:00
local pedCoords = GetEntityCoords(ped)
local door = 0
local doorDist = 1000.0
for doorID, data in pairs(allDoors) do
local dist = #(pedCoords - data.objCoords)
if dist < doorDist then
door = doorID
doorDist = dist
end
end
return door
end
return Doorlock