/blockplace - My first block placing command

/blockplace - My first block placing command

Postby Leeizazombie » 21 Feb 2014, 02:50

Fixed build permissions, but they only apply on Zombie Servers, the default rank is Operator just in case.
The command no longer works on non build zombie maps (good thing) and does not replace bedrock.
Added new feature called paintwalk, example: /bp red paintwalk, this will place red blocks underneath you everywhere you walk, handy for auto-pillaring, use /bp [block] paintwalk again to turn it off (/bp air paintwalk would be neat for auto spleefing huh?).

Hope you like it:
Code: Select all
using System;
using System.Collections.Generic;
using System.Threading;

namespace MCDzienny
{
    public class CmdBlockPlace : Command
    {
        public override string name { get { return "blockplace"; } }
        public override string shortcut { get { return "bp"; } }
        public override string type { get { return "buid"; } }
        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;
        bool painting = false;
        bool mineing = false;
        public override bool ConsoleAccess { get { return false; } }
   
        public override void Use(Player p, string message)
        {
            string option = message.Split(' ')[1];
            string block = message.Split(' ')[0];
            blocktoplace = Block.Byte(block);

            if (!MCDzienny.InfectionSystem.InfectionSystem.currentInfectionMap.IsBuildingAllowed)
            {
                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)p.pos[0] / 32);
            this.y = (ushort)((uint)p.pos[1] / 32);
            this.z = (ushort)((uint)p.pos[2] / 32);
            if (option == "above")
            this.place(p, (ushort)((uint)this.x), (ushort)((uint)this.y + 1), this.z); //Above Head
            if (option == "below")
                this.place(p, (ushort)((uint)this.x), (ushort)((uint)this.y - 2), this.z); //Below Player
            if (option == "line")
            {
                this.place(p, (ushort)((uint)this.x), (ushort)((uint)this.y - 2), this.z);
                this.place(p, (ushort)((uint)this.x - 1), (ushort)((uint)this.y - 2), this.z);
                this.place(p, (ushort)((uint)this.x - 2), (ushort)((uint)this.y - 2), this.z);
                this.place(p, (ushort)((uint)this.x - 3), (ushort)((uint)this.y - 2), this.z);
                this.place(p, (ushort)((uint)this.x - 4), (ushort)((uint)this.y - 2), this.z);

                this.place(p, (ushort)((uint)this.x + 1), (ushort)((uint)this.y - 2), this.z);
                this.place(p, (ushort)((uint)this.x + 2), (ushort)((uint)this.y - 2), this.z);
                this.place(p, (ushort)((uint)this.x + 3), (ushort)((uint)this.y - 2), this.z);
                this.place(p, (ushort)((uint)this.x + 4), (ushort)((uint)this.y - 2), this.z);
            }
            if (option == "paintwalk")
            {
                painting =! painting;

                while (painting)
                {
                    if (!MCDzienny.InfectionSystem.InfectionSystem.currentInfectionMap.IsBuildingAllowed)
                    {
                        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)p.pos[0] / 32);
                    this.y = (ushort)((uint)p.pos[1] / 32);
                    this.z = (ushort)((uint)p.pos[2] / 32);
                    this.place(p, (ushort)((uint)this.x), (ushort)((uint)this.y - 2), this.z);
                    Thread.Sleep(100);
                }
            }
            else
                Player.SendMessage(p, "Please specify an option, /help bp");
            return;
        }
        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, "/bp [block] [option] - Places [block] in the position of [option]");
            Player.SendMessage(p, "Options: above, below, line, paintwalk. More comming soon.");
            Player.SendMessage(p, "Note: use paintwalk again to turn it off.");
        }
    }
}

Remember it's mainly coded for Zombie Servers, any suggestions/questions? go ahead!

Older version:
Spoiler:
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 1 guest

cron