Skip to Content
ResourcesMapmanagerEventsgetMapDirectives: Register and Clean Up a Map Directive
Report an error
Open in ChatGPTOpen in Claude

Register a mapmanager directive

Context: client-side mapmanager callback. The event supplies an add function whose contract is add(name, create, remove). A one-argument anonymous callback is not the registration shape used by the reviewed mapmanager implementation.

Define a harmless map marker

Start mapmanager and load this consumer as client.lua before a map using the directive is processed:

AddEventHandler('getMapDirectives', function(add) add('lab_marker', function(state, label) return function(opts) if type(opts) ~= 'table' or type(opts.x) ~= 'number' or type(opts.y) ~= 'number' or type(opts.z) ~= 'number' then return end local blip = AddBlipForCoord(opts.x, opts.y, opts.z) SetBlipSprite(blip, 1) state.add('blip', blip) end end, function(state, arg) if state.blip and DoesBlipExist(state.blip) then RemoveBlip(state.blip) end end) end)

The create callback receives per-directive state and the directive argument, then returns a function receiving options. The remove callback receives the retained state for cleanup. A map file interpreted by mapmanager can use the registered directive like this:

lab_marker 'Study point' { x = 0.0, y = 0.0, z = 75.0 }

This coordinate is a reproducible test location, not a recommendation for player spawning. The example creates a local map blip; it does not create a world mesh or server entity. Start a test map, confirm one marker, stop it and confirm the marker disappears. Repeat to catch stale-handle or duplicate-registration mistakes.

The mapmanager implementation  demonstrates the contract and state.add lifecycle. For actual resource/map setup, see mapmanager; for engine versus provider hooks, see stock events.