public void OnSetRadioSpeaker(GTANetworkAPI.Client 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(GTANetworkAPI.Client player, bool toggle) { if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient)) { return; } voiceClient.RadioSpeaker = toggle; }
private void SetPlayerRadioSpeaker(int netId, bool toggle) { Player player = this.Players[netId]; if (!VoiceManager._voiceClients.TryGetValue(player, out VoiceClient voiceClient)) { return; } VoiceManager.SetRadioSpeaker(voiceClient, toggle); }
public void OnPlayerConnected(GTANetworkAPI.Client client) { VoiceClient voiceClient = new VoiceClient(client, VoiceManager.GetTeamSpeakName(), SaltyShared.SharedData.VoiceRanges[1]); lock (VoiceManager._voiceClients) { VoiceManager._voiceClients.Add(client, voiceClient); } client.TriggerEvent(SaltyShared.Event.SaltyChat_Initialize, VoiceManager.ServerUniqueIdentifier, VoiceManager.RequiredUpdateBranch, VoiceManager.MinimumPluginVersion, VoiceManager.SoundPack, VoiceManager.IngameChannel, VoiceManager.IngameChannelPassword, voiceClient.TeamSpeakName); }
private void RemovePlayerRadioChannel(int netId, string radioChannelName) { Player player = this.Players[netId]; if (!VoiceManager._voiceClients.TryGetValue(player, out VoiceClient voiceClient)) { return; } VoiceManager.LeaveRadioChannel(voiceClient, radioChannelName); }
private void SetPlayerRadioChannel(int netId, string radioChannelName, bool isPrimary) { Player player = this.Players[netId]; if (!VoiceManager._voiceClients.TryGetValue(player, out VoiceClient voiceClient)) { return; } VoiceManager.JoinRadioChannel(voiceClient, radioChannelName, isPrimary); }
private void OnLeaveRadioChannel(Player player, string[] args) { if (args.Length < 1) { player.SendChatMessage("Usage", "/leaveradio {radioChannelName}"); return; } VoiceManager.LeaveRadioChannel(player, args[0]); player.SendChatMessage("Radio", $"You left channel \"{args[0]}\"."); }
public static void LeaveRadioChannel(GTANetworkAPI.Client 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(GTANetworkAPI.Client player, bool isTalking) { if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient)) { return; } foreach (VoiceClient client in VoiceManager.VoiceClients) { client.Player.TriggerEvent(SaltyShared.Event.SaltyChat_IsTalking, player.Handle.Value, isTalking); } }
private void OnJoinSecondaryRadioChannel(Player player, string[] args) { if (args.Length < 1) { player.SendChatMessage("Usage", "/joinsecradio {radioChannelName}"); return; } VoiceManager.JoinRadioChannel(player, args[0], false); player.SendChatMessage("Radio", $"You joined secondary channel \"{args[0]}\"."); }
private void OnCheckVersion([FromSource] Player player, string updateChannel, string version) { if (!VoiceManager._voiceClients.TryGetValue(player, out VoiceClient client)) { return; } if (!VoiceManager.IsVersionAccepted(updateChannel, version)) { player.Drop($"[Salty Chat] Required Branch: {VoiceManager.RequiredUpdateBranch} | Required Version: {VoiceManager.MinimumPluginVersion}"); return; } }
private void OnSetRadioSpeaker(Player player, string[] args) { if (args.Length < 1) { player.SendChatMessage("Usage", "/speaker {true/false}"); return; } bool toggle = String.Equals(args[0], "true", StringComparison.OrdinalIgnoreCase); VoiceManager.SetRadioSpeaker(player, toggle); player.SendChatMessage("Speaker", $"The speaker is now {(toggle ? "on" : "off")}."); }
public static void JoinRadioChannel(VoiceClient voiceClient, string radioChannelName, bool isPrimary) { foreach (RadioChannel channel in VoiceManager.RadioChannels) { if (channel.Members.Any(v => v.VoiceClient == voiceClient && v.IsPrimary == isPrimary)) { return; } } RadioChannel radioChannel = VoiceManager.GetRadioChannel(radioChannelName, true); radioChannel.AddMember(voiceClient, isPrimary); }
private void OnJoinRadioChannel([FromSource] Player player, string radioChannelName, bool isPrimary) { if (!VoiceManager._voiceClients.TryGetValue(player, out VoiceClient voiceClient)) { return; } VoiceManager.LeaveRadioChannel(voiceClient, isPrimary); if (!String.IsNullOrEmpty(radioChannelName)) { VoiceManager.JoinRadioChannel(voiceClient, radioChannelName, isPrimary); } }
public static void LeaveRadioChannel(VoiceClient voiceClient, bool primary) { foreach (RadioChannelMember membership in VoiceManager.GetPlayerRadioChannelMembership(voiceClient).Where(m => m.IsPrimary == primary)) { membership.RadioChannel.RemoveMember(voiceClient); if (membership.RadioChannel.Members.Length == 0) { lock (VoiceManager._radioChannels) { VoiceManager._radioChannels.Remove(membership.RadioChannel); } } } }
public static void LeaveRadioChannel(VoiceClient voiceClient, string radioChannelName) { foreach (RadioChannelMember membership in VoiceManager.GetPlayerRadioChannelMembership(voiceClient).Where(m => m.RadioChannel.Name == radioChannelName)) { membership.RadioChannel.RemoveMember(voiceClient); if (membership.RadioChannel.Members.Length == 0) { lock (VoiceManager._radioChannels) { VoiceManager._radioChannels.Remove(membership.RadioChannel); } } } }
private void OnSendingOnRadio([FromSource] Player player, string radioChannelName, bool isSending) { if (!VoiceManager._voiceClients.TryGetValue(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 SendingOnRadio(GTANetworkAPI.Client 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); }
private void OnLeaveRadioChannel(Player player, string[] args) { if (args.Length < 1) { player.SendChatMessage("Usage", "/leaveradio {radioChannelName}"); return; } if (!VoiceManager._voiceClients.TryGetValue(player, out VoiceClient voiceClient)) { return; } VoiceManager.LeaveRadioChannel(voiceClient, args[0]); player.SendChatMessage("Radio", $"You left channel \"{args[0]}\"."); }
public void OnSetVoiceRange(GTANetworkAPI.Client player, float voiceRange) { if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient)) { return; } if (Array.IndexOf(SaltyShared.SharedData.VoiceRanges, voiceRange) >= 0) { voiceClient.VoiceRange = voiceRange; foreach (VoiceClient client in VoiceManager.VoiceClients) { client.Player.TriggerEvent(SaltyShared.Event.SaltyChat_UpdateClient, player.Handle.Value, voiceClient.TeamSpeakName, voiceClient.VoiceRange); } } }
private void OnInitialize([FromSource] Player player) { if (!VoiceManager.Enabled) { return; } VoiceClient voiceClient; lock (VoiceManager._voiceClients) { voiceClient = new VoiceClient(player, VoiceManager.GetTeamSpeakName(), SharedData.VoiceRanges[1]); VoiceManager._voiceClients.Add(player, voiceClient); } player.TriggerEvent(Event.SaltyChat_Initialize, voiceClient.TeamSpeakName, VoiceManager.ServerUniqueIdentifier, VoiceManager.SoundPack, VoiceManager.IngameChannel, VoiceManager.IngameChannelPassword); }
public static void JoinRadioChannel(GTANetworkAPI.Client 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 static void LeaveRadioChannel(Player player, string radioChannelName) { if (!VoiceManager._voiceClients.TryGetValue(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); } } }
private void OnInitialize([FromSource] Player player) { if (!VoiceManager.Enabled) { return; } VoiceClient voiceClient; lock (VoiceManager._voiceClients) { voiceClient = new VoiceClient(player, VoiceManager.GetTeamSpeakName(), SharedData.VoiceRanges[1], true); if (VoiceManager._voiceClients.ContainsKey(player)) { VoiceManager._voiceClients[player] = voiceClient; } else { VoiceManager._voiceClients.Add(player, voiceClient); } } player.TriggerEvent(Event.SaltyChat_Initialize, voiceClient.TeamSpeakName, VoiceManager.RadioTowers); Vector3 voiceClientPosition = voiceClient.Player.Character != null ? voiceClient.Player.Character.Position : new Vector3(0.0f, 0.0f, 0.0f); string clientJson = JsonConvert.SerializeObject(new SaltyShared.VoiceClient(voiceClient.Player.GetServerId(), voiceClient.TeamSpeakName, voiceClient.VoiceRange, true, new Position(voiceClientPosition.X, voiceClientPosition.Y, voiceClientPosition.Z))); List <SaltyShared.VoiceClient> voiceClients = new List <SaltyShared.VoiceClient>(); foreach (VoiceClient client in VoiceManager.VoiceClients.Where(c => c.Player != player)) { Vector3 clientPosition = client.Player.Character != null ? client.Player.Character.Position : new Vector3(0.0f, 0.0f, 0.0f); voiceClients.Add(new SaltyShared.VoiceClient(client.Player.GetServerId(), client.TeamSpeakName, client.VoiceRange, client.IsAlive, new Position(clientPosition.X, clientPosition.Y, clientPosition.Z))); client.Player.TriggerEvent(Event.SaltyChat_UpdateClient, clientJson); } player.TriggerEvent(Event.SaltyChat_SyncClients, JsonConvert.SerializeObject(voiceClients)); }
private void OnCheckVersion(GTANetworkAPI.Client player, string branch, string version) { 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.TriggerEvent(SaltyShared.Event.SaltyChat_UpdateClient, cl.Player.Handle.Value, cl.TeamSpeakName, cl.VoiceRange); cl.Player.TriggerEvent(SaltyShared.Event.SaltyChat_UpdateClient, voiceClient.Player.Handle.Value, voiceClient.TeamSpeakName, voiceClient.VoiceRange); } player.TriggerEvent(SaltyShared.Event.SaltyChat_UpdateRadioTowers, Newtonsoft.Json.JsonConvert.SerializeObject(VoiceManager.RadioTowers)); }
private void OnCheckVersion([FromSource] Player player, string updateChannel, string version) { if (!VoiceManager._voiceClients.TryGetValue(player, out VoiceClient client)) { return; } if (!VoiceManager.IsVersionAccepted(updateChannel, version)) { player.Drop($"[Salty Chat] Required Branch: {VoiceManager.RequiredUpdateBranch} | Required Version: {VoiceManager.MinimumPluginVersion}"); return; } foreach (VoiceClient voiceClient in VoiceManager._voiceClients.Values.ToArray().Where(c => c.Player != player)) { player.TriggerEvent(Event.SaltyChat_UpdateClient, voiceClient.Player.Handle, voiceClient.TeamSpeakName, voiceClient.VoiceRange); voiceClient.Player.TriggerEvent(Event.SaltyChat_UpdateClient, player.Handle, client.TeamSpeakName, client.VoiceRange); } player.TriggerEvent(Event.SaltyChat_UpdateRadioTowers, VoiceManager.RadioTowers); }
public void OnLeaveRadioChannel(GTANetworkAPI.Client player, string channelName) { VoiceManager.LeaveRadioChannel(player, channelName); player.SendChatMessage("Radio", $"You left channel \"{channelName}\"."); }
private void SetPlayerRadioSpeaker(int netId, bool toggle) { Player player = this.Players[netId]; VoiceManager.SetRadioSpeaker(player, toggle); }
private void SetPlayerRadioChannel(int netId, string radioChannelName, bool isPrimary) { Player player = this.Players[netId]; VoiceManager.JoinRadioChannel(player, radioChannelName, isPrimary); }
private void RemovePlayerRadioChannel(int netId, string radioChannelName) { Player player = this.Players[netId]; VoiceManager.LeaveRadioChannel(player, radioChannelName); }