예제 #1
0
        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")}.");
        }
예제 #2
0
        public static void SetRadioSpeaker(GTANetworkAPI.Client player, bool toggle)
        {
            if (!VoiceManager.TryGetVoiceClient(player, out VoiceClient voiceClient))
            {
                return;
            }

            voiceClient.RadioSpeaker = toggle;
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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]}\".");
        }
예제 #8
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);
            }
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
        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]}\".");
        }
예제 #11
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;
            }
        }
예제 #12
0
        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")}.");
        }
예제 #13
0
        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);
        }
예제 #14
0
        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);
            }
        }
예제 #15
0
        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);
                    }
                }
            }
        }
예제 #16
0
        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);
                    }
                }
            }
        }
예제 #17
0
        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);
        }
예제 #18
0
        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);
        }
예제 #19
0
        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]}\".");
        }
예제 #20
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);
                }
            }
        }
예제 #21
0
        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);
        }
예제 #22
0
        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);
        }
예제 #23
0
        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);
                }
            }
        }
예제 #24
0
        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));
        }
예제 #25
0
        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));
        }
예제 #26
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;
            }

            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);
        }
예제 #27
0
        public void OnLeaveRadioChannel(GTANetworkAPI.Client player, string channelName)
        {
            VoiceManager.LeaveRadioChannel(player, channelName);

            player.SendChatMessage("Radio", $"You left channel \"{channelName}\".");
        }
예제 #28
0
        private void SetPlayerRadioSpeaker(int netId, bool toggle)
        {
            Player player = this.Players[netId];

            VoiceManager.SetRadioSpeaker(player, toggle);
        }
예제 #29
0
        private void SetPlayerRadioChannel(int netId, string radioChannelName, bool isPrimary)
        {
            Player player = this.Players[netId];

            VoiceManager.JoinRadioChannel(player, radioChannelName, isPrimary);
        }
예제 #30
0
        private void RemovePlayerRadioChannel(int netId, string radioChannelName)
        {
            Player player = this.Players[netId];

            VoiceManager.LeaveRadioChannel(player, radioChannelName);
        }