/C4

/C4

Postby lucasds12 » 31 May 2013, 23:45

I'll just show you how to make the c4 command and please give credit for the mcforge devs cause they made it.
Code: Select all
/*
   Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCForge)
   
   Dual-licensed under the   Educational Community License, Version 2.0 and
   the GNU General Public License, Version 3 (the "Licenses"); you may
   not use this file except in compliance with the Licenses. You may
   obtain a copy of the Licenses at
   
   http://www.opensource.org/licenses/ecl2.php
   http://www.gnu.org/licenses/gpl-3.0.html
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the Licenses are distributed on an "AS IS"
   BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
   or implied. See the Licenses for the specific language governing
   permissions and limitations under the Licenses.
*/
namespace MCForge.Commands
{
    public sealed class CmdC4 : Command
    {
        public override string name { get { return "c4"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
        public CmdC4() { }


        public override void Use(Player p, string message)
        {
            if (p != null)
            {
                if (p.level.physics >= 1 && p.level.physics < 5)
                {
                    sbyte numb = Level.C4.NextCircuit(p.level);
                    Level.C4.C4s c4 = new Level.C4.C4s(numb);
                    p.level.C4list.Add(c4);
                    p.c4circuitNumber = numb;
                    Player.SendMessage(p, "Place any block for c4 and place a " + c.red + "red" + Server.DefaultColor + " block for the detonator!");
                    p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                    return;
                }
                else
                {
                    Player.SendMessage(p, "To use c4, the physics level must be 1, 2, 3 or 4");
                    return;
                }
            }
            Player.SendMessage(p, "This command can only be used in-game!");
            return;
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/c4 - Place c4!");
        }
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();


            if (type == Block.red) { Blockchange2(p, x, y, z, type); return; }
            if (type != Block.air)
            {
                p.level.Blockchange(p, x, y, z, Block.c4);
            }
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }


        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.level.Blockchange(p, x, y, z, Block.c4det);
            Player.SendMessage(p, "Placed detonator block!");
        }
    }
}

Enjoy destructing crap. Lol.
-Lucas

















There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.

Re: /C4

Postby ismellike » 31 May 2013, 23:50

Unfortunately that code uses MCForge variables which MCDzienny doesn't have definitions for; It won't work.

I will post a c4 command though.
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /C4

Postby lucasds12 » 31 May 2013, 23:51

Ok, didn't notice.
Thanks for the information.
Also can someone move this to the "Actual Commands" section?
-Lucas
There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.

Re: /C4

Postby dzienny » 31 May 2013, 23:58

lucasds12 wrote:Ok, didn't notice.
Thanks for the information.
Also can someone move this to the "Actual Commands" section?
-Lucas


The Actual Commands section is meant for the commands that work and are ready to be used. Unfortunately the above command doesn't meet these requirements.
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: /C4

Postby lucasds12 » 01 Jun 2013, 00:02

Ah, it unfortunately appears so. I have not recently noticed that some of that coding is not enabled in MCDzienny.
I apologize making a mistake on trying to make such a nice command but the attempt seemed to not determine my first command. I seem to be mistakenly sorry for posting such a useless command. I try to assist others as much as I can.

-Lucas
There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.

Re: /C4

Postby ismellike » 01 Jun 2013, 00:56

Here you go :)!
Code: Select all
using System.Threading;
using System;
using System.Collections.Generic;
using System.IO;

namespace MCDzienny
{
    public class CmdTntwar : Command
    {
        //use p.overallDeath for killstreaks
        private static List<Player> tntwars = new List<Player>();
        // The command's name, in all lowercase.  What you'll be putting behind the slash when using it.
        public override string name { get { return "c4"; } }

        // Command's shortcut (please take care not to use an existing one, or you may have issues.
        public override string shortcut { get { return ""; } }

        // Determines which submenu the command displays in under /help.
        public override string type { get { return "other"; } }

        public override bool museumUsable { get { return false; } }

        public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }

