External Registration (addBooth)

Register or update booths at runtime from client or server using the addBooth export.

-- client.lua OR server.lua
exports['sp_music']:addBooth('bean_machine', {
  label = 'Bean Machine',
  icon = 'fa-solid fa-mug-saucer',
  defaultVolume = 55,

  speakers = {
    ['main'] = { label = 'Main Lobby', coords = vec3(-526.38, -247.98, 35.79), distance = 10.0 },
    ['back'] = { label = 'Back Room',  coords = vec3(-519.18, -232.07, 35.89), distance = 10.0 },
  },

  controls = {
    { type = 'target', zone = 'sphere', coords = vec3(-511.85, -255.23, 35.60), radius = 5.0, drawSprite = true },
    -- { type = 'points', coords = vec3(-511.85, -255.23, 35.60), distance = 3.0 },
    -- { type = 'marker', coords = vec3(-511.85, -255.23, 35.60), distance = 3.0, markerType = 1 },
    -- { type = 'zone', zone='sphere', coords = vec3(0,0,0), radius = 2.0 },  
  },
})

Parameters

  • key (string) — unique booth id (e.g., 'bean_machine')

  • data (table) — booth definition:

    • label (string)

    • icon (string)

    • defaultVolume (number 0–100)

    • speakers[key] = { label:string, coords:vec3, distance:number? }

    • groups?: string or string[] or table<string, number> ( Job/Gang Filter )

    • controls[]:

      • type: 'target' | 'points' | 'marker'|'zone'

      • coords:vec3

      • distance?:number (falls back to config.points.defaultDistance or config.markers.defaultDistance)

      • zone?: 'sphere' | 'box' | 'poly' (for target)

      • radius?/width?/height?/markerType?/color?

For ease of use when using targeting or zones use https://coxdocs.dev/ox_lib/Modules/Zones/Shared#zone-creation-script ox_libs zone creation script.

Behavior

  • If the booth already exists, calling addBooth updates it (implementation-dependent).

  • Defaults are pulled from Config when fields are missing.

  • All interaction rendering is delegated to sp_core bridges/modules.

Need a remove/update API? Consider adding require('sp_music.api').removeBooth(key) and require('sp_music.api').updateBooth(key, patch).

Last updated