/deletecorecommand - Deletes a core command.

/deletecorecommand - Deletes a core command.

Postby lucasds12 » 06 Jun 2013, 00:04

Hello, I would like the /deletecorecommand command that isn't so complicated to understand.
For newbies, a core command is a command that is implemented to MCDzienny. (e.g /hide, /pay)
I want a simple command that will delete OR unload a core command.
SendMessage: The command is now deleted!
GlobalMessage: [COMMAND] is now deleted!
Thanks for reading this, it would be unexpectedly amazing if you could reply or help me make this command.
-Lucas
There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.

Re: /deletecorecommand - Deletes a core command.

Postby Conor » 06 Jun 2013, 00:06

Within the 'Use' method of your command insert the following code.

Code: Select all
if (String.IsNullOrEmpty(message))
{
   Help(p);
   return;
}

Command cmd = Command.all.Find(message);

if (cmd == null)
{
   Player.SendMessage(p, "Command could not be found.");
   return;
}

Command.all.Remove(cmd);
Player.SendMessage(p, "Command removed.");
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: /deletecorecommand - Deletes a core command.

Postby lucasds12 » 06 Jun 2013, 01:01

Compiler error:
Code: Select all
-------------------------

Error #CS0116
Message: A namespace does not directly contain members such as fields or methods
Line: 47

-------------------------

Error #CS1022
Message: Type or namespace definition, or end-of-file expected
Line: 64

-------------------------

Error #CS1022
Message: Type or namespace definition, or end-of-file expected
Line: 65

Command:
Code: Select all
/*
   Auto-generated command skeleton class.

   Use this as a basis for custom commands implemented via the MCDzienny scripting framework.
   File and class should be named a specific way.  For example, /update is named 'CmdUpdate.cs' for the file, and 'CmdUpdate' for the class.
*/

// Add any other using statements you need up here, of course.
// As a note, MCDzienny is designed for .NET 3.5.
using System;

namespace MCDzienny
{
   public class CmdDeletecorecommand : Command
   {     
      // The command's name, in all lowercase.  What you'll be putting behind the slash when using it.
      public override string name { get { return "deletecorecommand"; } }

      // Command's shortcut (please take care not to use an existing one, or you may have issues.
      public override string shortcut { get { return "dcc"; } }

      // Determines which submenu the command displays in under /help.
      public override string type { get { return "mod"; } }

      // Determines whether or not this command can be used in a museum.  Block/map altering commands should be made false to avoid errors.
      public override bool museumUsable { get { return false; } }

      // Determines the command's default rank.  Valid values are:
      // LevelPermission.Nobody, LevelPermission.Banned, LevelPermission.Guest
      // LevelPermission.Builder, LevelPermission.AdvBuilder, LevelPermission.Operator, LevelPermission.Admin
      public override LevelPermission defaultRank { get { return LevelPermission.Nobody; } }

      // This is where the magic happens, naturally.
      // p is the player object for the player executing the command.  message is everything after the command invocation itself.
      public override void Use(Player p, string message)
      {
         Player.SendMessage(p, "Deleting core command...");
      }

      // This one controls what happens when you use /help [commandname].
      public override void Help(Player p)
      {
         Player.SendMessage(p, "/deletecorecommand - Deletes a core command.");
      }
   
}
if (String.IsNullOrEmpty(message))
{
   Help(p);
   return;
}

Command cmd = Command.all.Find(message);

if (cmd == null)
{
   Player.SendMessage(p, "Command is not valid.");
   return;
}

Command.all.Remove(cmd);
Player.SendMessage(p, "Command successfully removed, enjoy!");
}
  }

Help please.
-Lucas
There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.

Re: /deletecorecommand - Deletes a core command.

Postby ismellike » 06 Jun 2013, 01:17

Conor wrote:Within the 'Use' method of your command insert the following code.


You put the code in another place.

This is the use method
Code: Select all
      public override void Use(Player p, string message)
      {
}


So it would look like this

Spoiler:
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas


Return to Requests for Addon

Who is online

Users browsing this forum: No registered users and 4 guests

cron