public KickCommand(Player player, string reason) : this(player.Name, reason) { }
/// <summary> /// This function is used internally. /// It executes all needed handlers when a specific command occures. /// </summary> /// <param name="str"> /// A <see cref="System.String"/> /// </param> /// <param name="cmd"> /// A <see cref="Command"/> /// </param> internal static void Execute(Player player, Command cmd) { foreach (KeyValuePair<string, ClientCommandDelegate> keyval in events) { if (cmd.ToString().StartsWith(keyval.Key)) { if (keyval.Value != null) { keyval.Value(player, cmd); } } } cmd.Execute(player); }
public KickCommand(Player player) : this(player.Name) { }
protected virtual void OnFailure(Player player) { Server.LogDeveloper("Command failed: {0}", Arguments.Join(' ')); }
protected virtual void OnSuccess(Player player) { Server.LogDeveloper("Command successful: {0}", Arguments.Join(' ')); }
protected static void WriteLine(Player player, string text) { Write(player, text + '\n'); }
protected static void WriteLine(Player player, string format, params object[] param) { WriteLine(player, string.Format(format, param)); }
/// <summary> /// Emulates a player calling a command. /// </summary> /// <param name="p"> /// Instance of the player <see cref="Player"/> /// </param> public void FakeCall(Player p) { overrideArguments = true; instance = this; MetaModEngine.dllapiFunctions.ClientCommand(p.Pointer); instance = null; overrideArguments = false; }
protected static void Write(Player player, string text) { if (player == null) { Server.Print(text); } else { player.PrintConsole(text); } }
/// <summary> /// Updates the two dproto variables according to the player. /// </summary> /// <param name="player"> /// The information about this player <see cref="Player"/> /// </param> public static void UpdateCVariables(Player player) { UpdateCVariables(player.Index); }
public virtual void Execute(Player player) { Server.LogDeveloper("Command executed: {0}", Arguments.Join(' ')); OnFailure(player.UserID); }
public void SwearCheck(Player player, Command cmd) { }
void HandleSayExec(Player player, Command command) { // Ommit /exec and execute the following text string exec_string = command.Arguments[1].Split(' ').Shift().Join(' ') + ";"; EvaluateGoldSrc(player, exec_string); }
/// <summary> /// This function evaluates a piece of code and prints the output linewise to the chat of the player /// </summary> /// <param name="p"> /// A player instance <see cref="Player"/> /// </param> /// <param name="code"> /// A command <see cref="System.String"/> /// </param> protected virtual void EvaluateGoldSrc(Player p, string code) { bool result_set; object result; try { Evaluator.Evaluate(code, out result, out result_set); if (result_set) { System.IO.TextWriter tw = new System.IO.StringWriter(); PrettyPrint(tw, result); p.ClientPrintEachLine(tw.ToString()); } } catch (Exception e) { p.ClientPrintEachLine(e.ToString()); } }
public void SendMessage(Player player, float time) { Message.Begin(MessageDestination.OneReliable, Message.GetUserMessageID("TextMsg"), IntPtr.Zero, player.Pointer); Message.WriteByte(4); Message.WriteString("#Game_will_restart_in"); Message.WriteString(time.ToString()); Message.WriteString("SECOND"); Message.End(); Message.Begin(MessageDestination.OneReliable, Message.GetUserMessageID("TextMsg"), IntPtr.Zero, player.Pointer); Message.WriteByte(2); Message.WriteString("#Game_will_restart_in_console"); Message.WriteString(time.ToString()); Message.WriteString("SECOND"); Message.End(); }
public void ClearPlayer(Player player) { if (knifeonly.Bool()) { player.StripUserWeapons(); player.GiveItem("weapon_knife"); player.SetMoney(0); } }