Cooldowns

CLIENT & SERVER SIDE

Standalone cooldown system with options for both player-specific and global actions. It provides an efficient way to track and enforce cooldowns for various gameplay mechanics, ensuring consistent behaviour across different frameworks or custom implementations.

Client Functions

check_cooldown

Used to check if something is on cooldown from the client.

Function

local function check_cooldown(cooldown_type, is_global, cb)
    utils.callback.cb('boii_utils:sv:check_cooldown', { cooldown_type = cooldown_type, is_global = is_global }, function(active_cooldown)
        if active_cooldown then
            cb(true)
        else
            cb(false)
        end
    end)
end

exports('check_cooldown', check_cooldown)
utils.cooldowns.check = check_cooldown

Example

--- Define the type
local cooldown_type = 'action_type'
--- Specify if cooldown is global
local is_global = false

--- Utils object
utils.cooldowns.check(cooldown_type, is_global, function(is_on_cooldown)
    if is_on_cooldown then
        print('Player-specific action is currently on cooldown.')
    else
        print('Player-specific action is available.')
    end
end)

--- Direct export
exports.boii_utils:check_cooldown(...)

Server Functions

Last updated