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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.