        public override void Use(Player p, string message)
        {
            if (!p.ExtraData.ContainsKey("c4"))
            {
                p.ExtraData.Add("c4", false);
            }
            if (p.level.physics != 3 || p.level.physics != 2)
            {
                Player.SendMessage(p, "The physics do not allow explosions on this map.");
            }
            else if ((bool)p.ExtraData["c4"] == false)
            {
                p.ExtraData["c4"] = true;
                p.Blockchange += new Player.BlockchangeEventHandler(addc4);
                Player.SendMessage(p, "C4 mode turned on.");
            }
            else
            {
                p.ClearBlockchange();
                p.ExtraData["c4"] = false;
                Player.SendMessage(p, "C4 mode turned off.");
            }
        }
        public void addc4(Player p, ushort x, ushort y, ushort z, byte type)
        {
            if (type == Block.red)
            {
                List<Pos> buffer = new List<Pos>();
                ushort c4x, c4y, c4z; int currentBlock = 0;
                int limit = 5;
                foreach (byte tnt in p.level.blocks)
                {
                    if (tnt == Block.Byte("tdoor_tnt"))
                    {
                        p.level.IntToPos(currentBlock, out c4x, out c4y, out c4z);
                        BufferAdd(buffer, c4x, c4y, c4z);
                    }
                    currentBlock++;
                }
                Player.SendMessage(p, buffer.Count.ToString());
                buffer.ForEach(delegate(Pos c4)
                {
                    if (limit > 0)
                    {
                        limit -= 1;
                        p.level.MakeExplosion(c4.x, c4.y, c4.z,Block.rock);
                    }

                });
            }
            else
            {
                p.level.Blockchange(x, y, z, Block.Parse("tdoor_tnt"), true, "");
            }
        }
        struct Pos
        {
            public ushort x, y, z;
        }
        void BufferAdd(List<Pos> list, ushort x, ushort y, ushort z)
        {
            Pos pos; pos.x = x; pos.y = y; pos.z = z; list.Add(pos);
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/c4 -- switches c4's [on/off]");
        }
    }
}
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /C4

Postby lucasds12 » 01 Jun 2013, 01:36

Thank you! Thank you! Thank you!
:)
I even have a thank you on code:
Code: Select all
Thank You!

-Lucas
There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.

Re: /C4

Postby Breakdown901 » 01 Jun 2013, 12:45

Just tried isme's version, it wont work for me. Whatever physics you set it to it comes up "The physics do not allow explosions on this map." Yes, I tried setting it to 1,2,3 and 4 and none work.
Owner of:
Breakdown901 Lava Survival/Zombie Survival/Freebuild
Host of NeonGaming Lava Survival.
Breakdown901
 
Posts: 320
Joined: 24 May 2013, 12:54

Re: /C4

Postby ismellike » 01 Jun 2013, 13:03

Try this one

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

namespace MCDzienny
{
    public class CmdTntwar : Command
    {
        //use p.overallDeath for killstreaks
        private static List<Player> tntwars = new List<Player>();
        // The command's name, in all lowercase.  What you'll be putting behind the slash when using it.
        public override string name { get { return "c4"; } }

        // Command's shortcut (please take care not to use an existing one, or you may have issues.
        public override string shortcut { get { return ""; } }

        // Determines which submenu the command displays in under /help.
        public override string type { get { return "other"; } }

        public override bool museumUsable { get { return false; } }

        public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }

        public override void Use(Player p, string message)
        {
            if (!p.ExtraData.ContainsKey("c4"))
            {
                p.ExtraData.Add("c4", false);
            }
            if (p.level.physics != 3 && p.level.physics != 2)
            {
                Player.SendMessage(p, "The physics do not allow explosions on this map.");
            }
            else if ((bool)p.ExtraData["c4"] == false)
            {
                p.ExtraData["c4"] = true;
                p.Blockchange += new Player.BlockchangeEventHandler(addc4);
                Player.SendMessage(p, "C4 mode turned on.");
            }
            else
            {
                p.ClearBlockchange();
                p.ExtraData["c4"] = false;
                Player.SendMessage(p, "C4 mode turned off.");
            }
        }
        public void addc4(Player p, ushort x, ushort y, ushort z, byte type)
        {
            if (type == Block.red)
            {
                List<Pos> buffer = new List<Pos>();
                ushort c4x, c4y, c4z; int currentBlock = 0;
                int limit = 5;
                foreach (byte tnt in p.level.blocks)
                {
                    if (tnt == Block.Byte("tdoor_tnt"))
                    {
                        p.level.IntToPos(currentBlock, out c4x, out c4y, out c4z);
                        BufferAdd(buffer, c4x, c4y, c4z);
                    }
                    currentBlock++;
                }
                Player.SendMessage(p, buffer.Count.ToString());
                buffer.ForEach(delegate(Pos c4)
                {
                    if (limit > 0)
                    {
                        limit -= 1;
                        p.level.MakeExplosion(c4.x, c4.y, c4.z,Block.rock);
                    }

                });
            }
            else
            {
                p.level.Blockchange(x, y, z, Block.Parse("tdoor_tnt"), true, "");
            }
        }
        struct Pos
        {
            public ushort x, y, z;
        }
        void BufferAdd(List<Pos> list, ushort x, ushort y, ushort z)
        {
            Pos pos; pos.x = x; pos.y = y; pos.z = z; list.Add(pos);
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/c4 -- switches c4's [on/off]");
        }
    }
}
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas


Return to Requests for Addon

Who is online

Users browsing this forum: No registered users and 3 guests

cron