Skip to content

Exports, events and hooks

Every export validates its arguments and never throws: a bad call returns false (or nil).

Every export validates its arguments and never throws: a bad call returns false (or nil).

Client exports

ExportArgumentsReturnsWhat
ThemeBlip(blip)blip handlebooleanTheme a blip now instead of on the next pass. false when it is skipped (wrong kind, flashing, excluded, skipped sprite, or the theme is off).
ExcludeBlip(blip, excluded?)handle, boolean (default true)booleanLeave a blip alone; if it is themed its colour and alpha are put back at once. false themes it again.
IsExcluded(blip)handleboolean
SetSpriteRule(sprite, rule?)sprite id, rule table or nilboolean ok, string? errRuntime rule for one icon (fields as Config.Sprites). Wins over config and presets until restart. nil removes it. Applied at once.
GetSpriteRule(sprite)sprite idtable?Copy of the rule in force.
SetPreset(name)preset namebooleanSwitch this client to a preset. The server's next change replaces it.
GetPreset()string?Active preset on this client.
GetPresets(){ {name, label}, ... }Sorted by name.
GetPalette(){ family = colour }Copy of the active palette.
GetColour(family)family namenumber?0xRRGGBBAA of one family — colour your own UI to match the map.
IsActive()booleanIs the theme applied on this client right now.
Refresh()trueRe-apply the theme to every known blip now.
GetStats(){ active, preset, themed, sprites, excluded }For a debug panel.
lua
-- Make a blip and show it themed straight away
local blip = AddBlipForCoord(215.0, -810.0, 30.7)
SetBlipSprite(blip, 357)
SetBlipColour(blip, 3)
BeginTextCommandSetBlipName('STRING'); AddTextComponentSubstringPlayerName('Garage'); EndTextCommandSetBlipName(blip)
if GetResourceState('cc_blips') == 'started' then exports.cc_blips:ThemeBlip(blip) end

-- Your race checkpoint must stay exactly as you drew it
exports.cc_blips:ExcludeBlip(checkpointBlip)

-- Every ATM small and green, whatever script made them
exports.cc_blips:SetSpriteRule(277, { family = 'green', scale = 0.45 })

Set the blip's sprite and name before calling ThemeBlip. cc_blips never changes a sprite.

Server exports

ExportArgumentsReturnsWhat
SetPreset(name)preset nameboolean ok, string? errSwitch every player; remembered across restarts.
GetPreset()stringThe server's preset.
SetEnabled(on)booleanbooleanTheme on / off for everyone; remembered.
IsEnabled()boolean
lua
-- An event night: vivid map from 20:00 to midnight
exports.cc_blips:SetPreset('vivid')
-- later
exports.cc_blips:SetPreset('soft')

Events

All local (AddEventHandler); none are network events, so nothing here can be triggered by a player.

EventSideArgumentsWhen
cc_blips:presetChangedclientnameThe active preset changed on this client.
cc_blips:activeChangedclientactive (boolean)The theme was switched on or off on this client (player toggle or admin).
cc_blips:server:changedserverwhat, value, srcwhat = 'preset', 'enabled' or 'reload'; src = admin id, 0 console, nil export.

GlobalState

Read-only for clients (only the server can write it):

KeyValue
cc_blips:presetThe server's preset name.
cc_blips:enabledfalse when an admin switched the theme off.
cc_blips:reloadA counter bumped by /blipsadmin reload.

Hooks (custom/hooks.lua, client)

HookArgumentsReturnWhat
shouldThemeblip, sprite, colourfalse to skipCalled when a blip is first seen.
colourblip, sprite, family, coloura colour or nilChange the colour about to be set. family is nil for a rule's exact colour.
onPresetChangednameThe active preset changed.

A hook that errors is reported once in F8 and treated as absent, so a mistake in a hook never stops the map from being themed.