/add maps easier

/add maps easier

Postby ismellike » 17 May 2013, 02:54

/Add

With this command you will be able to /add lava [map_name] [author] to the lava system in like 10 seconds.

You can also add zombie maps the same way, just do /add zombie [map_name] [author].

When you add a lava map it will set the lava spawn at your position using the source block as lavaup.


Code: Select all
using System;
using System.IO;

namespace MCDzienny
{
    public class CmdAdd : Command
    {
        public override string name { get { return "add"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
        /*                              *
         * ~~~~~~~~~~~~~~~~~~~~~~~~~~~  *
         * Made by Ismellike t(*_*t)    *
         *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
         */
        public override void Use(Player p, string message)
        {
            string levelname, author;
            if (p == null)
            {
                Player.SendMessage(p, "Can't let you do that "+Server.ConsoleName+".");
            }
            else if (message.Split(' ')[0].ToLower() == "lava")
            {
                try
                {
                    levelname = message.Split(' ')[1];
                    author = message.Split(' ')[2];
                }
                catch
                {
                    Player.SendMessage(p, "Please add a level name and author.");
                    return;
                }
                if (File.Exists("lava/maps/" + levelname + ".lvl"))
                {
                    Player.SendMessage(p, levelname + " is already a lava map.");
                    return;
                }
                int x = p.pos[0] / 32;
                int y = p.pos[1] / 32;
                int z = p.pos[2] / 32;
                using (var sr = new StreamReader("lava/maps.txt"))
                {
                    using (var sw = new StreamWriter("lava/temp_maps.txt"))
                    {
                        string line;

                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line == "</Maps>")
                            {
                                sw.WriteLine("<Map name=\"" + levelname + "\" phase1=\"0\" phase2=\"0\" author=\"" + author + "\">");
                                sw.WriteLine("<Source block=\"lavaup\" x=\"" + x + "\" y=\"" + y + "\" z=\"" + z + "\" type=\"\" delay=\"0\" />");
                                sw.WriteLine(" </Map>" + Environment.NewLine + "</Maps>");
                                break;
                            }
                            else
                            {
                                sw.WriteLine(line);
                            }
                        }
                    }
                }
                File.Delete("lava/maps.txt");
                File.Move("lava/temp_maps.txt","lava/maps.txt");
                File.Copy("levels/" + p.level.name + ".lvl", "lava/maps/" + levelname + ".lvl");
                Player.GlobalMessageOps(p.name + " has just added " + p.level.name + " to the lava maps.");
            }
            else if (message.Split(' ')[0].ToLower() == "zombie")
            {
                try
                {
                    levelname = message.Split(' ')[1];
                    author = message.Split(' ')[2];
                }
                catch
                {
                    Player.SendMessage(p, "Please add a level name and author.");
                    return;
                }
                if (File.Exists("infection/maps/" + levelname + ".lvl"))
                {
                    Player.SendMessage(p, levelname + " is already a lava map.");
                    return;
                }
                using (var sr = new StreamReader("infection/maps.txt"))
                {
                    using (var sw = new StreamWriter("infection/temp_maps.txt"))
                    {
                        string line;

                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line == "</Maps>")
                            {
  sw.WriteLine("<Map name=\""+levelname+"\" author=\""+author+"\" countdown-seconds=\"10\" round-time-minutes=\"5\" allow-building=\"True\" allow-pillaring=\"True\" />");
                                sw.WriteLine(line);
                                break;
                            }
                            else
                            {
                                sw.WriteLine(line);
                            }
                        }
                    }
                }
                File.Delete("infection/maps.txt");
                File.Move("infection/temp_maps.txt", "infection/maps.txt");
                File.Copy("levels/" + p.level.name + ".lvl", "infection/maps/" + levelname + ".lvl");
                Player.GlobalMessageOps(p.name + " has just added " + p.level.name + " to the zombie maps.");
            }
            else
            {
                Help(p);
            }
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/add [lava/zombie] [map_name] [author] -- adds maps for playing.");
            if (Server.mode==Mode.Lava||Server.mode==Mode.LavaFreebuild)
            {
                Player.SendMessage(p, "Lava spawn will be at your position as lavaup.");
            }
        }
    }
}
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /add maps easier

Postby Alshima » 17 May 2013, 04:46

I like it :D
Alshima
 
Posts: 160
Joined: 11 Mar 2013, 02:22
Location: Alshima Island

Re: /add maps easier

Postby dzienny » 21 May 2013, 23:49

That's nice! I think every lava owner should add this to their server.
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27


Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 4 guests

cron