Example #1
0
 public static void Inform(Player p, string text)
 {
     p.PrintMessage(Color.DarkGreen + text);
 }
 /// <summary>
 /// Lookup the command cmd, and execute it using args as the arguments. sender is used to post error messages back to the user.
 /// </summary>
 /// <param name="sender">The Player attempting to execute the command.</param>
 /// <param name="cmd">Command to execute, e.g. "me"</param>
 /// <param name="args">Argument passed to command, e.g. "uses /me sucessfully"</param>
 ///
 public static void Execute(Player sender, string cmd, string args)
 {
     if (Commands.ContainsKey(cmd))
     {
         if (sender.rank >= Commands[cmd].RankNeeded) {
             try {
                 Commands[cmd].Run(sender, cmd, args);
             }
             catch(NotImplementedException) {
                 sender.PrintMessage(Color.CommandError + "That command's not implemented!");
             }
         } else {
             sender.PrintMessage(Color.CommandError + "You don't have permission to use that command.");
         }
     } else {
         sender.PrintMessage(Color.CommandError + "Unknown command " + cmd);
     }
 }
Example #3
0
 void Player_BlockChange(Player sender, BlockPosition pos, Block BlockType)
 {
     Block was = map.GetTile(pos.x, pos.y, pos.z);
     if (!Game.CanBuild(sender, pos, BlockType)) {
         sender.BlockSet(pos, was);
         sender.PrintMessage(Color.DarkGreen + "You're not allowed to do that!");
         return;
     }
     map.SetTile(pos.x, pos.y, pos.z, BlockType);
     Game.PlayerBuilds(sender, pos, BlockType, was);
 }
        public static void WrapMessage(Player sendto, string message, string prefix)
        {
            if(prefix.Length > 4)
                prefix = prefix.Substring(0, 4);

            while (message.Length > 60)
            {
                int i = message.LastIndexOf(' ', 60, 60);
                if(i == -1) i = 60;

                sendto.PrintMessage(prefix + message.Substring(0, i));
                message = message.Substring(i);
            }
            sendto.PrintMessage(prefix + message);
        }