namespace MCDzienny { public class CmdHide : Command { public override string name { get { return "hide"; } } public override string shortcut { get { return ""; } } public override string type { get { return "mod"; } } public override bool museumUsable { get { return false; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override bool ConsoleAccess { get { return false; } }
public override void Init() { // Remove the core command named "hide". Command.all.Remove(Command.all.Find("hide")); }
public override void Use(Player p, string message) { if (p.possess != string.Empty) { Player.SendMessage(p, "Stop your current possession first."); return; }
Player.SendMessage(p, "You're now %fvisible%s."); } } }
public override void Help(Player p) { Player.SendMessage(p, "/hide <s> - makes yourself (in)visible to other players."); } } }
Changelog:
Spoiler:
new: removes the core command "hide" on initialization, change: p.name -> p.PublicName - to hide email domains, change: use of Misc.Message class to parse the arguments - more readable, change: Server.DefaultColor was mostly replaced with "%s" code - more readable, fix: Player.GlobalSpawn(p); fix: works if a player doesn't have a message set.
Anyway, I consider it a bug that the hide command doesn't take into consideration farewell and welcome messages. So, I will fix it in some of the next versions. But, the code still may be useful to others if they want to make their own changes to it.
And, I highly advise using Visual Studio C# Express Edition, which is free, for creating custom commands. It makes the process much easier.
// Some method called when a custom command is loaded using /cmdload. // The Command passed through the method is the command which will be added. public void LoadNewCustomCommand(Command cmd) { cmd.Init(); Command.all.Add(cmd); }