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.

--- 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

add_cooldown

Use the following to add a cooldown, you can specfiy if this should be specific to the player or global (server wide).

--- Specify unique id
local cooldown_id = 'id1234'
--- Specify cooldown timein seconds (s)
local cooldown_time = 30
--- Specify if is global if false cooldowns are attached to players source
local is_global = false

--- Utils object
utils.cooldowns.add(source, cooldown_id, cooldown_time, is_global)

--- Direct export
exports.boii_utils:add_cooldown(source, cooldown_id, cooldown_time, is_global)

check_cooldown

Use the following to check the current status of a cooldown.

--- Specify unique id
local cooldown_id = 'id1234'
--- Specify if is global if false we check cooldowns attached to players source
local is_global = false

--- Utils object
utils.cooldowns.check(source, cooldown_id, is_global)

--- Direct export
exports.boii_utils:check_cooldown(source, cooldown_id, is_global)

clear_cooldown

Use the following to clear a specific cooldown.

--- Specify unique id
local cooldown_id = 'id1234'
--- Specify if is global if false we check cooldowns attached to players source
local is_global = false

--- Utils object
utils.cooldowns.clear(cooldown_id, is_global)

--- Direct export
exports.boii_utils:clear_cooldown(cooldown_id, is_global)

clear_resource_cooldowns

Use the following to clear all cooldowns attached to a resource.

--- Specify resource name
local resource_name = 'your_resource'

--- Utils object
utils.cooldowns.clear_reosurce_cooldowns(resource_name)

--- Direct export
exports.boii_utils:clear_reosurce_cooldowns(resource_name)

Last updated