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

            voiceClient.RadioSpeaker = toggle;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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]}\".");
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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]}\".");
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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")}.");
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
                    }
                }
            }
        }
Ejemplo n.º 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);
                    }
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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]}\".");
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 27
0
        public void OnLeaveRadioChannel(GTANetworkAPI.Client player, string channelName)
        {
            VoiceManager.LeaveRadioChannel(player, channelName);

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

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

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

            VoiceManager.LeaveRadioChannel(player, radioChannelName);
        }