public void OnPlayerLoggedIn(IPlayer client, string playerName = "") { var tsName = VoiceManager.GetTeamSpeakName(); VoiceClient voiceClient; if (String.IsNullOrEmpty(playerName)) { voiceClient = new VoiceClient(client, tsName, SharedData.VoiceRanges[0]); } else { var checkname = VoiceManager.VoiceClients.Values.FirstOrDefault(x => x.TeamSpeakName == playerName); if (checkname == null) { voiceClient = new VoiceClient(client, playerName, SharedData.VoiceRanges[0]); } else { voiceClient = new VoiceClient(client, tsName, SharedData.VoiceRanges[0]); } } lock (VoiceManager.VoiceClients) { VoiceManager.VoiceClients.Add(client, voiceClient); } client.Emit(Event.SaltyChat_Initialize, voiceClient.TeamSpeakName, VoiceManager.ServerUniqueIdentifier, VoiceManager.SoundPack, VoiceManager.IngameChannel, VoiceManager.IngameChannelPassword); //Console.WriteLine($"{client} connected"); }
public void OnSetRadioSpeaker(IPlayer player, string toggleString) { bool toggle = String.Equals(toggleString, "true", StringComparison.OrdinalIgnoreCase); VoiceManager.SetRadioSpeaker(player, toggle); //player.SendChatMessage("Speaker", $"The speaker is now {(toggle ? "on" : "off")}."); }
public static void SetRadioSpeaker(IPlayer player, bool toggle) { if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient)) { return; } voiceClient.RadioSpeaker = toggle; }
public void OnPlayerConnected(IPlayer client, string reason) { VoiceClient voiceClient = new VoiceClient(client, VoiceManager.GetTeamSpeakName(), SharedData.VoiceRanges[0]); lock (VoiceManager._voiceClients) { VoiceManager._voiceClients.Add(client, voiceClient); } //Console.WriteLine($"{client} connected"); client.Emit(Event.SaltyChat_Initialize, voiceClient.TeamSpeakName, VoiceManager.ServerUniqueIdentifier, VoiceManager.SoundPack, VoiceManager.IngameChannel, VoiceManager.IngameChannelPassword); }
public static void LeaveRadioChannel(IPlayer player) { if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient)) { return; } foreach (RadioChannel radioChannel in VoiceManager.RadioChannels.Where(r => r.IsMember(voiceClient))) { VoiceManager.LeaveRadioChannel(player, radioChannel.Name); } }
public void OnIsTalking(IPlayer player, bool isTalking) { if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient)) { return; } foreach (VoiceClient client in VoiceManager.VoiceClients) { client.Player.Emit(Event.SaltyChat_IsTalking, player.Id, isTalking); } }
public static void SendingOnRadio(IPlayer player, string radioChannelName, bool isSending) { if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient)) { return; } RadioChannel radioChannel = VoiceManager.GetRadioChannel(radioChannelName, false); if (radioChannel == null || !radioChannel.IsMember(voiceClient)) { return; } radioChannel.Send(voiceClient, isSending); }
public static void LeaveRadioChannel(IPlayer player, string radioChannelName) { if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient)) { return; } RadioChannel radioChannel = VoiceManager.GetRadioChannel(radioChannelName, false); if (radioChannel != null) { radioChannel.RemoveMember(voiceClient); if (radioChannel.Members.Length == 0) { VoiceManager._radioChannels.Remove(radioChannel); } } }
public static void JoinRadioChannel(IPlayer player, string radioChannelName) { if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient)) { return; } foreach (RadioChannel channel in VoiceManager.RadioChannels) { if (channel.IsMember(voiceClient)) { return; } } RadioChannel radioChannel = VoiceManager.GetRadioChannel(radioChannelName, true); radioChannel.AddMember(voiceClient); }
public void OnSetVoiceRange(IPlayer player, int range) { float voiceRange = (float)range; if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient)) { return; } //Console.WriteLine("Set Voice Range for Player"); if (Array.IndexOf(SharedData.VoiceRanges, voiceRange) >= 0) { voiceClient.VoiceRange = voiceRange; foreach (VoiceClient client in VoiceManager.VoiceClients) { client.Player.Emit(Event.SaltyChat_UpdateClient, player.Id, voiceClient.TeamSpeakName, voiceClient.VoiceRange); } } }
public void OnCheckVersion(IPlayer player, string branch, string version) { Console.WriteLine($"Checked Version for Player #{player.Id}"); if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient)) { return; } if (!VoiceManager.IsVersionAccepted(branch, version)) { player.Kick($"[Salty Chat] Required Branch: {VoiceManager.RequiredUpdateBranch} | Required Version: {VoiceManager.MinimumPluginVersion}"); return; } foreach (VoiceClient cl in VoiceManager.VoiceClients) { player.Emit(Event.SaltyChat_UpdateClient, cl.Player.Id, cl.TeamSpeakName, cl.VoiceRange); } Alt.EmitAllClients(Event.SaltyChat_UpdateClient, voiceClient.Player.Id, voiceClient.TeamSpeakName, voiceClient.VoiceRange); }
public void OnLeaveRadioChannel(IPlayer player, string channelName) { VoiceManager.LeaveRadioChannel(player, channelName); //player.SendChatMessage("Radio", $"You left channel \"{channelName}\"."); }
public void OnJoinRadioChannel(IPlayer player, string channelName) { VoiceManager.JoinRadioChannel(player, channelName); //player.SendChatMessage("Radio", $"You joined channel \"{channelName}\"."); }