public override void Use(Player p, string message, CommandData data)
        {
            if (!(p.group.Permission >= LevelPermission.Operator))
            {
                if (!Hacks.CanUseHacks(p))
                {
                    if (data.Context != CommandContext.MessageBlock)
                    {
                        p.Message("%cYou cannot use this command manually when hacks are disabled.");
                        return;
                    }
                }
            }

            BlockID block = p.GetHeldBlock();
            int     x = p.Pos.BlockX, y = (p.Pos.Y - 32) / 32, z = p.Pos.BlockZ;

            try {
                string[] parts = message.Split(' ');
                switch (parts.Length)
                {
                case 1:
                    if (message == "")
                    {
                        break;
                    }

                    if (!CommandParser.GetBlock(p, parts[0], out block))
                    {
                        return;
                    }
                    break;

                case 3:
                    x = int.Parse(parts[0]);
                    y = int.Parse(parts[1]);
                    z = int.Parse(parts[2]);
                    break;

                case 4:
                    if (!CommandParser.GetBlock(p, parts[0], out block))
                    {
                        return;
                    }

                    x = int.Parse(parts[1]);
                    y = int.Parse(parts[2]);
                    z = int.Parse(parts[3]);
                    break;

                default: Player.Message(p, "Invalid number of parameters"); return;
                }
            } catch {
                p.Message("Invalid parameters"); return;
            }

            if (!CommandParser.IsBlockAllowed(p, "place ", block))
            {
                return;
            }

            x = Clamp(x, p.level.Width);
            y = Clamp(y, p.level.Height);
            z = Clamp(z, p.level.Length);

            p.SendBlockchange((ushort)x, (ushort)y, (ushort)z, block);
            //string blockName = Block.GetName(p, block);
            //Player.Message(p, "{3} block was placed at ({0}, {1}, {2}).", P.X, P.Y, P.Z, blockName);
        }
Example #2
0
 void Player_PlayerBlockChange(Player p, ushort x, ushort y, ushort z, byte type)
 {
     if (started)
     {
         if (p.level == mainlevel && !blueteam.members.Contains(p) && !redteam.members.Contains(p))
         {
             p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z));
             Player.SendMessage(p, "You are not on a team!");
             Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
         }
         if (p.level == mainlevel && blueteam.members.Contains(p) && x == redbase.x && y == redbase.y && z == redbase.z && mainlevel.GetTile(redbase.x, redbase.y, redbase.z) != Block.air)
         {
             Player.GlobalMessageLevel(mainlevel, blueteam.color + p.name + " took the " + redteam.color + " red team's FLAG!");
             GetPlayer(p).hasflag = true;
         }
         if (p.level == mainlevel && redteam.members.Contains(p) && x == bluebase.x && y == bluebase.y && z == bluebase.z && mainlevel.GetTile(bluebase.x, bluebase.y, bluebase.z) != Block.air)
         {
             Player.GlobalMessageLevel(mainlevel, redteam.color + p.name + " took the " + blueteam.color + " blue team's FLAG");
             GetPlayer(p).hasflag = true;
         }
         if (p.level == mainlevel && blueteam.members.Contains(p) && x == bluebase.x && y == bluebase.y && z == bluebase.z && mainlevel.GetTile(bluebase.x, bluebase.y, bluebase.z) != Block.air)
         {
             if (GetPlayer(p).hasflag)
             {
                 Player.GlobalMessageLevel(mainlevel, blueteam.color + p.name + " RETURNED THE FLAG!");
                 GetPlayer(p).hasflag = false;
                 GetPlayer(p).cap++;
                 GetPlayer(p).points += cappoint;
                 blueteam.points++;
                 mainlevel.Blockchange(redbase.x, redbase.y, redbase.z, Block.red);
                 p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z));
                 Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
                 if (blueteam.points >= maxpoints)
                 {
                     End();
                     return;
                 }
             }
             else
             {
                 Player.SendMessage(p, "You cant take your own flag!");
                 p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z));
                 Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
             }
         }
         if (p.level == mainlevel && redteam.members.Contains(p) && x == redbase.x && y == redbase.y && z == redbase.z && mainlevel.GetTile(redbase.x, redbase.y, redbase.z) != Block.air)
         {
             if (GetPlayer(p).hasflag)
             {
                 Player.GlobalMessageLevel(mainlevel, redteam.color + p.name + " RETURNED THE FLAG!");
                 GetPlayer(p).hasflag = false;
                 GetPlayer(p).points += cappoint;
                 GetPlayer(p).cap++;
                 redteam.points++;
                 mainlevel.Blockchange(bluebase.x, bluebase.y, bluebase.z, Block.blue);
                 p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z));
                 Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
                 if (redteam.points >= maxpoints)
                 {
                     End();
                     return;
                 }
             }
             else
             {
                 Player.SendMessage(p, "You cant take your own flag!");
                 p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z));
                 Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
             }
         }
     }
 }