bridge/voice.lua

-- ==========================================
-- VOICE BRIDGE  (client-side only)
-- ==========================================
-- Wraps voice-system calls so the main script works with
-- different voice resources (pma-voice, saltychat, etc.).
--
-- Default: pma-voice
-- To support a different voice system, change the functions below.
--
-- Global table:  Voice
-- ==========================================

Voice = {}

local hasPmaVoice = GetResourceState('pma-voice') == 'started'

--- Enable listener override — pilot receives audio from all player channels
--- regardless of camera position.
--- @param enabled boolean
function Voice.SetListenerOverride(enabled)
    if not hasPmaVoice then return end
    pcall(function()
        exports['pma-voice']:setListenerOverride(enabled)
    end)
end

--- Reset proximity check back to the default voice behaviour.
function Voice.ResetProximityCheck()
    if not hasPmaVoice then return end
    pcall(function()
        exports['pma-voice']:resetProximityCheck()
    end)
end

--- Override the proximity check function.
--- The callback receives a player index and should return:
---   shouldHear (boolean), distance (number)
--- @param fn function(playerIndex) → boolean, number
function Voice.OverrideProximityCheck(fn)
    if not hasPmaVoice then return end
    pcall(function()
        exports['pma-voice']:overrideProximityCheck(fn)
    end)
end

Last updated