how to use

Basic Example (Client.lua)

local QBCore = exports['qb-core']:GetCoreObject()

Config = Config or {}
Config.Crime          = 'robbery:fleeca' -- any unique string key (ex: 'store:24', 'vangelico:main')
Config.CooldownTimer  = 120 -- minutes

local function Notify(msg, ntype)
    if GetResourceState('ox_lib') == 'started' and lib and lib.notify then
        lib.notify({ description = msg, type = ntype or 'inform' })
    else
        QBCore.Functions.Notify(msg, ntype or 'primary')
    end
end

-- Your heist start function (adjust to match your script)
local function StartHeist()
    -- Start your heist logic here
end

-- Option A: ox_lib callback (recommended)
CreateThread(function()
    local ready, remainingMin = lib.callback.await('watari_cooldown:check', false, Config.Crime)

    if ready then
        StartHeist()
        exports['watari_cooldown']:setCrimeCooldown(Config.Crime, Config.CooldownTimer)
        Notify('Cooldown has been initiated', 'success')
    else
        Notify(('Cooldown is active, ends in %s minutes'):format(tostring(remainingMin)), 'error')
    end
end)

-- Option B: client export (same result)
-- CreateThread(function()
--     local ready, remainingMin = exports['watari_cooldown']:isCooldownReady(Config.Crime)
--     if ready then
--         StartHeist()
--         exports['watari_cooldown']:setCrimeCooldown(Config.Crime, Config.CooldownTimer)
--         Notify('Cooldown has been initiated', 'success')
--     else
--         Notify(('Cooldown is active, ends in %s minutes'):format(tostring(remainingMin)), 'error')
--     end
-- end)

Server-side Example (Server.lua)

API Reference (Quick)

Client Exports

  • exports['watari_cooldown']:isCooldownReady(crime) -> (ready:boolean, remainingMin:number)

  • exports['watari_cooldown']:setCrimeCooldown(crime, minutes) -> sets cooldown (minutes <= 0 = clear)

Server Exports

  • exports['watari_cooldown']:IsReady(crime) -> (ready:boolean, remainingMin:number)

  • exports['watari_cooldown']:Set(crime, minutes) -> sets cooldown (minutes <= 0 = clear)

ox_lib Callbacks

  • watari_cooldown:check (crime) -> (ready:boolean, remainingMin:number)

  • watari_cooldown:list (includeExpired:boolean)

  • watari_cooldown:getPrivileges

  • watari_cooldown:reset (crime) -- UI reset purpose

UI

  • Command: /cooldownlist (if enabled in config)

  • Open UI:

    • TriggerEvent('watari_cooldown:openUI')

    • TriggerEvent('watari_cooldown:openUI', true) -- showActiveOnly

Last updated