/trap [player] [block]

/trap [player] [block]

Postby Leeizazombie » 22 Feb 2014, 14:02

Hey this is my second build type command, and I lets you trap a player with any blocks. :lol:
Have fun trapping players ;)

Code: Select all
using System;
using System.Collections.Generic;
using System.Threading;

namespace MCDzienny
{
    public class CmdTrap : Command
    {
        public override string name { get { return "trap"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "build"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
        public ushort x;
        public ushort y;
        public ushort z;
        public byte blocktoplace;

        public override void Use(Player p, string message)
        {
            string block = message.Split(' ')[1];
            blocktoplace = Block.Byte(block);
            if (message == "") { Help(p); return; }
            string two = message.Split(' ')[0];
            Player who = Player.Find(two);
            if (blocktoplace == null)
            {
                Player.SendMessage(p, "Invalid block name.");
                return;
            }
            if (who == null)
            {
                Player.SendMessage(p, "Player is not online.");
                return;
            }

            if (p.level.name == MCDzienny.InfectionSystem.InfectionSystem.currentInfectionMap.ToString() && !MCDzienny.InfectionSystem.InfectionSystem.currentInfectionMap.IsBuildingAllowed || p.level.permissionbuild > p.group.Permission)
            {
                Player.SendMessage(p, "You can't build on this map.");
                return;
            }
            if (!Block.canPlace(p, blocktoplace))
            {
                Player.SendMessage(p, "You can't place this block type.");
                return;
            }

            this.x = (ushort)((uint)who.pos[0] / 32);
            this.y = (ushort)((uint)who.pos[1] / 32);
            this.z = (ushort)((uint)who.pos[2] / 32);

            this.place(p, this.x, (ushort)((uint)this.y + 1), this.z);
            this.place(p, (ushort)((uint)this.x - 1), (ushort)((uint)this.y - 1), this.z);
            this.place(p, (ushort)((uint)this.x - 1), (ushort)((uint)this.y - 1), (ushort)((uint)this.z - 1));
            this.place(p, this.x, (ushort)((uint)this.y - 1), (ushort)((uint)this.z - 1));
            this.place(p, (ushort)((uint)this.x + 1), (ushort)((uint)this.y - 1), (ushort)((uint)this.z - 1));
            this.place(p, (ushort)((uint)this.x + 1), (ushort)((uint)this.y - 1), this.z);
            this.place(p, (ushort)((uint)this.x + 1), (ushort)((uint)this.y - 1), (ushort)((uint)this.z + 1));
            this.place(p, this.x, (ushort)((uint)this.y - 1), (ushort)((uint)this.z + 1));
            this.place(p, (ushort)((uint)this.x - 1), (ushort)((uint)this.y - 1), (ushort)((uint)this.z + 1));
            this.place(p, (ushort)((uint)this.x - 1), this.y, this.z);
            this.place(p, (ushort)((uint)this.x - 1), this.y, (ushort)((uint)this.z - 1));
            this.place(p, this.x, this.y, (ushort)((uint)this.z - 1));
            this.place(p, (ushort)((uint)this.x + 1), this.y, (ushort)((uint)this.z - 1));
            this.place(p, (ushort)((uint)this.x + 1), this.y, this.z);
            this.place(p, (ushort)((uint)this.x + 1), this.y, (ushort)((uint)this.z + 1));
            this.place(p, this.x, this.y, (ushort)((uint)this.z + 1));
            this.place(p, (ushort)((uint)this.x - 1), this.y, (ushort)((uint)this.z + 1));
            this.place(p, (ushort)((uint)this.x - 1), (ushort)((uint)this.y + 1), this.z);
            this.place(p, (ushort)((uint)this.x - 1), (ushort)((uint)this.y + 1), (ushort)((uint)this.z - 1));
            this.place(p, this.x, (ushort)((uint)this.y + 1), (ushort)((uint)this.z - 1));
            this.place(p, (ushort)((uint)this.x + 1), (ushort)((uint)this.y + 1), (ushort)((uint)this.z - 1));
            this.place(p, (ushort)((uint)this.x + 1), (ushort)((uint)this.y + 1), this.z);
            this.place(p, (ushort)((uint)this.x + 1), (ushort)((uint)this.y + 1), (ushort)((uint)this.z + 1));
            this.place(p, this.x, (ushort)((uint)this.y + 1), (ushort)((uint)this.z + 1));
            this.place(p, (ushort)((uint)this.x - 1), (ushort)((uint)this.y + 1), (ushort)((uint)this.z + 1));
            Player.SendMessage(who, "You've been trapped with %7" + block);
            Player.SendMessage(p, "You trapped " + who.color + who.name + Server.DefaultColor + " with %7" + block);
        }
        public void place(Player p, ushort x, ushort y, ushort z)
        {
            if ((int)y >= (int)p.level.height)
                return;
            p.level.Blockchange(p, x, y, z, this.blocktoplace);
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/trap [player] [block] - Trap a player with a specified block.");
        }
    }
}


Note: If you type an unknown block name it will just place orange blocks, I wasn't sure how to prevent it, although it seems that this is the dummy block for unknown names.

Any suggestions or bugs? Please tell me! :)
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 3 guests

cron