npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@infernus/samp-voice

v0.0.3

Published

A wrapper of the popular SA-MP voice library for samp-node.

Readme

@infernus/samp-voice

npm npm npm bundle size

A wrapper of the popular SA-MP voice library for samp-node.

Getting started

pnpm add @infernus/core @infernus/samp-voice

Example

import { GameMode, Player, PlayerEvent } from "@infernus/core";
import {
  DynamicLocalPlayerStream,
  SampVoice,
  SampVoiceEvent,
  SampVoiceGlobalStream,
  SampVoiceLocalStream,
  SV_INFINITY,
  SV_NULL,
} from "@infernus/samp-voice";

let global_stream: SampVoiceGlobalStream | null = null;
const local_stream = new Map<Player, SampVoiceLocalStream>();

/*
    The public OnPlayerActivationKeyPress and OnPlayerActivationKeyRelease
    are needed in order to redirect the player's audio traffic to the
    corresponding streams when the corresponding keys are pressed.
*/

SampVoiceEvent.onPlayerActivationKeyPress(({ player, keyId, next }) => {
  // Attach player to local stream as speaker if 'B' key is pressed
  if (keyId === 0x42 && local_stream.has(player)) {
    local_stream.get(player)!.attachSpeaker(player);
  }
  // Attach the player to the global stream as a speaker if the 'Z' key is pressed
  if (keyId === 0x5a && global_stream) {
    global_stream.attachSpeaker(player);
  }

  return next();
});

SampVoiceEvent.onPlayerActivationKeyRelease(({ player, keyId, next }) => {
  // Detach the player from the local stream if the 'B' key is released
  if (keyId === 0x42 && local_stream.has(player)) {
    local_stream.get(player)!.detachSpeaker(player);
  }
  // Detach the player from the global stream if the 'Z' key is released
  if (keyId === 0x5a && global_stream) {
    global_stream.detachSpeaker(player);
  }

  return next();
});

PlayerEvent.onConnect(({ player, next }) => {
  // Checking for plugin availability
  if (SampVoice.getVersion(player) === SV_NULL) {
    player.sendClientMessage(-1, "Could not find plugin sampvoice.");
  }
  // Checking for a microphone
  else if (SampVoice.hasMicro(player) === false) {
    player.sendClientMessage(-1, "The microphone could not be found.");
  }
  // Create a local stream with an audibility distance of 40.0, an unlimited number of listeners
  // and the name 'Local' (the name 'Local' will be displayed in red in the players' speakerlist)
  else {
    const stream = new DynamicLocalPlayerStream(
      40.0,
      SV_INFINITY,
      player,
      0xff0000ff,
      "Local",
    );

    if (stream.ptr === SV_NULL) {
      return next();
    }

    local_stream.set(player, stream);

    player.sendClientMessage(
      -1,
      "Press Z to talk to global chat and B to talk to local chat.",
    );

    // Attach the player to the global stream as a listener
    if (global_stream) {
      global_stream.attachListener(player);
    }

    // Assign microphone activation keys to the player
    SampVoice.addKey(player, 0x42);
    SampVoice.addKey(player, 0x5a);
  }

  return next();
});

PlayerEvent.onDisconnect(({ player, next }) => {
  // Removing the player's local stream after disconnecting
  if (local_stream.has(player)) {
    local_stream.get(player)!.detachListener(player);
    local_stream.get(player)!.detachSpeaker(player);
    local_stream.get(player)!.delete();
    local_stream.delete(player);
  }
  return next();
});

GameMode.onInit(({ next }) => {
  // Uncomment the line to enable debug mode
  // SampVoice.debug(true);
  local_stream.clear();
  global_stream = new SampVoiceGlobalStream(0xffff0000, "Global");
  return next();
});

GameMode.onExit(({ next }) => {
  if (global_stream) {
    global_stream.detachAllListeners();
    global_stream.detachAllSpeakers();
    global_stream.delete();
    global_stream = null;
  }
  local_stream.clear();
  return next();
});