/xtempban

/xtempban

Postby Bboy505 » 05 Apr 2014, 23:56

I decided to make a custom command for Lee's zombie survival because mcdzienny's tempban only allows an hour to be tempbanned and also doesn't have an easier way to impliment your rules into the command.

Feel free to use this command in your own server :)

Code: Select all
using System;
using System.IO;
using System.Threading;

namespace MCDzienny
{
   public class CmdXtempban : Command
   {
        string stbTime;
        int tbTime;
        string reason;
        string offlinePlayer;
      public override string name { get { return "xtempban"; } }
      public override string shortcut { get { return "xtb"; } }
      public override string type { get { return "mod"; } }
      public override bool museumUsable { get { return false; } }
      public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
      public override void Use(Player p, string message)
      {
            Player who = Player.Find(message.Split(' ')[0]);
            stbTime = message.Split(' ')[1];
            reason = message.Split(' ')[2];


            //If offline do this
            if (who == null)
            {
                Player.SendMessage(p, "Player not found. Punishing given player anyways.");
                offlinePlayer = message.Split(' ')[0];

                if (reason == "@r1")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r2")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r3")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r4")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r5")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r6")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r7")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r8")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else
                {
                    Player.SendMessage(p, "You need to use /xtempban <player> <time> @r(rule number) to tempban someone");
                    return;
                }

                if (stbTime == "") { stbTime = "60"; }
               
                Command.all.Find("ban").Use(p, offlinePlayer);
                Player.GlobalMessage(p.color + p.name + " &0tempbanned " + Server.DefaultColor + "(offline)" + offlinePlayer + " for:");
                Player.GlobalMessage("&c" + reason);
                tbTime = Convert.ToInt16(stbTime);
                tbTime = tbTime * 60000;
                Thread.Sleep(tbTime);
                Command.all.Find("unban").Use(null, offlinePlayer);
            }

            else
            {
                //If online do this
                if (who.group.Permission > p.group.Permission)
                {
                    Player.SendMessage(p, "You can't tempban someone of equal or higher rank");
                    return;
                }

                if (reason == "@r1")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r2")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r3")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r4")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r5")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r6")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r7")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else if (reason == "@r8")
                {
                    reason = "INPUT YOUR OWN RULE";
                }
                else
                {
                    Player.SendMessage(p, "You need to use /xtempban <player> <time> @r(rule number) to tempban someone");
                    return;
                }

                if (stbTime == "") { stbTime = "60"; }
               
                Command.all.Find("kickban").Use(p, who.name + " Tempbanned for " + stbTime + " minutes for: " + reason);
                tbTime = Convert.ToInt16(stbTime);
                tbTime = tbTime * 60000;
                Thread.Sleep(tbTime);
                Command.all.Find("unban").Use(null, who.name);
            }
      }

      

      public override void Help(Player p)
      {
         Player.SendMessage(p, "/xtempban - tempbans a player but also adds a record.");
            Player.SendMessage(p, "/xtempban {player} {time} {reason}");
      }
   }
}
Founder of McClassicHosting
Need to contact me? Visit:
irc.geekshed.net
#mcclassichosting, #Panda
Bboy505
 
Posts: 13
Joined: 24 Jun 2013, 01:24

Re: /xtempban

Postby Leeizazombie » 06 Apr 2014, 00:51

Hmm, never noticed the command, but I'd prefer it uses a timer instead of sleeping the Thread, makes it more reliable.
Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)

Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting
User avatar
Leeizazombie
 
Posts: 536
Joined: 10 Jun 2013, 17:45
Location: Ireland.


Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 7 guests