Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sure-developer.com/llms.txt

Use this file to discover all available pages before exploring further.

Cooldown

The cooldown module exists on both client and server. The server owns definitions and authoritative state. Clients read synced state, request missing entries, decrement local display values, and ask the server to start or reset cooldowns.
local cooldown = sure.getModule('cooldown')

Server define

Define each cooldown key on the server before clients request it.
server.lua
local cooldown = sure.getModule('cooldown')

cooldown.define('robbery', {
  initialDurationMs = 0,
  durationMs = 15 * 60 * 1000,
  resetAfterZeroTicks = 60
})
initialDurationMs
integer
required
The value assigned to a new position entry the first time it is requested.
durationMs
integer
required
The value used when start(key, position) is called without an explicit duration.
pauseTimerOn
integer
Optional millisecond value where countdowns pause until an external update changes the value.
resetAfterZeroTicks
integer
Optional number of one-second server ticks to wait at zero before resetting the entry to durationMs.

Client read and start

client.lua
local cooldown = sure.getModule('cooldown')
local position = GetEntityCoords(PlayerPedId())

local remainingMs = cooldown.getRemaining('robbery', position)

if remainingMs == 0 then
  cooldown.start('robbery', position)
end

Position keys

Cooldown entries are keyed by key plus a rounded vector3 position. Coordinates are rounded to two decimal places on both client and server to avoid floating point drift.

API by side

define(key, definition)
function
required
Registers a cooldown definition and creates storage for that key.
Client state is for display and convenience. Treat the server module as authoritative for gameplay decisions.