public static bool Prefix(Intercom __instance, bool player) { if (EventPlugin.IntercomSpeakingEventPatchDisable) { return(true); } try { if (!__instance._interactRateLimit.CanExecute(true) || Intercom.AdminSpeaking) { return(false); } bool allow = true; if (player) { if (!__instance.ServerAllowToSpeak()) { return(false); } Events.InvokeIntercomSpeak(__instance.gameObject, ref allow); if (allow) { Intercom.host.RequestTransmission(__instance.gameObject); } } else { if (!(Intercom.host.Networkspeaker == __instance.gameObject)) { return(false); } Events.InvokeIntercomSpeak(__instance.gameObject, ref allow); if (allow) { Intercom.host.RequestTransmission(null); } } return(false); } catch (Exception exception) { Log.Error($"IntercomSpeakEvent error: {exception}"); return(true); } }
private static bool Prefix(Intercom __instance, bool player) { try { if (!__instance._interactRateLimit.CanExecute(true) || Intercom.AdminSpeaking) { return(false); } var ev = new IntercomSpeakingEventArgs(player ? API.Features.Player.Get(__instance.gameObject) : null); if (player) { if (!__instance.ServerAllowToSpeak()) { return(false); } Player.OnIntercomSpeaking(ev); if (ev.IsAllowed) { Intercom.host.RequestTransmission(__instance.gameObject); } } else { if (!(Intercom.host.Networkspeaker == __instance.gameObject)) { return(false); } Player.OnIntercomSpeaking(ev); if (ev.IsAllowed) { Intercom.host.RequestTransmission(null); } } return(false); } catch (Exception e) { Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.IntercomSpeaking: {e}\n{e.StackTrace}"); return(true); } }
private static bool Prefix(Intercom __instance, bool player) { if (!__instance._interactRateLimit.CanExecute(true) || Intercom.AdminSpeaking) { return(false); } var ev = new IntercomSpeakingEventArgs(player ? API.Features.Player.Get(__instance.gameObject) : null); if (player) { if (!__instance.ServerAllowToSpeak()) { return(false); } Player.OnIntercomSpeaking(ev); if (ev.IsAllowed) { Intercom.host.RequestTransmission(__instance.gameObject); } } else { if (!(Intercom.host.Networkspeaker == __instance.gameObject)) { return(false); } Player.OnIntercomSpeaking(ev); if (ev.IsAllowed) { Intercom.host.RequestTransmission(null); } } return(false); }