/// <summary> Sets the main level of the server that new players spawn in. </summary> /// <returns> true if main level was changed, false if not /// (same map as current main, or given map doesn't exist).</returns> public static bool SetMainLevel(string mapName) { if (mapName.CaselessEq(ServerConfig.MainLevel)) { return(false); } Level oldMain = mainLevel; Level lvl = LevelInfo.FindExact(mapName); if (lvl == null) { lvl = CmdLoad.LoadLevel(null, mapName); } if (lvl == null) { return(false); } oldMain.Config.AutoUnload = true; mainLevel = lvl; mainLevel.Config.AutoUnload = false; ServerConfig.MainLevel = mapName; return(true); }
static bool LoadOfflineLevel(Player p, string name) { string propsPath = LevelInfo.PropertiesPath(name); LevelConfig cfg = new LevelConfig(); LevelConfig.Load(propsPath, cfg); if (!cfg.LoadOnGoto) { Player.Message(p, "Level \"{0}\" cannot be loaded using %T/Goto.", name); return(false); } LevelAccessController visitAccess = new LevelAccessController(cfg, name, true); bool ignorePerms = p.summonedMap != null && p.summonedMap.CaselessEq(name); if (!visitAccess.CheckDetailed(p, ignorePerms)) { return(false); } CmdLoad.LoadLevel(p, name, true); Level lvl = LevelInfo.FindExact(name); if (lvl != null) { return(GotoLevel(p, lvl)); } Player.Message(p, "Level \"{0}\" failed to be auto-loaded.", name); return(false); }
protected internal override void OnBuyCommand(Player p, string message, string[] args) { if (args.Length < 3) { OnStoreCommand(p); return; } LevelPreset preset = FindPreset(args[1]); if (preset == null) { Player.Message(p, "%cThat isn't a level preset"); return; } if (p.money < preset.price) { Player.Message(p, "%cYou don't have enough %3" + ServerConfig.Currency + "%c to buy that map"); return; } string name = p.name + "_" + args[2]; try { Command.all.FindByName("NewLvl").Use(null, name + " " + preset.x + " " + preset.y + " " + preset.z + " " + preset.type); Player.Message(p, "%aCreating level: '%f" + name + "%a' . . ."); CmdLoad.LoadLevel(null, name); Level level = LevelInfo.FindExact(name); CmdOverseer.SetPerms(p, level); Level.SaveSettings(level); PlayerActions.ChangeMap(p, name); Player.Message(p, "%aSuccessfully created your map: '%f" + name + "%a'"); } catch { Player.Message(p, "%cSomething went wrong, Money untouched"); return; } Economy.MakePurchase(p, preset.price, "%3Map: %f" + preset.name); }
static void AutoLoadLineProcessor(string name, string phys) { name = name.ToLower(); if (phys == "") { phys = "0"; } if (name != mainLevel.name) { CmdLoad.LoadLevel(null, name, phys); } else { try { int physLevel = int.Parse(phys); if (physLevel >= 0 && physLevel <= 5) { mainLevel.setPhysics(physLevel); } } catch { s.Log("Physics variable invalid"); } } }
public void LoadMap(string name) { if (String.IsNullOrEmpty(name) || !HasMap(name)) { return; } name = name.ToLower(); Level oldMap = null; if (active && map != null) { oldMap = map; } CmdLoad.LoadLevel(null, name); map = LevelInfo.FindExact(name); if (map != null) { mapSettings = LoadMapSettings(name); mapData = GenerateMapData(mapSettings); map.setPhysics(mapData.destroy ? 2 : 1); map.Config.PhysicsOverload = 1000000; map.Config.AutoUnload = false; map.Config.LoadOnGoto = false; Level.SaveSettings(map); } if (active && map != null) { sendingPlayers = true; try { Player[] online = PlayerInfo.Online.Items; foreach (Player pl in online) { pl.Game.RatedMap = false; pl.Game.PledgeSurvive = false; if (pl.level == oldMap) { if (sendAfkMain && pl.IsAfk) { PlayerActions.ChangeMap(pl, Server.mainLevel); } else { PlayerActions.ChangeMap(pl, map); } } } oldMap.Unload(true, false); } catch { } sendingPlayers = false; StartRound(); } }
/// <summary> Load a map into CTF </summary> public void SetMap(string mapName) { MapName = mapName; CmdLoad.LoadLevel(null, mapName); Map = LevelInfo.FindExact(mapName); Map.SaveChanges = false; UpdateConfig(); }
/// <summary> Load a map into CTF </summary> /// <param name="map">The map to load</param> public void LoadMap(string map) { mapname = map; PropertiesFile.Read("CTF/" + mapname + ".config", LineProcessor); Command.all.Find("unload").Use(null, "ctf"); if (File.Exists("levels/ctf.lvl")) { File.Delete("levels/ctf.lvl"); } File.Copy("CTF/maps/" + mapname + ".lvl", "levels/ctf.lvl"); CmdLoad.LoadLevel(null, "ctf"); mainlevel = LevelInfo.FindExact("ctf"); }
protected internal override void OnBuyCommand(Player p, string message, string[] args) { if (args.Length < 3) { OnStoreCommand(p); return; } LevelPreset preset = FindPreset(args[1]); if (preset == null) { Player.Message(p, "%cThat isn't a level preset"); return; } if (p.money < preset.price) { Player.Message(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy that map"); return; } string name = p.name + "_" + args[2]; try { Command.all.Find("newlvl").Use(null, name + " " + preset.x + " " + preset.y + " " + preset.z + " " + preset.type); Player.Message(p, "%aCreating level: '%f" + name + "%a' . . ."); CmdLoad.LoadLevel(null, name); Level level = LevelInfo.FindExact(name); if (level.permissionbuild > p.Rank) { level.permissionbuild = p.Rank; } if (level.permissionvisit > p.Rank) { level.permissionvisit = p.Rank; } PlayerActions.ChangeMap(p, name); Player.Message(p, "%aSuccessfully created your map: '%f" + name + "%a'"); try { Level.Zone zn = default(Level.Zone); zn.bigX = (ushort)(level.Width - 1); zn.bigY = (ushort)(level.Height - 1); zn.bigZ = (ushort)(level.Length - 1); zn.Owner = p.name; level.ZoneList.Add(zn); LevelDB.CreateZone(level.name, zn); Player.Message(p, "%aZoning Succesful"); } catch { Player.Message(p, "%cZoning Failed"); } } catch { Player.Message(p, "%cSomething went wrong, Money untouched"); return; } Economy.MakePurchase(p, preset.price, "%3Map: %f" + preset.name); }
static void LoadAutoloadMaps(SchedulerTask task) { AutoloadMaps = PlayerExtList.Load("text/autoload.txt", '='); List <string> maps = AutoloadMaps.AllNames(); foreach (string map in maps) { if (map.CaselessEq(mainLevel.name)) { continue; } CmdLoad.LoadLevel(null, map); } }
static void LoadMainLevel(SchedulerTask task) { try { mainLevel = CmdLoad.LoadLevel(null, ServerConfig.MainLevel); if (mainLevel == null) { GenerateMain(); } mainLevel.Config.AutoUnload = false; LevelInfo.Loaded.Add(mainLevel); } catch (Exception e) { Logger.LogError(e); } }
static bool LoadOfflineLevel(Player p, string name, bool ignorePerms) { if (!Level.CheckLoadOnGoto(name)) { Player.Message(p, "Level \"{0}\" cannot be loaded using /goto.", name); return(false); } CmdLoad.LoadLevel(p, name, "0", true); Level lvl = LevelInfo.FindExact(name); if (lvl != null) { return(GotoLevel(p, lvl, ignorePerms)); } Player.Message(p, "Level \"{0}\" failed to be auto-loaded.", name); return(false); }
bool SetStartLevel(Level level) { if (level == null) { List <string> levels = Picker.GetCandidateLevels(); if (levels == null) { return(false); } MapName = LevelPicker.GetRandomLevel(new Random(), levels); Map = LevelInfo.FindExact(MapName) ?? CmdLoad.LoadLevel(null, MapName); if (Map == null) { return(false); } } else { MapName = level.name; Map = level; } Map.SaveChanges = false; Chat.MessageGlobal("A game of zombie survival is starting on: {0}", MapName); Player[] players = PlayerInfo.Online.Items; foreach (Player p in players) { if (p.level != Map) { continue; } PlayerJoinedLevel(p, p.level, p.level); } if (ZSConfig.SetMainLevel) { Server.mainLevel = Map; } return(true); }
bool SetStartLevel(Level level) { if (level == null) { List <string> levels = LevelPicker.GetCandidateLevels(); if (levels == null) { return(false); } CurLevelName = LevelPicker.GetRandomLevel(new Random(), levels); CurLevel = LevelInfo.FindExact(CurLevelName) ?? CmdLoad.LoadLevel(null, CurLevelName); if (CurLevel == null) { return(false); } } else { CurLevelName = level.name; CurLevel = level; } Chat.MessageAll("A game of zombie survival is starting on: {0}", CurLevelName); Player[] players = PlayerInfo.Online.Items; foreach (Player p in players) { if (p.level != CurLevel) { continue; } PlayerJoinedLevel(p, p.level, p.level); } if (ZombieGameProps.SetMainLevel) { Server.mainLevel = CurLevel; } return(true); }
internal void ChangeLevel(string next) { Player[] online = PlayerInfo.Online.Items; if (Map != null) { Level.SaveSettings(Map); Map.ChatLevel("The next map has been chosen - " + Colors.red + next.ToLower()); Map.ChatLevel("Please wait while you are transfered."); } string lastLevel = MapName; MapName = next; Picker.QueuedMap = null; CmdLoad.LoadLevel(null, next); Map = LevelInfo.FindExact(next); Map.SaveChanges = false; if (ZSConfig.SetMainLevel) { Server.mainLevel = Map; } online = PlayerInfo.Online.Items; List <Player> players = new List <Player>(online.Length); foreach (Player pl in online) { pl.Game.RatedMap = false; pl.Game.PledgeSurvive = false; if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(lastLevel)) { players.Add(pl); } } JoinInRandomOrder(players, next); if (LastLevelName.Length > 0) { Command.all.FindByName("Unload").Use(null, LastLevelName); } LastLevelName = next; }
internal void ChangeLevel(string next) { Player[] online = PlayerInfo.Online.Items; if (CurLevel != null) { Level.SaveSettings(CurLevel); CurLevel.ChatLevel("The next map has been chosen - " + Colors.red + next.ToLower()); CurLevel.ChatLevel("Please wait while you are transfered."); } string lastLevel = CurLevelName; CurLevelName = next; QueuedLevel = null; CmdLoad.LoadLevel(null, next); CurLevel = LevelInfo.Find(next); if (ZombieGameProps.SetMainLevel) { Server.mainLevel = CurLevel; } online = PlayerInfo.Online.Items; List <Player> players = new List <Player>(online.Length); foreach (Player pl in online) { pl.Game.RatedMap = false; pl.Game.PledgeSurvive = false; if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(lastLevel)) { players.Add(pl); } } JoinInRandomOrder(players, next); if (LastLevelName != "") { Command.all.Find("unload").Use(null, LastLevelName); } LastLevelName = next; }
public void Enable(Player p) { plugin.Game = this; plugin.Load(false); MapName = "countdown"; CmdLoad.LoadLevel(null, "countdown"); Map = LevelInfo.FindExact("countdown"); if (Map == null) { Player.Message(p, "Countdown level not found, generating.."); GenerateMap(p, 32, 32, 32); Map = LevelInfo.FindExact("countdown"); } Map.Config.Deletable = false; Map.Config.Buildable = false; Map.BuildAccess.Min = LevelPermission.Nobody; Map.Config.MOTD = "Welcome to the Countdown map! -hax"; Status = CountdownGameStatus.Enabled; Chat.MessageGlobal("Countdown has been enabled!"); }