Agency Docs
Standalone

Agency-Doorlock 导出 & API

锁住整座城市最省事的方式。Agency-Doorlock 把任何一扇门变成安全且会保存状态的门锁,全部在游戏内设置:瞄准门,按 E,完成(双开门自动配对)。通过 [E] 提示或 ox_target / qb-target.

v1.1.7免费6 页面

01客户端导出

导出说明
ToggleNearestDoor()Locks or unlocks the door the player is standing at. The server checks access exactly like the E key.
GetNearbyDoorId()Returns the id of the door the player is standing at, or nil.
GetAllDoors()Returns every door as { id, label, locked, static, leaves, access }. The PIN is never included.
GetDoorCoords(doorId: number)Returns the position of the first door leaf as { x, y, z }, or nil.

02服务端导出

导出说明
AddPlayerAccess(doorId: number, player: number|string)Gives one player access to one door. Saved to the database and synced to every player at once. Returns true, or false plus a reason. true, "unchanged" if the player already had access.
RemovePlayerAccess(doorId: number, player: number|string)Takes the access away again. Saved and synced at once. Returns true, or false plus a reason. true, "unchanged" if there was nothing to remove.
HasPlayerAccess(doorId: number, player: number|string)true if the player is on the door's player list. Job, gang and "everyone" access are not counted.
GetPlayerAccess(doorId: number)Returns a copy of the door's player list, or nil if the door does not exist.
IsReady()false while the doors are still loading from the database after a start, true afterwards.

03事件

名称端说明
agency-doorlock:accessChanged服务端Fired on the server after AddPlayerAccess or RemovePlayerAccess changed a door. Arguments: doorId, identifier, granted (true / false). Listen with AddEventHandler.

+值得了解

Since version 1.1.7 Agency-Doorlock has server exports that let your own resource give one player access to one existing door and take it away again, for example a housing script that hands out house keys. Every change is saved to the database and sent to all online players straight away. Only server code can call these exports, so the player never gets setup or admin rights: your script decides who may hand out a key.

Example from a housing script
Check in your own server code that the player may hand out the key, for example that they own the house. Then call exports['Agency-Doorlock']:AddPlayerAccess(doorId, targetServerId). To take it away again call exports['Agency-Doorlock']:RemovePlayerAccess(doorId, 'ABC12345'). Both return true on success, or false plus a reason.
Which player value to pass
Pass the server id of an online player as a number, and Agency-Doorlock looks up the identifier itself. For players who are offline pass the stored identifier as a string: the citizenid on QBCore and QBox, the identifier on ESX, the license on standalone.
Where the door id comes from
doorId is the number shown in the /adoorlock door list. Doors from Config.StaticDoors live in config.lua and cannot be changed at runtime, so the exports answer false, "static_door" for them.
Reasons for false
not_loaded (the doors are still loading after a start, check IsReady()), door_not_found, static_door, invalid_player, player_offline, player_not_loaded (online, but no character loaded yet) and limit_reached (250 players per door). true, "unchanged" means there was nothing to do.

?常见问题

Does the player who hands out keys need admin rights?

No. Only server scripts can call the exports. Your own script checks who may hand out a key, for example the house owner, and Agency-Doorlock stores and syncs it. /adoorlock stays limited to the permission in Config.SetupPermission.

Do the keys survive a server restart?

Yes. They are written to the agency_doorlock table, into the same player list that the Players field in /adoorlock edits. Admins see them there too.

Does a player with a key still have to enter the PIN?

No. A player on the door's player list opens it directly, the same as a player added in the editor.

How does my script notice a change?

Listen on the server with AddEventHandler('agency-doorlock:accessChanged', function(doorId, identifier, granted) end). It fires after every successful AddPlayerAccess or RemovePlayerAccess.

看完本页仍未解决?接下来由我们的支持团队接手。