/// <summary> /// Runs the script event with the given input. /// </summary> /// <param name="prio">The priority to run with.</param> /// <param name="oevt">The details of the script to be ran.</param> /// <returns>The event details after firing.</returns> public void Run(int prio, PlayerChatEventArgs oevt) { PlayerChatScriptEvent evt = (PlayerChatScriptEvent)Duplicate(); evt.Cancelled = oevt.Cancelled; evt.Player = oevt.Player; evt.ChatMode = oevt.ChatMode; evt.Text = oevt.Text; evt.Color = oevt.Color; evt.Call(prio); oevt.ChatMode = evt.ChatMode; oevt.Text = evt.Text; oevt.Color = evt.Color; oevt.Cancelled = evt.Cancelled; }
/// <summary> /// Runs the script event with the given input. /// </summary> /// <param name="prio">The priority to run with.</param> /// <param name="oevt">The details of the script to be ran.</param> /// <returns>The event details after firing.</returns> public void Run(int prio, PlayerChatEventArgs oevt) { PlayerChatScriptEvent evt = (PlayerChatScriptEvent)Duplicate(); evt.Cancelled = oevt.Cancelled; evt.Player = oevt.Player; evt.ChatMode = oevt.ChatMode; evt.Text = oevt.Text; evt.Color = oevt.Color; evt.Call(prio); oevt.ChatMode = evt.ChatMode; oevt.Text = evt.Text; oevt.Color = evt.Color; oevt.Cancelled = evt.Cancelled; }
public static bool PlayerChat(SteamPlayer steamPlayer, ref byte modeByte, ref EChatMode mode, ref Color color, ref string text) { if (text.StartsWith("@") && steamPlayer.isAdmin) { // Send the admin command through. return false; } if (text.StartsWith("/")) { SysConsole.Output(OutputType.CLIENTINFO, "Player [" + steamPlayer.player.name + "] executing player command: " + text); string cmd = text.Substring(1); int splitPos = cmd.IndexOf(' '); string args = ""; if (splitPos > 0) { args = cmd.Substring(splitPos + 1); cmd = cmd.Substring(0, splitPos); } for (int i = 0; i < Instance.PlayerCommands.Count; i++) { if (Instance.PlayerCommands[i].check(steamPlayer.playerID.steamID, cmd, args)) { return true; } } // TODO: if (CVars.g_showinvalidplayercommand.ValueB) ChatManager.manager.channel.send("tellChat", steamPlayer.playerID.steamID, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, steamPlayer.playerID.steamID, (byte)0, Color.red, "Unknown command!"); // Processed a local command. return true; } color = Color.white; if (steamPlayer.isAdmin) { color = Palette.ADMIN; } else if (steamPlayer.isPro) { color = Palette.PRO; } PlayerChatEventArgs evt = new PlayerChatEventArgs(); evt.Player = new PlayerTag(steamPlayer); evt.ChatMode = new TextTag(mode.ToString()); evt.Text = new TextTag(text); evt.Color = new ColorTag(color); UnturnedFreneticEvents.OnPlayerChat.Fire(evt); mode = (EChatMode)Enum.Parse(typeof(EChatMode), evt.ChatMode.ToString().ToUpper()); modeByte = (byte)mode; text = evt.Text.ToString(); color = evt.Color.Internal; return evt.Cancelled; }