Esempio n. 1
0
        void HandleGenerate(Player p, string arg1, string arg2, string arg3)
        {
            int width, height, length;

            if (!int.TryParse(arg1, out width) || !int.TryParse(arg2, out height) || !int.TryParse(arg3, out length))
            {
                width = 32; height = 32; length = 32;
            }
            if (width < 32 || !MapGen.OkayAxis(width))
            {
                width = 32;
            }
            if (height < 32 || !MapGen.OkayAxis(height))
            {
                height = 32;
            }
            if (length < 32 || !MapGen.OkayAxis(length))
            {
                length = 32;
            }
            if (!CmdNewLvl.CheckMapSize(p, width, height, length))
            {
                return;
            }

            Level lvl = CountdownMapGen.Generate(width, height, length);

            lvl.Deletable       = false;
            lvl.Buildable       = false;
            lvl.permissionbuild = LevelPermission.Nobody;
            lvl.motd            = "Welcome to the Countdown map! -hax";

            Level oldLvl = LevelInfo.FindExact("countdown");

            if (oldLvl != null)
            {
                LevelActions.Replace(oldLvl, lvl);
            }
            else
            {
                LevelInfo.Loaded.Add(lvl);
            }

            lvl.Save();
            if (Server.Countdown.gamestatus != CountdownGameStatus.Disabled)
            {
                Server.Countdown.mapon = lvl;
            }

            const string format = "Generated map ({0}x{1}x{2}), sending you to it..";

            Player.Message(p, format, width, height, length);
            PlayerActions.ChangeMap(p, "countdown");

            const ushort x = 8 * 32 + 16;
            const ushort y = 23 * 32 + 32;
            const ushort z = 17 * 32 + 16;

            p.SendPos(Entities.SelfID, x, y, z, p.rot[0], p.rot[1]);
        }
Esempio n. 2
0
        static void AddMap(Player p, string value)
        {
            if (p.group.OverseerMaps == 0)
            {
                Player.Message(p, "Your rank is not allowed to create any /os maps."); return;
            }
            string level = NextLevel(p);

            if (level == null)
            {
                return;
            }

            if (value == "")
            {
                value = "128 64 128 flat";
            }
            else if (value.IndexOf(' ') == -1)
            {
                value = "128 64 128 " + value;
            }

            string[] args = value.TrimEnd().Split(' ');
            if (args.Length == 3)
            {
                value += " flat";
            }

            CmdNewLvl newLvl = (CmdNewLvl)Command.all.Find("newlvl"); // TODO: this is a nasty hack, find a better way

            if (!newLvl.GenerateMap(p, level + " " + value))
            {
                return;
            }

            // Set default perbuild permissions
            CmdLoad.LoadLevel(null, level);
            Level lvl = LevelInfo.FindExact(level);

            if (lvl == null)
            {
                return;
            }

            lvl.RealmOwner = p.name;
            Command.all.Find("perbuild").Use(null, lvl.name + " +" + p.name);
            CmdZone.ZoneAll(lvl, p.name);

            LevelPermission osPerm = Server.osPerbuildDefault;

            if (osPerm == LevelPermission.Nobody)
            {
                osPerm = GrpCommands.MinPerm(Command.all.Find("overseer"));
            }
            Group grp = Group.findPerm(osPerm);

            if (grp == null)
            {
                return;
            }

            Command.all.Find("perbuild").Use(null, lvl.name + " " + grp.name);
            Player.Message(p, "Use %T/os zone add [name] %Sto allow " +
                           "players ranked below " + grp.ColoredName + " %Sto build in the map.");
        }