public static void SetPlayerSendingOnRadioChannel(GTANetworkAPI.Client client, string radioChannel, bool isSending) { if (!Voice.RadioChannels.ContainsKey(radioChannel) || !Voice.RadioChannels[radioChannel].Contains(client)) { return; } if (isSending && !Voice.PlayersTalkingOnRadioChannels[radioChannel].Contains(client)) { Voice.PlayersTalkingOnRadioChannels[radioChannel].Add(client); foreach (GTANetworkAPI.Client radioClient in Voice.RadioChannels[radioChannel]) { radioClient.TriggerEvent(SaltyShared.Event.Voice_TalkingOnRadio, client.GetSharedData(SaltyShared.SharedData.Voice_TeamSpeakName), true); } } else if (!isSending && Voice.PlayersTalkingOnRadioChannels[radioChannel].Contains(client)) { Voice.PlayersTalkingOnRadioChannels[radioChannel].Remove(client); foreach (GTANetworkAPI.Client radioClient in Voice.RadioChannels[radioChannel]) { radioClient.TriggerEvent(SaltyShared.Event.Voice_TalkingOnRadio, client.GetSharedData(SaltyShared.SharedData.Voice_TeamSpeakName), false); } } }
/// <summary> /// Removes player from a specific radio channel /// </summary> /// <param name="client"></param> /// <param name="radioChannel"></param> public static void RemovePlayerRadioChannel(GTANetworkAPI.Client client, string radioChannel) { if (Voice.PlayersTalkingOnRadioChannels.ContainsKey(radioChannel) && Voice.PlayersTalkingOnRadioChannels[radioChannel].Contains(client)) { Voice.PlayersTalkingOnRadioChannels[radioChannel].Remove(client); if (Voice.PlayersTalkingOnRadioChannels[radioChannel].Count == 0) { Voice.PlayersTalkingOnRadioChannels.Remove(radioChannel); } foreach (GTANetworkAPI.Client radioClient in Voice.RadioChannels[radioChannel]) { radioClient.TriggerEvent(SaltyShared.Event.Voice_TalkingOnRadio, client.GetSharedData(SaltyShared.SharedData.Voice_TeamSpeakName), false); } } if (Voice.RadioChannels.ContainsKey(radioChannel) && Voice.RadioChannels[radioChannel].Contains(client)) { Voice.RadioChannels[radioChannel].Remove(client); if (Voice.RadioChannels[radioChannel].Count == 0) { Voice.RadioChannels.Remove(radioChannel); Voice.PlayersTalkingOnRadioChannels.Remove(radioChannel); } } }