-------------------------------------------------------------------------------------------------------------------------------------------- GS_DOORLOCKS API -------------------------------------------------------------------------------------------------------------------------------------------------local DoorLocksAPI =nilifIsResourceStarted('gs_doorlocks') then DoorLocksAPI = 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.
--- Setup locks for banksfunctionSetupLocks()ifnot DoorLocksAPI thenreturnendfor name, data innext, Config.Banks dofor i =1, #data.doors dolocal Added, Door = DoorLocksAPI:AddNewDoor(data.doors[i])if Added thenDevPrint('Added door', Door.Data.doorid, 'to bank', name) Config.Banks[name].doors[i].doorid = Door.Data.dooridelseif Door then Door.fn.Update(data.doors[i]) Config.Banks[name].doors[i].doorid = Door.Data.dooridDevPrint('Updated door', Door.Data.doorid, 'to bank', name)endendendend
Disable Doors
This function will disable lockpicking on the configured doors and locks them shut.
--- Disable doors for a bank--- @param bank stringfunctionDisableDoors(bank)ifnot DoorLocksAPI thenreturnendlocal Doors = Config.Banks[bank].doors or {}for i =1, #Doors dolocal Door = DoorLocksAPI:Door(Doors[i].doorid)if Door then Door.fn.Update({locked =true, canLockpick =false})endendend
Enable Doors
This function is triggered when a robbery is started. It will make sure any open doors are locked shut and enables lockpicking.
--- Enable doors for a bank--- @param bank stringfunctionEnableDoors(bank)ifnot DoorLocksAPI thenreturnendlocal Doors = Config.Banks[bank].doors or {}for i =1, #Doors dolocal Door = DoorLocksAPI:Door(Doors[i].doorid)if Door then Door.fn.Update({locked =true, canLockpick =true})endendend
Notifications
Notification that appears on the right-middle of the screen in vorp framework.
This function is used to check if a player has permission to reset the bank.
--- Check if a player has the permission to reset the bank--- @param source numberfunctionHasResetPermission(source)local User <const>= Core.getUser(source)ifnot User thenreturnfalseendlocal Character <const>= User.getUsedCharacterifnot Character thenreturnfalseendlocal HasPermission =falseifIsPlayerAceAllowed(source, Config.ResetCommand.acePerm) then HasPermission =trueendif Config.ResetCommand.groups thenif Config.ResetCommand.groups[Character.group] then HasPermission =trueendendif Config.ResetCommand.jobs thenif Config.ResetCommand.jobs[Character.job] then HasPermission =trueendendreturn HasPermissionend
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.
This function is used to give money/currency (non item) rewards from a successful vault crack.
--- Add Currency--- @param source number--- @param currency number -- 0 = cash, 1 = gold, 2 = rol--- @param amount number--- @returnboolean | nilfunctionAddCurrency(source,currency,amount)local User <const>= Core.getUser(source)ifnot User thenreturnendlocal Character <const>= User.getUsedCharacterifnot Character thenreturnend Character.addCurrency(currency, amount, 'Bank Robbery')returntrueend
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.
--- Triggered when a bank robbery is started--- @param source number--- @param bank stringfunctionBankRobberyStarted(source,bank)end
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.
--- Triggered when a bank vault explodes--- @param source number--- @param bank stringfunctionBankVaultExplosion(source,bank)end
Job Check
This function checks for on duty players based on the job requirements configured.
--- Check if enough players are on duty--- @param bank stringfunctionCheckJobs(bank)local BankJobs = Config.Banks[bank].requiredJobsifnot BankJobs.enabled thenreturntrueendlocal OnDuty =0for _, playerSrc inipairs(GetPlayers()) dolocal User = Core.getUser(playerSrc)if User thenlocal Character = User.getUsedCharacterif Character thenif BankJobs.jobs[Character.job] then OnDuty = OnDuty +1endendendendreturn OnDuty >= BankJobs.onDutyend