Sign in to follow this  
State Valentin

Voice chat issue (I can't hear / be heard ?)

Recommended Posts

Hello, i want to know where it's my problem ? I can't make the voice chat work. 

My code it's the following:

 

 

 
mp.events.add('playerJoin', player => {

  mp.players.forEach((_player) => {
      if(player == _player) return false;
      player.disableVoiceTo(_player);
  });

});

mp.events.add('toggleVoice', player => {
  if(player.loggedIn == true) {
    if(player.vars.voice.status == true) {
      player.vars.voice.status = false;
    } 
    else {
      player.vars.voice.status = true;
    }
    player.call('setVoiceToggle', [player.vars.voice.status]);
  }
});

mp.events.add('startTalking', player => {
  if(player.loggedIn == true) {
    if(player.vars.voice.channel == 0)
    {
      mp.players.forEachInRange(player.position, 10, (_player) => { 
          //if(player == _player) return false; for testing.
          if(_player.vars.voice.channel != 0) return false;
          if(_player.vars.voice.status != true) return false;
          player.enableVoiceTo(_player);
          console.log('voice found');
        }
      );
    }
    else if(player.vars.voice.channel == 1) // walkie talkie in the future
    {
      mp.players.forEach((_player) => {
          if(player == _player) return false;
          if(_player.vars.voice.channel != 1) return false;
          if(_player.vars.voice.status != true) return false;
          player.enableVoiceTo(_player);
      });
    }
  }
});

mp.events.add('stopTalking', player => {
  if(player.loggedIn == true) {
    player.voiceListeners.forEach((listener) => {
      player.disableVoiceTo(listener);
    });
  }
});

 

Client-side:

mp.keys.bind(0x58, true, function() {
  if(playerLogged == true) {
    hud.execute(`gui.hud.setMicrophoneStatus(true);`);
    mp.events.callRemote("startTalking");
    player.voiceVolume = 1.0;
  }
});

mp.keys.bind(0x58, false, function() {
  if(playerLogged == true) {
    hud.execute(`gui.hud.setMicrophoneStatus(false);`);
    mp.events.callRemote("stopTalking");
  }
});

 

I have this in my conf.json 

"voice-chat" : true

 

I can't get it, why it's not working ? Other servers are using the voice chat fine. 

the key functions works (the set microphone status changes the color of a font awesome icon)

And i get to 'found' in the server-side when i'm talking near someone. And also the variables are not a problem:

 

    player.vars = {
      voice: {
        status: true,
        channel: 0
      }
    }

 

Edited by State Valentin

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.