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
| Export | Arguments | Returns | What |
|---|---|---|---|
ThemeBlip(blip) | blip handle | boolean | Theme 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) | boolean | Leave a blip alone; if it is themed its colour and alpha are put back at once. false themes it again. |
IsExcluded(blip) | handle | boolean | |
SetSpriteRule(sprite, rule?) | sprite id, rule table or nil | boolean ok, string? err | Runtime rule for one icon (fields as Config.Sprites). Wins over config and presets until restart. nil removes it. Applied at once. |
GetSpriteRule(sprite) | sprite id | table? | Copy of the rule in force. |
SetPreset(name) | preset name | boolean | Switch 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 name | number? | 0xRRGGBBAA of one family — colour your own UI to match the map. |
IsActive() | boolean | Is the theme applied on this client right now. | |
Refresh() | true | Re-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
| Export | Arguments | Returns | What |
|---|---|---|---|
SetPreset(name) | preset name | boolean ok, string? err | Switch every player; remembered across restarts. |
GetPreset() | string | The server's preset. | |
SetEnabled(on) | boolean | boolean | Theme 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.
| Event | Side | Arguments | When |
|---|---|---|---|
cc_blips:presetChanged | client | name | The active preset changed on this client. |
cc_blips:activeChanged | client | active (boolean) | The theme was switched on or off on this client (player toggle or admin). |
cc_blips:server:changed | server | what, value, src | what = 'preset', 'enabled' or 'reload'; src = admin id, 0 console, nil export. |
GlobalState
Read-only for clients (only the server can write it):
| Key | Value |
|---|---|
cc_blips:preset | The server's preset name. |
cc_blips:enabled | false when an admin switched the theme off. |
cc_blips:reload | A counter bumped by /blipsadmin reload. |
Hooks (custom/hooks.lua, client)
| Hook | Arguments | Return | What |
|---|---|---|---|
shouldTheme | blip, sprite, colour | false to skip | Called when a blip is first seen. |
colour | blip, sprite, family, colour | a colour or nil | Change the colour about to be set. family is nil for a rule's exact colour. |
onPresetChanged | name | The 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.