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 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);
        }
Beispiel #3
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));
        }