Old warn command?

Re: Old warn command?

Postby Stuwie » 02 Jun 2013, 19:56

Would I have to compile the command again or not?
Image
User avatar
Stuwie
 
Posts: 78
Joined: 27 Nov 2011, 23:49

Re: Old warn command?

Postby ismellike » 02 Jun 2013, 19:57

yeah you have to compile,unload,load every time you update a command.

(/cmdunload and /cmdload in case you didn't know)
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: Old warn command?

Postby lucasds12 » 02 Jun 2013, 19:59

Or you can use isme's command called /cmdup, and also here's another warn system.
Code: Select all
using System;

namespace MCDzienny
{
    public class CmdWarn : Command
    {
        public override string name { get { return "warn"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "mod"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Builder; } }

        public override void Use(Player p, string message)
        {
            string reason = message.Substring(message.IndexOf(' ') + 1).Trim();

            if (message == "")
            {
                Help(p);
                return;
            }

            Player who = Player.Find(message.Split(' ')[0]);

            // Makes sure the player is online and valid.
            if (who == null)
            {
                Player.SendMessage(p, "Player not found!");
                return;
            }

            // Code here makes it so you cannot warn your-self.
            if (who == p)
            {
                Player.SendMessage(p, "Cannot warn yourself.");
                return;
            }

            // Check the rank.
            if (p != null && p.group.Permission < who.group.Permission)
            {
                Player.SendMessage(p, "Cannot warn someone higher than you.");
                return;
            }

            // Your reason.
            if (message.Split(' ').Length == 1)
            {
                Player.SendMessage(p, "You need add a valid rule.");
            }
            else
            {
                if (reason == "1")
                {
                    Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "1. EDIT ONLY THIS PART ADD REASON HERE");
                    Command.all.Find("spawn").Use(who, "");
                }
                else if (reason == "2")
                {
                    Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "2. EDIT ONLY THIS PART ADD REASON HERE");
                    Command.all.Find("spawn").Use(who, "");
                }
                else if (reason == "3")
                {
                    Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "3. EDIT ONLY THIS PART ADD REASON HERE");
                    Command.all.Find("spawn").Use(who, "");
                }
                else if (reason == "4")
                {
                    Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "4. EDIT ONLY THIS PART ADD REASON HERE");
                    Command.all.Find("spawn").Use(who, "");
                }
                else if (reason == "5")
                {
                    Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "5. DoEDIT ONLY THIS PART ADD REASON HERE");
                    Command.all.Find("spawn").Use(who, "");
                }
                else if (reason == "6")
                {
                    Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "6. EDIT ONLY THIS PART ADD REASON HERE");
                    Command.all.Find("spawn").Use(who, "");
                }
                else if (reason == "7")
                {
                    Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "7. EDIT ONLY THIS PART ADD REASON HERE.");
                    Command.all.Find("spawn").Use(who, "");
                }
                else
                {
                    Player.SendMessage(p, "Invalid rule.");
                }
            }
        }

        public override void Help(Player p)
        {
            Player.SendMessage(p, "/warn <player> [rule] - Warns a player for [rule] then sends them back to spawn. Example, /warn bob 2");
        }
    }
}

All credit goes to Catching_Fire.
-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: Old warn command?

Postby Stuwie » 02 Jun 2013, 20:00

Thanks!! :)
Image
User avatar
Stuwie
 
Posts: 78
Joined: 27 Nov 2011, 23:49

Re: Old warn command?

Postby Conor » 02 Jun 2013, 20:00

The command platinum made can be made slightly more reliable too, he forgot to check whether there even is a space in the message, the rank of the player, whether they're hidden, and there is an 'else' statement missing in the code. I changed it below, hopefully it will work better for you.

Code: Select all
using System;

namespace MCDzienny
{
   public class CmdWarn : Command
   {
      public override string name { get { return "warn"; } }

      public override string shortcut { get { return ""; } }

      public override string type { get { return "mod"; } }

      public override bool museumUsable { get { return true; } }

      public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }

        public override void Use(Player p, string message)
        {
            if (message == "") { Help(p); return; }

            Player who = null;
            string reason = "No given reason.";

            if (message.Contains(" "))
            {
                who = Player.Find(message.Split(' ')[0]);
                reason = message.Substring(message.IndexOf(' ') + 1);
            }
            else
            {
                who = Player.Find(message);
            }

            if (who == null || who.hidden)
            {
                Player.SendMessage(p, "Player could not be found.");
            }
            else if (who.group.Permission >= p.group.Permission)
            {
                Player.SendMessage(p, "Cannot warn players of greater or equal rank.");
            }
            else
            {
                Player.GlobalMessage(p.color + p.PublicName + " %ewarned " + who.color + who.PublicName + " %ebecause: &c" + reason);
                Player.SendMessage(who, "If you continue you may be kicked!");
            }
        }

      public override void Help(Player p)
      {
         Player.SendMessage(p, "/warn - /warn player reason Warns a player for that reason.");
      }
   }
}
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: Old warn command?

Postby lucasds12 » 02 Jun 2013, 20:02

Here's isme's command called /cmdup, it basically updates the command.
Code: Select all
using System;

namespace MCDzienny
{
    public class CmdCmdup : Command
    {
        public override string name { get { return "cmdup"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "mod"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }

        public override void Use(Player p, string message)
        {
                Command.all.Find("compile").Use(p, message);
                Command.all.Find("cmdunload").Use(p, message);
                Command.all.Find("cmdload").Use(p, message);
                Player.SendMessage(p, "Command updated");
        }

        public override void Help(Player p)
        {
            Player.SendMessage(p, "/cmdup updates a command");
        }
    }
}

Enjoy!
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: Old warn command?

Postby Stuwie » 02 Jun 2013, 20:20

Everytime I restart the server, I have to load the command ''warn'' that I just added, Is there way of making it automaticly load?
Image
User avatar
Stuwie
 
Posts: 78
Joined: 27 Nov 2011, 23:49

Re: Old warn command?

Postby ismellike » 02 Jun 2013, 20:21

Put the name of the command, warn, into the cmdautoload file that is in the Text folder.
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: Old warn command?

Postby Stuwie » 02 Jun 2013, 20:25

The ''cmdautolod'' text is empty. Shall I just put ''warn'' or ''/warn'' ??
Image
User avatar
Stuwie
 
Posts: 78
Joined: 27 Nov 2011, 23:49

Re: Old warn command?

Postby lucasds12 » 02 Jun 2013, 20:28

Stuwie wrote:The ''cmdautolod'' text is empty. Shall I just put ''warn'' or ''/warn'' ??

All you write is "warn" and that's entirely it and putting /warn in the cmdautoload text is not valid for it to auto load, please follow the instructions if your willing to add the /warn command into your server.
-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.

PreviousNext

Return to General Chat

Who is online

Users browsing this forum: No registered users and 4 guests

cron