예제 #1
0
        private void SetPlayerTalking(string teamSpeakName, bool isTalking)
        {
            Ped         playerPed   = null;
            VoiceClient voiceClient = this.VoiceClients.FirstOrDefault(v => v.TeamSpeakName == teamSpeakName);

            if (voiceClient != null)
            {
                playerPed = voiceClient.Player?.Character;
            }
            else if (teamSpeakName == this.TeamSpeakName)
            {
                playerPed = Game.PlayerPed;

                BaseScript.TriggerEvent(Event.SaltyChat_TalkStateChanged, isTalking);
            }

            if (playerPed != null)
            {
                //API.SetPlayerTalkingOverride(playerPed.Handle, isTalking);

                if (isTalking)
                {
                    _ = playerPed.Tasks.PlayFacialAnimation("face_human@gen_male@base", "mood_talking_normal");
                }
                else
                {
                    _ = playerPed.Tasks.PlayFacialAnimation("face_human@gen_male@base", "mood_normal");
                }
            }
        }
예제 #2
0
        private void OnClientUpdate(string json)
        {
            try
            {
                SaltyShared.VoiceClient sharedVoiceClient = Newtonsoft.Json.JsonConvert.DeserializeObject <SaltyShared.VoiceClient>(json);

                VoiceClient voiceClient = new VoiceClient(
                    sharedVoiceClient.PlayerId,
                    sharedVoiceClient.TeamSpeakName,
                    sharedVoiceClient.VoiceRange,
                    sharedVoiceClient.IsAlive,
                    new CitizenFX.Core.Vector3(
                        sharedVoiceClient.Position.X,
                        sharedVoiceClient.Position.Y,
                        sharedVoiceClient.Position.Z
                        )
                    );

                lock (this._voiceClients)
                {
                    if (this._voiceClients.ContainsKey(voiceClient.ServerId))
                    {
                        this._voiceClients[voiceClient.ServerId] = voiceClient;
                    }
                    else
                    {
                        this._voiceClients.Add(voiceClient.ServerId, voiceClient);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"SaltyChat_UpdateClient: Error while parsing voice client{Environment.NewLine}{ex.ToString()}");
            }
        }
예제 #3
0
        private void SetPlayerTalking(string teamSpeakName, bool isTalking)
        {
            Ped         playerPed   = null;
            VoiceClient voiceClient = this.VoiceClients.FirstOrDefault(v => v.TeamSpeakName == teamSpeakName);

            if (voiceClient != null)
            {
                playerPed = voiceClient.Player?.Character;
            }
            else if (teamSpeakName == this.TeamSpeakName)
            {
                playerPed = Game.PlayerPed;

                BaseScript.TriggerEvent(Event.SaltyChat_TalkStateChanged, isTalking);
            }

            if (playerPed != null)
            {
                API.SetPlayerTalkingOverride(playerPed.Handle, isTalking);

                // Lip sync workaround for OneSync
                if (isTalking)
                {
                    API.PlayFacialAnim(playerPed.Handle, "mic_chatter", "mp_facial");
                }
                else
                {
                    API.PlayFacialAnim(playerPed.Handle, "mood_normal_1", "facials@gen_male@variations@normal");
                }
            }
        }
예제 #4
0
        private void OnClientSync(string json)
        {
            try
            {
                SaltyShared.VoiceClient[] voiceClients = Newtonsoft.Json.JsonConvert.DeserializeObject <SaltyShared.VoiceClient[]>(json);

                lock (this._voiceClients)
                {
                    this._voiceClients.Clear();

                    foreach (SaltyShared.VoiceClient sharedVoiceClient in voiceClients)
                    {
                        VoiceClient voiceClient = new VoiceClient(
                            sharedVoiceClient.PlayerId,
                            sharedVoiceClient.TeamSpeakName,
                            sharedVoiceClient.VoiceRange,
                            sharedVoiceClient.IsAlive,
                            new CitizenFX.Core.Vector3(
                                sharedVoiceClient.Position.X,
                                sharedVoiceClient.Position.Y,
                                sharedVoiceClient.Position.Z
                                )
                            );

                        this._voiceClients.Add(sharedVoiceClient.PlayerId, voiceClient);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"SaltyChat_SyncClients: Error while parsing voice clients{Environment.NewLine}{ex.ToString()}");
            }
        }
예제 #5
0
        private static bool TryGetVoiceClient(ushort handle, out VoiceClient voiceClient)
        {
            lock (VoiceManager._voiceClients)
            {
                if (VoiceManager._voiceClients.TryGetValue(handle, out voiceClient))
                {
                    return(true);
                }
            }

            voiceClient = null;
            return(false);
        }