Exemplo n.º 1
0
        static void HandleGoto(Player p, string map, string ignored)
        {
            byte mapNum = 0;

            if (map.Length == 0 || map == "1")
            {
                map = FirstMapName(p);
            }
            else
            {
                if (!byte.TryParse(map, out mapNum))
                {
                    Player.MessageLines(p, gotoHelp);
                    return;
                }
                map = p.name.ToLower() + map;
            }

            if (LevelInfo.FindExact(map) == null)
            {
                CmdLoad.LoadLevel(p, map, ServerConfig.AutoLoadMaps);
            }
            if (LevelInfo.FindExact(map) != null)
            {
                PlayerActions.ChangeMap(p, map);
            }
        }
Exemplo n.º 2
0
        public override void Use(Player p, string message)
        {
            string[] args = message.SplitSpaces();
            if (args.Length != 2)
            {
                Help(p); return;
            }

            Level lvl = Matcher.FindLevels(p, args[0]);

            if (lvl == null)
            {
                return;
            }
            string newName = args[1].ToLower();

            if (!Formatter.ValidName(p, newName, "level"))
            {
                return;
            }

            if (LevelInfo.MapExists(newName))
            {
                Player.Message(p, "Level already exists."); return;
            }
            if (lvl == Server.mainLevel)
            {
                Player.Message(p, "Cannot rename the main level."); return;
            }
            if (!LevelInfo.ValidateAction(p, lvl.name, "rename this level"))
            {
                return;
            }

            List <Player> players = lvl.getPlayers();

            lvl.Unload();

            LevelActions.Rename(lvl.name, newName);
            CmdLoad.LoadLevel(p, newName);
            Chat.MessageGlobal("Renamed {0} to {1}", lvl.name, newName);
            // Move all the old players to the renamed map
            foreach (Player pl in players)
            {
                PlayerActions.ChangeMap(pl, newName);
            }
        }