/admin

/admin

Postby lucasds12 » 16 Jun 2013, 02:29

Hey guys, it's me with a other command. It's been a while since I've made custom commands but I am back with another command. This command is called /admin. You will first need one of the default ranks, which is SuperOP. This command will actually RANK the player SuperOP and sort of works like "/rank [player] superop" but a little shortcut to ranking the player that rank.
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 CmdAdmin : 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 "admin"; } }

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

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

      // 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.Nobody
      // LevelPermission.Builder, LevelPermission.AdvBuilder, LevelPermission.Operator, LevelPermission.Admin
      public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }

      // 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, "Successfully ranked the player!");
                                                Command.all.Find("setrank")Use(null, "superop");
                                                 Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was admintized :D");
       

      }

      // This one controls what happens when you use /help [commandname].
      public override void Help(Player p)
      {
         Player.SendMessage(p, "/admin - Ranks the player SuperOP!");
      }
   }
}

Enjoy.
-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: /admin

Postby Conor » 18 Jun 2013, 14:44

Topic moved.

Lucas, please ensure your command is functional before you post in the 'actual commands' section.

This command will not compile, as it has quite a few different problems. If you would like help then feel free to ask.

Hint: Your first problem is using the 'who' Player object, where did it come from? Have a look.
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: /admin

Postby Breakdown901 » 11 Jul 2013, 17:38

I can't get it to work, but I think it should look something like this. I'm a noob coder so remember this is probably wrong.

Code: Select all
using System;
namespace MCDzienny
{
   public class CmdAdmin : Command
   {
      public override string name { get { return "admin"; } }
      public override string shortcut { get { return "ad"; } }
      public override string type { get { return "mod"; } }
      public override bool museumUsable { get { return false; } }
      public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
      public override void Use(Player p, string message)
      {
                 if (message == "") { Help(p); return; }

         Player who = Player.Find(message.Split(' ')[0]);
                        if (who == null)
{
   Player.SendMessage(p, "Player is not online.");
   return;
}
else
      {
                Command.all.Find("setrank").Use(p, "superop");
                }
                {
                Player.GlobalMessage(who.color + who.name + Server.DefaultColor + " was admintized :D");
                }
             
            }             

      public override void Help(Player p)
      {
         Player.SendMessage(p, "/admin - Rank a player administrator.");
      }
   }
}
Owner of:
Breakdown901 Lava Survival/Zombie Survival/Freebuild
Host of NeonGaming Lava Survival.
Breakdown901
 
Posts: 320
Joined: 24 May 2013, 12:54


Return to Help in Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron