private void _voiceServer_VoiceClientMicrophoneStatusChanged(long connectionId, bool isMuted) { using (var threadSafeList = new AltVPlayerList()) { var p = GetPlayerByConnectionId(threadSafeList.AllPlayers, connectionId); if (p != null) { OnVoiceLogging?.Invoke(LogLevel.Debug, $"{p.Name} Mic muted {isMuted}"); Alt.Emit("PUREVOICE_CLIENT_MICROPHONESTATUS", p, isMuted); } } }
private void _voiceServer_VoiceClientConnected(string clientGUID, string teamspeakID, ushort teamspeakClientID, long connectionID, string clientName, bool micMuted, bool speakersMuted) { using (var threadSafeList = new AltVPlayerList()) { var p = threadSafeList.AllPlayers.FirstOrDefault(c => c.HardwareIdHash.ToString() == clientGUID); if (p != null) { OnVoiceLogging?.Invoke(LogLevel.Debug, String.Format("VoiceConnect {0} {1} {2} {3}", p.Name, teamspeakID, teamspeakClientID, connectionID)); _voiceServer.ConfigureClient(connectionID, p.Name, false); p.SetData("VOICE_ID", connectionID); p.SetData("VOICE_TS_ID", teamspeakClientID); p.SetData("VOICE_TEAMSPEAK_IDENT", teamspeakID); Alt.Emit("PUREVOICE_CLIENT_CONNECTED", p, micMuted, speakersMuted); } } }
public void StartVoice() { VoiceDefaultChannel = GetVoiceSetting <ulong>("voice_defaultchannel", VoiceDefaultChannel); VoiceIngameChannel = GetVoiceSetting <ulong>("voice_ingamechannel", VoiceIngameChannel); VoiceIngameChannelPassword = GetVoiceSetting <string>("voice_ingamechannelpassword", VoiceIngameChannelPassword); VoiceServerGUID = GetVoiceSetting <string>("voice_serverguid", VoiceServerGUID); VoiceServerIP = GetVoiceSetting <string>("voice_server", VoiceServerIP); VoiceServerPort = GetVoiceSetting <int>("voice_port", VoiceServerPort); VoiceServerSecret = GetVoiceSetting <string>("voice_secret", VoiceServerSecret); VoiceClientPort = GetVoiceSetting <int>("voice_clientport", VoiceClientPort); Version.TryParse(GetVoiceSetting <string>("voice_minpluginversion", VoiceServerPluginVersion.ToString()), out VoiceServerPluginVersion); VoiceEnableLipSync = GetVoiceSetting <bool>("voice_enablelipsync", VoiceEnableLipSync); VoiceMaxRange = GetVoiceSetting <float>("voice_maxrange", VoiceMaxRange); VoiceForceVoice = GetVoiceSetting <bool>("voice_forcevoice", VoiceForceVoice); _voiceServer = new PureVoice.Server.VoiceServer(VoiceServerPort, VoiceServerSecret, VoiceServerGUID, VoiceServerPluginVersion, VoiceDefaultChannel, VoiceIngameChannel, VoiceIngameChannelPassword, VoiceEnableLipSync); _voiceServer.VoiceClientConnected += _voiceServer_VoiceClientConnected; _voiceServer.VoiceClientDisconnected += _voiceServer_VoiceClientDisconnected; _voiceServer.VoiceClientOutdated += _voiceServer_VoiceClientOutdated; _voiceServer.VoiceClientMicrophoneStatusChanged += _voiceServer_VoiceClientMicrophoneStatusChanged; _voiceServer.VoiceClientSpeakersStatusChanged += _voiceServer_VoiceClientSpeakersStatusChanged; if (VoiceEnableLipSync) { _voiceServer.VoiceClientTalking += _voiceServer_VoiceClientTalking; } teamspeakTimer = new System.Timers.Timer(200); teamspeakTimer.AutoReset = true; teamspeakTimer.Elapsed += (sender, args) => { try { UpdateTeamspeak(); } catch (System.Threading.ThreadAbortException) { } catch (Exception ex) { OnVoiceLogging?.Invoke(LogLevel.Error, ex.ToString()); } }; teamspeakTimer.Start(); Alt.OnPlayerDead += Alt_OnPlayerDead; Alt.OnPlayerConnect += Alt_OnPlayerConnect; Alt.OnPlayerDisconnect += Alt_OnPlayerDisconnect; }