protected override void DoPurchase(Player p, string message, string[] args) { string text = message.SplitSpaces(2)[1]; // keep spaces this way bool hasAToken = false; for (int i = 0; i < text.Length; i++) { if (!CheckEscape(text, i, ref hasAToken)) { p.Message("You can only use {0} and {1} for tokens in infect messages."); return; } } if (!hasAToken) { p.Message("You need to include a \"{0}\" (placeholder for zombie player) " + "and/or a \"{1}\" (placeholder for human player) in the infect message."); return; } ZSData data = ZSGame.Get(p); if (data.InfectMessages == null) { data.InfectMessages = new List <string>(); } data.InfectMessages.Add(text); ZSConfig.AppendPlayerInfectMessage(p.name, text); p.Message("&aAdded infect message: &f" + text); Economy.MakePurchase(p, Price, "%3InfectMessage: " + message); }
public void ApplyToServer() { ZSConfig cfg = ZSGame.Config; cfg.NoPillaring = !Pillaring; cfg.MaxMoveDist = MaxMoveDistance; cfg.HitboxDist = HitboxPrecision; cfg.MapInHeartbeat = IncludeMapInHeartbeat; cfg.ZombieName = Name.Trim(); cfg.ZombieModel = Model.Trim(); if (cfg.ZombieModel.Length == 0) { cfg.ZombieModel = "zombie"; } cfg.InvisibilityDuration = InvisibilityDuration; cfg.InvisibilityPotions = InvisibilityPotions; cfg.ZombieInvisibilityDuration = ZInvisibilityDuration; cfg.ZombieInvisibilityPotions = ZInvisibilityPotions; cfg.ReviveChance = Chance; cfg.ReviveNoTime = InsufficientTime; cfg.ReviveNoTimeMessage = InsufficientTimeMessage; cfg.ReviveTooSlow = ExpiryTime; }
void SaveZSSettings() { try { ZSConfig cfg = ZSGame.Config; cfg.InvisibilityDuration = (int)zs_numInvHumanDur.Value; cfg.InvisibilityPotions = (int)zs_numInvHumanMax.Value; cfg.ZombieInvisibilityDuration = (int)zs_numInvZombieDur.Value; cfg.ZombieInvisibilityPotions = (int)zs_numInvZombieMax.Value; cfg.ReviveTimes = (int)zs_numReviveMax.Value; cfg.ReviveChance = (int)zs_numReviveEff.Value; cfg.ReviveTooSlow = (int)zs_numReviveLimit.Value; cfg.ZombieName = zs_txtName.Text.Trim(); cfg.ZombieModel = zs_txtModel.Text.Trim(); if (cfg.ZombieModel.Length == 0) { cfg.ZombieModel = "zombie"; } zsHelper.Save(); } catch (Exception ex) { Logger.LogError("Error saving ZS settings", ex); } }
public void LoadFromServer() { ZSConfig cfg = ZSGame.Config; Maps = cfg.Maps.Join(","); Pillaring = !cfg.NoPillaring; SetMainLevel = cfg.SetMainLevel; StartImmediately = cfg.StartImmediately; MaxMoveDistance = cfg.MaxMoveDist; HitboxPrecision = cfg.HitboxDist; IncludeMapInHeartbeat = cfg.MapInHeartbeat; Name = cfg.ZombieName; Model = cfg.ZombieModel; InvisibilityDuration = cfg.InvisibilityDuration; InvisibilityPotions = cfg.InvisibilityPotions; ZInvisibilityDuration = cfg.ZombieInvisibilityDuration; ZInvisibilityPotions = cfg.ZombieInvisibilityPotions; Chance = cfg.ReviveChance; InsufficientTime = cfg.ReviveNoTime; InsufficientTimeMessage = cfg.ReviveNoTimeMessage; ExpiryTime = cfg.ReviveTooSlow; }
public static void Load() { old = new OldPerms(); if (PropertiesFile.Read(Paths.ServerPropsFile, ref old, LineProcessor)) { Server.SettingsUpdate(); } if (old.saveZS) { ZSConfig.SaveSettings(); } ZSConfig.LoadSettings(); Database.Backend = ServerConfig.UseMySQL ? MySQLBackend.Instance : SQLiteBackend.Instance; #pragma warning disable 0618 Server.DefaultColor = ServerConfig.DefaultColor; Server.moneys = ServerConfig.Currency; #pragma warning restore 0618 if (!Directory.Exists(ServerConfig.BackupDirectory)) { ServerConfig.BackupDirectory = Path.Combine(Utils.FolderPath, "levels/backups"); } Save(); }
public void ApplyToServer() { ZSConfig cfg = ZSGame.Config; cfg.NoPillaring = !Pillaring; cfg.MaxMoveDist = MaxMoveDistance; cfg.HitboxDist = HitboxPrecision; }
public void LoadFromServer() { ZSConfig cfg = ZSGame.Config; Pillaring = !cfg.NoPillaring; MaxMoveDistance = cfg.MaxMoveDist; HitboxPrecision = cfg.HitboxDist; }
public static void LoadAllSettings() { // Unload custom plugins List <Plugin> plugins = new List <Plugin>(Plugin.all); foreach (Plugin p in plugins) { if (Plugin.core.Contains(p)) { continue; } Plugin.Unload(p, false); } ZSGame.Instance.infectMessages = ZSConfig.LoadInfectMessages(); Colors.Load(); Alias.Load(); BlockDefinition.LoadGlobal(); ImagePalette.Load(); SrvProperties.Load(); AuthService.ReloadDefault(); Group.LoadAll(); CommandPerms.Load(); Command.InitAll(); Block.SetBlocks(); AwardsList.Load(); PlayerAwards.Load(); Economy.Load(); WarpList.Global.Filename = "extra/warps.save"; WarpList.Global.Load(); CommandExtraPerms.Load(); ProfanityFilter.Init(); Team.LoadList(); ChatTokens.LoadCustom(); SrvProperties.FixupOldPerms(); CpeExtension.LoadDisabledList(); TextFile announcementsFile = TextFile.Files["Announcements"]; announcementsFile.EnsureExists(); announcements = announcementsFile.GetText(); // Reload custom plugins foreach (Plugin p in plugins) { if (Plugin.core.Contains(p)) { continue; } Plugin.Load(p, false); } OnConfigUpdatedEvent.Call(); }
void SaveChanges() { SaveProperties(); SaveRanks(); SaveCommands(); SaveBlocks(); try { SaveLavaSettings(); } catch { Logger.Log(LogType.Warning, "Error saving Lava Survival settings!"); } try { ZSConfig.SaveSettings(); } catch { Logger.Log(LogType.Warning, "Error saving Zombie Survival settings!"); } SrvProperties.Load(); // loads when saving? CommandPerms.Load(); }
protected internal override void OnBuyCommand(Player p, string message, string[] args) { if (p.money < Price) { p.Message("%WYou don't have enough &3{1} %Wto buy an {0}.", Name, Server.Config.Currency); return; } if (!ZSGame.Instance.Running || !ZSGame.Instance.RoundInProgress) { p.Message("You can only buy an invisiblity potion " + "when a round of zombie survival is in progress."); return; } ZSData data = ZSGame.Get(p); if (data.Invisible) { p.Message("You are already invisible."); return; } ZSConfig cfg = ZSGame.Config; int maxPotions = data.Infected ? cfg.ZombieInvisibilityPotions : cfg.InvisibilityPotions; if (data.InvisibilityPotions >= maxPotions) { p.Message("You cannot buy any more invisibility potions this round."); return; } DateTime end = ZSGame.Instance.RoundEnd; if (DateTime.UtcNow.AddSeconds(60) > end) { p.Message("You cannot buy an invisibility potion during the last minute of a round."); return; } int duration = data.Infected ? cfg.ZombieInvisibilityDuration : cfg.InvisibilityDuration; data.InvisibilityPotions++; int left = maxPotions - data.InvisibilityPotions; p.Message("Lasts for &a{0} %Sseconds. You can buy &a{1} %Smore this round.", duration, left); ZSGame.Instance.GoInvisible(p, duration); Economy.MakePurchase(p, Price, "%3Invisibility: " + duration); }
protected internal override void OnPurchase(Player p, string args) { if (!CheckPrice(p, Price, "an invisibility potion")) { return; } if (!ZSGame.Instance.Running || !ZSGame.Instance.RoundInProgress) { p.Message("You can only buy an invisiblity potion " + "when a round of zombie survival is in progress."); return; } ZSData data = ZSGame.Get(p); if (data.Invisible) { p.Message("You are already invisible."); return; } ZSConfig cfg = ZSGame.Config; int maxPotions = p.infected ? cfg.ZombieInvisibilityPotions : cfg.InvisibilityPotions; if (data.InvisibilityPotions >= maxPotions) { p.Message("You cannot buy any more invisibility potions this round."); return; } DateTime end = ZSGame.Instance.RoundEnd; if (DateTime.UtcNow.AddSeconds(60) > end) { p.Message("You cannot buy an invisibility potion during the last minute of a round."); return; } int duration = p.infected ? cfg.ZombieInvisibilityDuration : cfg.InvisibilityDuration; data.InvisibilityPotions++; int left = maxPotions - data.InvisibilityPotions; p.Message("Lasts for &a{0} &Sseconds. You can buy &a{1} &Smore this round.", duration, left); ZSGame.Instance.GoInvisible(p, duration); Economy.MakePurchase(p, Price, "%3Invisibility: " + duration); }
static void SetMaxMove(Player p, ZSGame game, string[] args) { if (args.Length == 2) { Player.Message(p, "Maxmium move distance is currently &a" + ZSConfig.MaxMoveDistance + " %Sunits apart."); return; } byte distance = 0; if (!CommandParser.GetByte(p, args[2], "Maxmimum move distance", ref distance)) { return; } ZSConfig.MaxMoveDistance = distance; Player.Message(p, "Maximum move distance set to &a" + distance + " %Sunits apart."); ZSConfig.SaveSettings(); }
static void SetHitbox(Player p, ZSGame game, string[] args) { if (args.Length == 2) { Player.Message(p, "Hitbox detection is currently &a" + ZSConfig.HitboxPrecision + " %Sunits apart."); return; } byte precision = 0; if (!CommandParser.GetByte(p, args[2], "Hitbox detection", ref precision)) { return; } ZSConfig.HitboxPrecision = precision; Player.Message(p, "Hitbox detection set to &a" + precision + " %Sunits apart."); ZSConfig.SaveSettings(); }
void LoadZSSettings(string[] allMaps) { zsHelper = new GamesHelper( ZSGame.Instance, zs_cbStart, zs_cbMap, zs_cbMain, zs_btnStart, zs_btnStop, zs_btnEnd, zs_btnAdd, zs_btnRemove, zs_lstUsed, zs_lstNotUsed); zsHelper.Load(allMaps); ZSConfig cfg = ZSGame.Config; zs_numInvHumanDur.Value = cfg.InvisibilityDuration; zs_numInvHumanMax.Value = cfg.InvisibilityPotions; zs_numInvZombieDur.Value = cfg.ZombieInvisibilityDuration; zs_numInvZombieMax.Value = cfg.ZombieInvisibilityPotions; zs_numReviveMax.Value = cfg.ReviveTimes; zs_numReviveEff.Value = cfg.ReviveChance; zs_numReviveLimit.Value = cfg.ReviveTooSlow; zs_txtName.Text = cfg.ZombieName; zs_txtModel.Text = cfg.ZombieModel; }
protected internal override void OnPurchase(Player p, string msg) { if (msg.Length == 0) { OnStoreCommand(p); return; } bool hasAToken = false; for (int i = 0; i < msg.Length; i++) { if (!CheckEscape(msg, i, ref hasAToken)) { p.Message("You can only use {0} and {1} for tokens in infect messages."); return; } } if (!hasAToken) { p.Message("You need to include a \"{0}\" (placeholder for zombie player) " + "and/or a \"{1}\" (placeholder for human player) in the infect message."); return; } if (!CheckPrice(p)) { return; } ZSData data = ZSGame.Get(p); if (data.InfectMessages == null) { data.InfectMessages = new List <string>(); } data.InfectMessages.Add(msg); ZSConfig.AppendPlayerInfectMessage(p.name, msg); p.Message("&aAdded infect message: &f" + msg); Economy.MakePurchase(p, Price, "%3InfectMessage: " + msg); }
protected override void HandleSet(Player p, RoundsGame game, string[] args) { ZSConfig cfg = ZSGame.Config; string prop = args[1]; LevelConfig lCfg = p.level.Config; if (prop.CaselessEq("map")) { p.Message("Pillaring allowed: &b" + lCfg.Pillaring); p.Message("Build type: &b" + lCfg.BuildType); p.Message("Round time: &b{0}" + lCfg.RoundTime.Shorten(true, true)); return; } if (args.Length < 3) { Help(p, "set"); return; } if (prop.CaselessEq("hitbox")) { if (!CommandParser.GetReal(p, args[2], "Hitbox detection", ref cfg.HitboxDist, 0, 4)) { return; } p.Message("Set hitbox detection to &a" + cfg.HitboxDist + " %Sblocks apart"); cfg.Save(); return; } else if (prop.CaselessEq("maxmove")) { if (!CommandParser.GetReal(p, args[2], "Max move distance", ref cfg.MaxMoveDist, 0, 4)) { return; } p.Message("Set max move distance to &a" + cfg.MaxMoveDist + " %Sblocks apart"); cfg.Save(); return; } else if (prop.CaselessEq("pillaring")) { if (!CommandParser.GetBool(p, args[2], ref lCfg.Pillaring)) { return; } p.Message("Set pillaring allowed to &b" + lCfg.Pillaring); game.UpdateAllStatus2(); } else if (prop.CaselessEq("build")) { if (!CommandParser.GetEnum(p, args[2], "Build type", ref lCfg.BuildType)) { return; } p.level.UpdateBlockPermissions(); p.Message("Set build type to &b" + lCfg.BuildType); game.UpdateAllStatus2(); } else if (prop.CaselessEq("roundtime")) { if (!ParseTimespan(p, "round time", args, ref lCfg.RoundTime)) { return; } } else { Help(p, "set"); return; } Level.SaveSettings(p.level); }