### Install Project Dependencies Source: https://github.com/avarianknight/pma-voice/blob/main/voice-ui/README.md Installs all necessary project dependencies using yarn. ```bash yarn install ``` -------------------------------- ### Set Call Volume Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setCallVolume.md Sets the local player's call channel volume to a value between 0 and 100 percent. Example sets volume to 50 percent. ```lua -- set the call volume to 50 percent exports['pma-voice']:setCallVolume(50) ``` -------------------------------- ### Grant Superadmin Muteply Ace Source: https://github.com/avarianknight/pma-voice/blob/main/README.md Grant the superadmin group the 'muteply' command ace to allow them to mute players. This is an example of access control configuration. ```lua add_ace group.superadmin command.muteply allow; ``` -------------------------------- ### Enable and Disable Voice Properties Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setVoiceProperty.md Use this function to control voice properties. For example, enable the radio by setting 'radioEnabled' to true, or disable radio clicks by setting 'micClicks' to false. ```lua -- Enable the radio exports['pma-voice']:setVoiceProperty('radioEnabled', true) ``` ```lua -- Disable radio clicks exports['pma-voice']:setVoiceProperty('micClicks', false) ``` -------------------------------- ### Get Player Proximity State Source: https://github.com/avarianknight/pma-voice/blob/main/docs/state-getters/stateBagGetters.md Accesses the player's state bag to retrieve proximity information. Replace Player(source) with LocalPlayer if on the client and only targeting the current player. ```lua local plyState = Player(source).state local proximity = plyState.proximity print(proximity.index) -- prints the index of the proximity as seen in Cfg.voiceModes print(proximity.distance) -- prints the distance of the proximity print(proximity.mode) -- prints the mode name of the proximity ``` -------------------------------- ### Get Players In Radio Channel Source: https://github.com/avarianknight/pma-voice/blob/main/docs/server-getters/getPlayersInRadioChannel.md Retrieves a list of all players currently in a specified radio channel. ```APIDOC ## GET /playersInRadioChannel ### Description Gets a list of all of the players in the specified radio channel. ### Method GET ### Endpoint /playersInRadioChannel ### Parameters #### Query Parameters - **radioChannel** (number) - Required - The channel to get all the members of ### Response #### Success Response (200) - **players** (table) - A table where keys are player source IDs and values indicate if the player is talking. ### Request Example ```lua -- this will return all of the current players in radio channel 1 local players = exports['pma-voice']:getPlayersInRadioChannel(1) for source, isTalking in pairs(players) do print((' %s is in radio channel 1, isTalking: %s'):format(GetPlayerName(source), isTalking)) end ``` ``` -------------------------------- ### Get Players in Radio Channel Source: https://github.com/avarianknight/pma-voice/blob/main/docs/server-getters/getPlayersInRadioChannel.md Retrieves a list of players in a specified radio channel. The returned table maps player source IDs to a boolean indicating if they are currently talking. ```lua -- this will return all of the current players in radio channel 1 local players = exports['pma-voice']:getPlayersInRadioChannel(1) for source, isTalking in pairs(players) do print(('%s is in radio channel 1, isTalking: %s'):format(GetPlayerName(source), isTalking)) end ``` -------------------------------- ### Build Project for Production Source: https://github.com/avarianknight/pma-voice/blob/main/voice-ui/README.md Compiles and minifies the project for production deployment. ```bash yarn build ``` -------------------------------- ### Serve Project for Development Source: https://github.com/avarianknight/pma-voice/blob/main/voice-ui/README.md Compiles and hot-reloads the project for development purposes. ```bash yarn serve ``` -------------------------------- ### Add Player to Radio Channel (Lua) Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setRadioChannel.md Use `addPlayerToRadio` as a more readable alternative to `setRadioChannel` for joining a specific channel. Server-side checks may reset the player if the channel is invalid. ```lua -- Joins radio channel 1 exports['pma-voice']:addPlayerToRadio(1) ``` -------------------------------- ### setMicClickOnVolume Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setMicClickOnVolume.md Sets the local player's radio turn on mic click volume. The volume should be a value between 0 and 100 percent. ```APIDOC ## setMicClickOnVolume ### Description Sets the local player's radio turn on mic click volume. ### Parameters #### Path Parameters * **volume** (number) - Required - The volume to change to, between 0 and 100 percent. ### Request Example ```lua -- sets the radio turn on mic click volume to 20 percent exports['pma-voice']:setMicClickOnVolume(20) ``` ``` -------------------------------- ### Handle PMA-Voice Events Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-getters/events.md Use these event handlers to receive player voice mode and radio status. The `settingsCallback` event retrieves registered voice modes. ```lua -- default voice mode is 2 local voiceMode = 2 local voiceModes = {} local usingRadio = false -- sets the current radio state boolean AddEventHandler("pma-voice:radioActive", function(radioTalking) usingRadio = radioTalking end) -- changes the current voice range index AddEventHandler('pma-voice:setTalkingMode', function(newTalkingRange) voiceMode = newTalkingRange end) -- returns registered voice modes from shared.lua's `Cfg.voiceModes` TriggerEvent("pma-voice:settingsCallback", function(voiceSettings) local voiceTable = voiceSettings.voiceModes -- loop through all voice modes and add them to the table -- the percentage is used for the voice mode slider if this was an actual UI for i = 1, #voiceTable do local distance = math.ceil(((i/#voiceTable) * 100)) voiceModes[i] = ("%s"):format(distance) end end) ``` -------------------------------- ### Set Mic Click On Volume Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setMicClickOnVolume.md Sets the radio turn-on mic click volume to a specified percentage. Use values between 0 and 100. ```lua -- sets the radio turn on mic click volume to 20 percent exports['pma-voice']:setMicClickOnVolume(20) ``` -------------------------------- ### Lint and Fix Files Source: https://github.com/avarianknight/pma-voice/blob/main/voice-ui/README.md Lints and automatically fixes code style issues in project files. ```bash yarn lint ``` -------------------------------- ### Set Player Call Channel with setCallChannel Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setCallChannel.md Use `setCallChannel` to join or leave a specific call channel. Passing `0` will remove the player from any active call channel. ```lua -- Joins call channel 1 exports['pma-voice']:setCallChannel(1) ``` ```lua -- This will remove them from the call channel exports['pma-voice']:setCallChannel(0) ``` -------------------------------- ### Add Player to Call Channel with addPlayerToCall Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setCallChannel.md The `addPlayerToCall` function serves as a more readable alias for `setCallChannel` to join a specified call channel. ```lua -- Joins call channel 1 exports['pma-voice']:addPlayerToCall(1) ``` -------------------------------- ### Set Call Channel Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setCallChannel.md Sets the local player's call channel. Joining channel 0 removes the player from any call channel. ```APIDOC ## POST /setCallChannel ### Description Sets the local player's call channel. Use `0` to leave the current channel. ### Method POST ### Endpoint `/setCallChannel` ### Parameters #### Query Parameters - **callChannel** (number) - Required - The call channel to join. `0` to leave. ``` -------------------------------- ### Set Radio Volume Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setRadioVolume.md Sets the local player's radio channel volume to a specified percentage. Ensure the value is between 0 and 100. ```lua -- sets the radio volume to 50 percent exports['pma-voice']:setRadioVolume(50) ``` -------------------------------- ### setMicClickOffVolume Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setMicClickOffVolume.md Sets the local player's radio turn-off mic click volume. The volume should be a value between 0 and 100 percent. ```APIDOC ## setMicClickOffVolume ### Description Sets the local players radio turn off mic click volume ### Parameters #### Path Parameters - **volume** (number) - Required - The volume to change to between 0 - 100 percent ### Request Example ```lua -- sets the radio turn off mic click volume to 20 percent exports['pma-voice']:setMicClickOffVolume(20) ``` ``` -------------------------------- ### Add Player To Call Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setCallChannel.md An alias for `setCallChannel` for easier readability when joining a call channel. ```APIDOC ## POST /addPlayerToCall ### Description An alias for `setCallChannel` to join a specific call channel. ### Method POST ### Endpoint `/addPlayerToCall` ### Parameters #### Query Parameters - **callChannel** (number) - Required - The call channel to join. ``` -------------------------------- ### Set Player Radio Channel (Lua) Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setRadioChannel.md Use `setRadioChannel` to join or leave radio channels. A value of 0 removes the player from all channels. Server-side checks may reset the player if the channel is invalid. ```lua -- Joins radio channel 1 exports['pma-voice']:setRadioChannel(1) ``` ```lua -- This will remove the player from all radio channels exports ['pma-voice']:setRadioChannel(0) ``` -------------------------------- ### Add Player to Radio Channel Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setRadioChannel.md An alternative, more readable function to join a specific radio channel. ```APIDOC ## POST /addPlayerToRadio ### Description Adds the local player to a specified radio channel. This is an alternative to `setRadioChannel`. ### Method POST ### Endpoint /addPlayerToRadio ### Parameters #### Query Parameters - **radioChannel** (number) - Required - The radio channel to join. ``` ```Lua -- Joins radio channel 1 exports['pma-voice']:addPlayerToRadio(1) ``` -------------------------------- ### setPlayerRadio Source: https://github.com/avarianknight/pma-voice/blob/main/docs/server-setters/setPlayerRadio.md Sets the player's radio channel. ```APIDOC ## setPlayerRadio ### Description Sets the players radio channel. ### Method EXPORTS ### Endpoint exports['pma-voice']:setPlayerRadio(source, radioChannel) ### Parameters #### Path Parameters - **source** (Player) - Required - The player to set the radio channel of - **radioChannel** (number) - Required - the radio channel to set the player to ### Request Example ```lua exports['pma-voice']:setPlayerRadio(source, 1) ``` ### Response #### Success Response (200) This function does not return a value. #### Response Example ```lua -- No return value ``` ``` -------------------------------- ### Set Radio Channel Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setRadioChannel.md Sets the local player's radio channel. Joining channel 0 removes the player from all channels. ```APIDOC ## POST /setRadioChannel ### Description Sets the local player's radio channel. ### Method POST ### Endpoint /setRadioChannel ### Parameters #### Query Parameters - **radioChannel** (number) - Required - The radio channel to join. Use 0 to leave all channels. ``` ```Lua -- Joins radio channel 1 exports['pma-voice']:setRadioChannel(1) -- This will remove the player from all radio channels exports ['pma-voice']:setRadioChannel(0) ``` -------------------------------- ### Set Call Volume Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setCallVolume.md Allows you to set the local player's call channel volume. The volume should be a value between 0 and 100. ```APIDOC ## setCallVolume ### Description Sets the local players call channel volume. ### Method exports ### Endpoint pma-voice:setCallVolume ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **callVolume** (number) - Required - The call volume to set to between 0 - 100 percent. ### Request Example ```lua -- set the call volume to 50 percent exports['pma-voice']:setCallVolume(50) ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Set Radio Volume Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setRadioVolume.md Sets the local player's radio channel volume. ```APIDOC ## setRadioVolume ### Description Sets the local players radio channel volume. ### Method EXPORTS ### Endpoint setRadioVolume ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **radioVolume** (number) - Required - The radio volume to set to between 0 - 100 percent. ### Request Example ```lua -- sets the radio volume to 50 percent exports['pma-voice']:setRadioVolume(50) ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Set Player Radio Channel Source: https://github.com/avarianknight/pma-voice/blob/main/docs/server-setters/setPlayerRadio.md Use this function to set a player's radio channel. Requires the player's source ID and the desired radio channel number. ```lua exports['pma-voice']:setPlayerRadio(source, 1) ``` -------------------------------- ### Add Channel Check to Radio Channel Source: https://github.com/avarianknight/pma-voice/blob/main/docs/server-setters/addChannelCheck.md Use this function to add a custom check to a radio channel. The provided function must return a boolean indicating if the player is allowed to join. Ensure the player has the necessary ACE permissions. ```lua -- Example for addChannelCheck -- this always has to return true/false exports['pma-voice']:addChannelCheck(1, function(source) if IsPlayerAceAllowed(source, 'radio.police') then return true end return false end) ``` -------------------------------- ### Set Player Call Channel Source: https://github.com/avarianknight/pma-voice/blob/main/docs/server-setters/setPlayerCall.md Use this function to set the radio channel for a specific player. The first argument is the player's source ID, and the second is the desired call channel number. ```lua exports['pma-voice']:setPlayerCall(source, 1) ``` -------------------------------- ### Set Mic Click Off Volume Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setMicClickOffVolume.md Sets the radio turn-off mic click volume to a specified percentage. The volume should be between 0 and 100. ```lua exports['pma-voice']:setMicClickOffVolume(20) ``` -------------------------------- ### Set Voice Property API Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/setVoiceProperty.md Sets a voice property. Currently used for enabling/disabling radios and radio clicks. ```APIDOC ## setVoiceProperty ### Description Sets the voice property, currently the only use is to enable/disable radios and radio clicks. ### Method EXPORTS ### Endpoint pma-voice:setVoiceProperty ### Parameters #### Path Parameters - **property** (string) - Required - The property to set - **value** (boolean) - Required - The value to set the property to ### Request Example ```lua -- Enable the radio exports['pma-voice']:setVoiceProperty('radioEnabled', true) -- Disable radio clicks exports['pma-voice']:setVoiceProperty('micClicks', false) ``` ### Response #### Success Response (200) No specific response body is detailed, but the action is performed. #### Response Example N/A ``` -------------------------------- ### Set Player Call Channel Source: https://github.com/avarianknight/pma-voice/blob/main/docs/server-setters/setPlayerCall.md Sets the radio call channel for a specific player. ```APIDOC ## setPlayerCall ### Description Sets the players call channel. ### Method EXPORTS ### Endpoint exports['pma-voice']:setPlayerCall(source, callChannel) ### Parameters #### Path Parameters - **source** (player) - Required - The player to set the radio channel of - **callChannel** (number) - Required - the radio channel to set the player to ### Request Example ```lua exports["pma-voice"]:setPlayerCall(source, 1) ``` ### Response #### Success Response (200) This function does not return a value. #### Response Example ```lua -- No explicit return value ``` ``` -------------------------------- ### Remove Player From Call Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/removePlayerFromCall.md Removes the player from the call channel. This is a shortcut for setCallChannel(0). ```lua -- Removes the player from the call channel exports['pma-voice']:removePlayerFromCall() ``` -------------------------------- ### addChannelCheck Source: https://github.com/avarianknight/pma-voice/blob/main/docs/server-setters/addChannelCheck.md Adds a custom check to a radio channel. This function allows developers to define specific conditions that must be met for a player to join a particular radio channel. ```APIDOC ## POST /addChannelCheck ### Description Adds a channel check to radio channels. This function allows you to define a callback that determines if a player is allowed to join a specific radio channel. ### Method POST ### Endpoint /addChannelCheck ### Parameters #### Query Parameters - **channel** (number) - Required - The ID of the radio channel to add the check to. - **function** (function) - Required - A callback function that will be executed when a player attempts to join the channel. This function must return a boolean value: `true` if the player is allowed to join, `false` otherwise. The function receives the player's source ID as an argument. ### Request Example ```lua -- Example for addChannelCheck -- this always has to return true/false exports['pma-voice']:addChannelCheck(1, function(source) if IsPlayerAceAllowed(source, 'radio.police') then return true end return false end) ``` ### Response #### Success Response (200) This endpoint does not return a specific JSON response upon success, but the channel check is registered. #### Response Example N/A ``` -------------------------------- ### Remove Player From Radio Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/removePlayerFromRadio.md Use this function to remove the player from the radio channel. This is equivalent to calling setRadioChannel(0). ```lua -- Removes the player from the radio channel exports['pma-voice']:removePlayerFromRadio() ``` -------------------------------- ### removePlayerFromCall Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/removePlayerFromCall.md Removes the player from the call. This is syntactic sugar for `setCallChannel(0)`. ```APIDOC ## removePlayerFromCall ### Description Removes the player from the call channel. ### Method N/A (Client-side function) ### Endpoint N/A ### Parameters None ### Request Example ```lua exports['pma-voice']:removePlayerFromCall() ``` ### Response N/A (Client-side function) ``` -------------------------------- ### removePlayerFromRadio Source: https://github.com/avarianknight/pma-voice/blob/main/docs/client-setters/removePlayerFromRadio.md Removes the player from the radio channel. This is syntactic sugar for `setRadioChannel(0)`. ```APIDOC ## removePlayerFromRadio ### Description Removes the player from the radio channel. ### NOTE This is just syntactic sugar for `setRadioChannel(0)`. ### Method `exports` (Lua function call) ### Endpoint `pma-voice:removePlayerFromRadio` ### Parameters None ### Request Example ```lua exports['pma-voice']:removePlayerFromRadio() ``` ### Response None (modifies game state) ### Response Example None ``` -------------------------------- ### Remove Channel Check Source: https://github.com/avarianknight/pma-voice/blob/main/docs/server-setters/removeChannelCheck.md Use this function to remove a check from a radio channel. Requires the channel ID as a parameter. ```lua -- Example for Removes exports['pma-voice']:removeChannelCheck(1) ``` -------------------------------- ### Define Disabled Radio States Source: https://github.com/avarianknight/pma-voice/blob/main/README.md Use this enum to check the bitwise state of a player's radio when it is disabled. Ensure you are checking against the correct bitwise flags. ```typescript enum DisabledRadioStates { Enabled = 0, IsDead = 1, IsCuffed = 2, IsPdCuffed = 4, IsUnderWater = 8, DoesntHaveItem = 16, PlayerDisabledRadio = 32, } ``` -------------------------------- ### removeChannelCheck Source: https://github.com/avarianknight/pma-voice/blob/main/docs/server-setters/removeChannelCheck.md Removes a channel check for a radio channel. ```APIDOC ## removeChannelCheck ### Description Removes a channel check for radio channel. ### Parameters * **channel**: The channel to remove the check from. ### Example ```lua -- Example for Removes exports['pma-voice']:removeChannelCheck(1) ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.