samp.directory
← Scripts et bibliothèques

RaihanPrnwd/omp-vox

Ergonomic Pawn roleplay voice wrapper for SampVoice on open.mp & SA-MP (local proximity with custom range, handy talky with frequency control, phone calls, and global admin voice).

Gamemode★ 0mis à jour il y a 12 heuresMITPawnsampctl
Ouvrir sur GitHub

Installer avec sampctl

sampctl package install RaihanPrnwd/omp-vox

Lance ceci dans le dossier de ton projet. sampctl télécharge le paquet et ce dont il dépend.

Dépend de 2 paquets

README.md

omp-vox

A clean, ergonomic, zero-boilerplate Pawn voice communication library for open.mp and SA-MP roleplay servers, built on top of SampVoice by AmyrAhmady.

omp-vox eliminates manual stream creation, speaker/listener handle routing, and push-to-talk key management boilerplate. It provides high-level APIs for local proximity voice chat, walkie-talkie / handy-talky (HT) radio channels, 1-on-1 private phone calls, and global admin voice broadcasts.


Features

  • Local Proximity Voice: Per-player dynamic local streams (SV_DLSTREAM) with configurable range and distance changes on the fly.
  • Handy Talky (HT) Radio: Decimal frequency tuning (e.g. 104.5 MHz), automatic dynamic channel creation and cleanup, frequency locking, and push-to-talk key binding.
  • 1-on-1 Phone Calls: Point-to-point bi-directional calling with optional local voice pass-through so nearby players can overhear conversations.
  • Global Admin Voice: Global broadcast streams (SV_GSTREAM) for administrative announcements.
  • Zero-Boilerplate Lifecycle: Standard ALS hooking (_ALS_) for automatic stream cleanup on player disconnect and keypress dispatch.
  • Roleplay Callbacks: Granular custom callbacks (OnVox*) for UI notifications, walkie-talkie animation triggers, and call state management.

Prerequisites

  1. SampVoice Server Plugin installed on your open.mp or SA-MP server.
  2. sampvoice.inc placed in your compiler's include path.
  3. Include <sampvoice> before <omp_vox>.

Installation

Via sampctl

sampctl package install RaihanPrnwd/omp-vox

Manual Installation

Download include/omp_vox.inc from this repository and copy it to your server's qawno/include or pawno/include folder:

#include <open.mp>
#include <sampvoice>
#include <omp_vox>

Configuration Defines

Configure these macros before including <omp_vox> to override default behaviors:

MacroDefaultDescription
VOX_DEFAULT_LOCAL_DISTANCE15.0Default proximity hearing radius in units
VOX_DEFAULT_LOCAL_KEY0x42Default push-to-talk key for local chat (B key)
VOX_DEFAULT_HT_KEY0x5ADefault push-to-talk key for HT radio (Z key)
VOX_MAX_HT_CHANNELS128Maximum concurrent active radio frequency channels
VOX_HT_FREQ_MULTIPLIER10Frequency integer hashing multiplier (1 decimal place)
VOX_DISABLE_CALLBACKS(undefined)Define to disable custom OnVox* callback dispatches
VOX_DISABLE_AUTOCLEANUP(undefined)Define to disable automatic OnPlayerConnect / OnPlayerDisconnect hooks
VOX_DISABLE_KEYHOOKS(undefined)Define to disable automatic push-to-talk key event hooks

Quick Start Example

#include <open.mp>
#include <sampvoice>
#include <omp_vox>

public OnPlayerSpawn(playerid)
{
    // Enable proximity voice with 15.0m range
    Vox_SetLocalVoiceEnabled(playerid, true);
    Vox_SetLocalVoiceDistance(playerid, 15.0);

    // Equip Handy Talky tuned to 104.5 MHz
    Vox_SetHTFrequency(playerid, 104.5);
    Vox_SetHTEnabled(playerid, true);
    return 1;
}

// Trigger animations or UI indicators when talking
public OnVoxPlayerLocalTalkStart(playerid)
{
    ApplyAnimation(playerid, "PED", "IDLE_CHAT", 4.1, 1, 1, 1, 1, 1, 1);
    return 1;
}

public OnVoxPlayerLocalTalkStop(playerid)
{
    ClearAnimations(playerid);
    return 1;
}

// Start phone call via roleplay command
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/call", true, 5))
    {
        new targetid = strval(cmdtext[6]);
        Vox_StartPhoneCall(playerid, targetid, true);
        SendClientMessage(playerid, 0x00FF00AA, "Call connected.");
        return 1;
    }
    if (!strcmp(cmdtext, "/hangup", true))
    {
        Vox_EndPhoneCall(playerid);
        SendClientMessage(playerid, 0xFF0000AA, "Call ended.");
        return 1;
    }
    return 0;
}

API Reference

Local Voice

