-------------------------------------------------------------------------------------------------------------------------------------------- GS_DOORLOCKS API -------------------------------------------------------------------------------------------------------------------------------------------------localDoorLocksAPI=nilifIsResourceStarted('gs_doorlocks') thenDoorLocksAPI=exports.gs_doorlocks:GetAPI()elseDevPrint('gs_doorlocks not started or doesnt exist.')end
Setup Locks
This function is triggered on resource startup to create the doors and lock them.
Disable Doors
This function will disable lockpicking on the configured doors and locks them shut.
Enable Doors
This function is triggered when a robbery is started. It will make sure any open doors are locked shut and enables lockpicking.
Notifications
Notification that appears on the right-middle of the screen in vorp framework.
Permission
This function is used to check if a player has permission to reset the bank.
Remove Item
The function is used to remove the explosive device from a players inventory. If not useing any item you can just return true here.
This is configured for vorp_inventory. You can modify to use whatever inventory system you use.
Add Item
This function is used to add non currency rewards from a successful vault crack .
This is configured for vorp_inventory. You can modify to use whatever inventory system you use.
Add Currency
This function is used to give money/currency (non item) rewards from a successful vault crack.
Robbery Started
This function is triggered when a robbery is started. You can use this to trigger a police notification with whatever resource you use on your server.
Vault Explosion
This function is triggered when the main vault door has been opened. You can use this to trigger a police notification with whatever resource you use on your server.
Job Check
This function checks for on duty players based on the job requirements configured.
--- Setup locks for banks
function SetupLocks()
if not DoorLocksAPI then return end
for name, data in next, Config.Banks do
for i = 1, #data.doors do
local Added, Door = DoorLocksAPI:AddNewDoor(data.doors[i])
if Added then
DevPrint('Added door', Door.Data.doorid, 'to bank', name)
Config.Banks[name].doors[i].doorid = Door.Data.doorid
elseif Door then
Door.fn.Update(data.doors[i])
Config.Banks[name].doors[i].doorid = Door.Data.doorid
DevPrint('Updated door', Door.Data.doorid, 'to bank', name)
end
end
end
end
--- Disable doors for a bank
--- @param bank string
function DisableDoors(bank)
if not DoorLocksAPI then return end
local Doors = Config.Banks[bank].doors or {}
for i = 1, #Doors do
local Door = DoorLocksAPI:Door(Doors[i].doorid)
if Door then
Door.fn.Update({locked = true, canLockpick = false})
end
end
end
--- Enable doors for a bank
--- @param bank string
function EnableDoors(bank)
if not DoorLocksAPI then return end
local Doors = Config.Banks[bank].doors or {}
for i = 1, #Doors do
local Door = DoorLocksAPI:Door(Doors[i].doorid)
if Door then
Door.fn.Update({locked = true, canLockpick = true})
end
end
end
--- Alert (right middle)
--- @param message string
--- @param mType string
function Notify(message, mType)
Core.NotifyAvanced(message, 'BLIPS', 'blip_proc_bank', (mType == 'error' and 'COLOR_RED' or 'COLOR_GREEN'), 1500)
end
--- Check if a player has the permission to reset the bank
--- @param source number
function HasResetPermission(source)
local User <const> = Core.getUser(source)
if not User then return false end
local Character <const> = User.getUsedCharacter
if not Character then return false end
local HasPermission = false
if IsPlayerAceAllowed(source, Config.ResetCommand.acePerm) then
HasPermission = true
end
if Config.ResetCommand.groups then
if Config.ResetCommand.groups[Character.group] then
HasPermission = true
end
end
if Config.ResetCommand.jobs then
if Config.ResetCommand.jobs[Character.job] then
HasPermission = true
end
end
return HasPermission
end
--- Remove Inventory Item
--- @param source number
--- @param item string
--- @return boolean | nil
function RemoveItem(source, item)
local hasItem = exports.vorp_inventory:getItemByName(source, item)
if hasItem then
return exports.vorp_inventory:subItemById(source, hasItem.id, nil, false, 1)
end
return false
end
--- Add Inventory Item
--- @param source number
--- @param item string
--- @param amount number
--- @return boolean | nil
function AddItem(source, item, amount)
return exports.vorp_inventory:addItem(source, item, amount)
end
--- Add Currency
--- @param source number
--- @param currency number -- 0 = cash, 1 = gold, 2 = rol
--- @param amount number
--- @return boolean | nil
function AddCurrency(source, currency, amount)
local User <const> = Core.getUser(source)
if not User then return end
local Character <const> = User.getUsedCharacter
if not Character then return end
Character.addCurrency(currency, amount, 'Bank Robbery')
return true
end
--- Triggered when a bank robbery is started
--- @param source number
--- @param bank string
function BankRobberyStarted(source, bank)
end
--- Triggered when a bank vault explodes
--- @param source number
--- @param bank string
function BankVaultExplosion(source, bank)
end
--- Check if enough players are on duty
--- @param bank string
function CheckJobs(bank)
local BankJobs = Config.Banks[bank].requiredJobs
if not BankJobs.enabled then return true end
local OnDuty = 0
for _, playerSrc in ipairs(GetPlayers()) do
local User = Core.getUser(playerSrc)
if User then
local Character = User.getUsedCharacter
if Character then
if BankJobs.jobs[Character.job] then
OnDuty = OnDuty + 1
end
end
end
end
return OnDuty >= BankJobs.onDuty
end