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

            voiceClient.RadioSpeaker = toggle;
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
                }
            }
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
                }
            }
        }
예제 #11
0
        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);
        }
예제 #12
0
        public void OnLeaveRadioChannel(IPlayer player, string channelName)
        {
            VoiceManager.LeaveRadioChannel(player, channelName);

            //player.SendChatMessage("Radio", $"You left channel \"{channelName}\".");
        }
예제 #13
0
        public void OnJoinRadioChannel(IPlayer player, string channelName)
        {
            VoiceManager.JoinRadioChannel(player, channelName);

            //player.SendChatMessage("Radio", $"You joined channel \"{channelName}\".");
        }