FunctionReturnDescription
Vox_SetLocalVoiceEnabled(playerid, bool:toggle)boolEnables or disables player's proximity voice stream
Vox_IsLocalVoiceEnabled(playerid)boolChecks if player's local voice is enabled
Vox_SetLocalVoiceDistance(playerid, Float:distance)boolUpdates player's local voice hearing range
Float:Vox_GetLocalVoiceDistance(playerid)FloatReturns current hearing distance of player
Vox_SetDefaultLocalDistance(Float:distance)boolUpdates global default local distance
Float:Vox_GetDefaultLocalDistance()FloatReturns global default local distance
Vox_MutePlayerLocal(playerid, bool:mute)boolMutes or unmutes player from speaking locally
Vox_IsPlayerLocalMuted(playerid)boolChecks if player is muted locally
Vox_IsPlayerLocalTalking(playerid)boolChecks if player is currently holding local push-to-talk
Vox_SetLocalKey(key)boolUpdates the push-to-talk key ID for local voice
Vox_GetLocalKey()intReturns current push-to-talk key ID for local voice

Handy Talky (Radio)

FunctionReturnDescription
Vox_SetHTEnabled(playerid, bool:toggle)boolEnables or disables HT radio device
Vox_IsHTEnabled(playerid)boolChecks if HT radio is active
Vox_SetHTFrequency(playerid, Float:frequency)boolSets player's active HT frequency (e.g. 104.5)
Float:Vox_GetHTFrequency(playerid)FloatReturns current active frequency
Vox_SetHTTransmitting(playerid, bool:transmitting)boolStarts or stops audio transmission on frequency
Vox_IsHTTransmitting(playerid)boolChecks if player is transmitting on radio
Vox_LockHTFrequency(Float:frequency, bool:locked)boolLocks channel to prevent garbage collection
Vox_IsHTFrequencyLocked(Float:frequency)boolChecks if frequency channel is locked
Vox_GetHTFrequencyListeners(Float:frequency)intReturns count of active listeners tuned to frequency
Vox_SetHTKey(key)boolUpdates push-to-talk key ID for HT radio
Vox_GetHTKey()intReturns current push-to-talk key ID for HT radio

Phone Call (1-on-1)

FunctionReturnDescription
Vox_StartPhoneCall(callerid, targetid, bool:keepLocalVoice = true)boolEstablishes private voice call between two players
Vox_EndPhoneCall(playerid)boolTerminates active call for player and partner
Vox_IsInPhoneCall(playerid)boolChecks if player is currently in a call
Vox_GetPhoneCallPartner(playerid)intReturns partner player ID or INVALID_PLAYER_ID
Vox_SetPhoneCallMuted(playerid, bool:mute)boolMutes or unmutes player's microphone in call
Vox_IsPhoneCallMuted(playerid)boolChecks if player's phone transmission is muted

Global Admin Voice

FunctionReturnDescription
Vox_SetAdminVoiceEnabled(playerid, bool:toggle)boolGrants or revokes admin broadcast permissions
Vox_IsAdminVoiceEnabled(playerid)boolChecks if player has admin voice enabled
Vox_SetAdminVoiceMode(playerid, bool:broadcastActive)boolStarts or stops global voice transmission
Vox_IsAdminVoiceBroadcasting(playerid)boolChecks if player is currently broadcasting
Vox_MutePlayerGlobal(playerid, bool:mute)boolMutes or unmutes player from hearing global broadcasts
Vox_IsPlayerGlobalMuted(playerid)boolChecks if player is muted from global broadcasts

Callbacks

CallbackDescription
OnVoxPlayerLocalTalkStart(playerid)Called when player presses local push-to-talk key
OnVoxPlayerLocalTalkStop(playerid)Called when player releases local push-to-talk key
OnVoxLocalDistanceChanged(playerid, Float:oldDistance, Float:newDistance)Called when player's local voice distance changes
OnVoxHTFrequencyChanged(playerid, Float:oldFreq, Float:newFreq)Called when player tunes to a different frequency
OnVoxHTTransmitStart(playerid, Float:frequency)Called when player starts radio transmission
OnVoxHTTransmitStop(playerid, Float:frequency)Called when player stops radio transmission
OnVoxPhoneCallStarted(callerid, targetid)Called when phone call connects
OnVoxPhoneCallEnded(playerid, partnerid)Called when phone call disconnects
OnVoxAdminVoiceStart(playerid)Called when admin begins broadcasting
OnVoxAdminVoiceStop(playerid)Called when admin ends broadcasting

License

This project is licensed under the MIT License.

includelibraryopenmppawnradioroleplaysa-mpsampsampvoicevoice-chatwalkie-talkie

Cette page est construite à partir de ce que GitHub publie sur le dépôt. samp.directory n’héberge pas le code. Signaler un problème avec cette fiche

RaihanPrnwd/omp-vox : Gamemode SA-MP | samp.directory