/crashplayer

/crashplayer

Postby Alshima » 15 Apr 2014, 06:00

So I haven't coded in awhile. So expect this to have some errors.

Code: Select all
//Made by Alshima
//(c) 2014
using System;
namespace MCDzienny
{
    public class Cmdcrashplayer : Command
    {
        public override string name { get { return "crashplayer"; } }
        public override string shortcut { get { return "ping"; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
        public override void Use(Player p, string message)
        {
            if (message == "") { Help(p); return; }

            Player who = Player.Find(message);

            if (who == null)
            {
                Player.SendMessage(p, "%cHe protected for today, nono for now.");
                return;
            }
            {
                Player.GlobalMessage("&fThis" + " " + who.color + who.PublicName + "%ftried to crash a player!");
                Player.SendMessage(who, "&4Y u mad 2day?");
                Thread.Sleep(5000);
                p.kick("%fYou are being %4hunted down at this moment. You shouldn't have done that! :O");

            }
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "%c----[CrashPlayer/Ping]----");
         Player.SendMessage(p, "/ping - make a player disconnect");
        }
    }
}


It might be a bit odd, despite the fact it is sort of newbish. So expect some errors, as stated up above. ;)

Enjoy.
Alshima
 
Posts: 160
Joined: 11 Mar 2013, 02:22
Location: Alshima Island

Re: /crashplayer

Postby _Retaliate_ » 15 Apr 2014, 08:25

You actually did good, only one error and it is a common one. You forgot the "else" in your if statement
Corrected Code for you:
Code: Select all
//Made by Alshima
//(c) 2014
using System;
namespace MCDzienny
{
    public class Cmdcrashplayer : Command
    {
        public override string name { get { return "crashplayer"; } }
        public override string shortcut { get { return "ping"; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
        public override void Use(Player p, string message)
        {
            if (message == "") { Help(p); return; }
            Player who = Player.Find(message);
            if (who == null)
            {
                Player.SendMessage(p, "%cHe protected for today, nono for now.");
                return;
            }
            else
            {
                Player.GlobalMessage("&fThis" + " " + who.color + who.PublicName + "%ftried to crash a player!");
                Player.SendMessage(who, "&4Y u mad 2day?");
                Thread.Sleep(5000);
                p.kick("%fYou are being %4hunted down at this moment. You shouldn't have done that! :O");

            }
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "%c----[CrashPlayer/Ping]----");
         Player.SendMessage(p, "/ping - make a player disconnect");
        }
    }
}
Image
_Retaliate_
 
Posts: 68
Joined: 26 Sep 2013, 11:16

Re: /crashplayer

Postby Leeizazombie » 15 Apr 2014, 12:38

Note: In relation to your shortcut that there is a core command: /ping already
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 9 guests

cron