public override void Execute(CommandQueue queue, CommandEntry entry) { PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); if (player == null) { queue.HandleError(entry, "Invalid player!"); return; } ItemAssetTag item = ItemAssetTag.For(entry.GetArgument(queue, 1)); if (item == null) { queue.HandleError(entry, "Invalid item!"); return; } byte amount = 1; if (entry.Arguments.Count > 2) { amount = (byte)Utilities.StringToUInt(entry.GetArgument(queue, 2)); } if (ItemTool.tryForceGiveItem(player.Internal.player, item.Internal.id, amount)) { if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully gave a " + TagParser.Escape(item.Internal.name) + "!"); } } else { queue.HandleError(entry, "Failed to give item (is the inventory full?)!"); } }
public static void Execute(CommandQueue queue, CommandEntry entry) { Client TheClient = (entry.Command as GP_BindCommand).TheClient; string key = entry.GetArgument(queue, 0); if (!Enum.TryParse(key, true, out GamePadButton btn)) { queue.HandleError(entry, "Unknown button: " + key); return; } if (entry.Arguments.Count == 1) { CommandScript cs = TheClient.Gamepad.ButtonBinds[(int)btn]; if (cs == null) { queue.HandleError(entry, "That button is not bound, or does not exist."); } else { entry.InfoOutput(queue, btn + ": {\n" + cs.FullString() + "}"); } } else if (entry.Arguments.Count >= 2) { TheClient.Gamepad.BindButton(btn, entry.GetArgument(queue, 1)); entry.GoodOutput(queue, "Keybind updated for " + btn + "."); } }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); if (player == null) { queue.HandleError(entry, "Invalid player!"); return; } ItemAssetTag item = ItemAssetTag.For(entry.GetArgument(queue, 1)); if (item == null) { queue.HandleError(entry, "Invalid item!"); return; } byte amount = 1; if (entry.Arguments.Count > 2) { amount = (byte)Utilities.StringToUInt(entry.GetArgument(queue, 2)); } if (ItemTool.tryForceGiveItem(player.Internal.player, item.Internal.id, amount)) { if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully gave a " + TagParser.Escape(item.Internal.name) + "!"); } } else { queue.HandleError(entry, "Failed to give item (is the inventory full?)!"); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { TemplateObject tcolor = entry.GetArgumentObject(queue, 0); ColorTag color = ColorTag.For(tcolor); if (color == null) { queue.HandleError(entry, "Invalid color: " + TagParser.Escape(tcolor.ToString())); return; } string message = entry.GetArgument(queue, 1); EChatMode chatMode = EChatMode.SAY; if (entry.Arguments.Count > 2) { string mode = entry.GetArgument(queue, 2); try { chatMode = (EChatMode)Enum.Parse(typeof(EChatMode), mode.ToUpper()); } catch (ArgumentException) { queue.HandleError(entry, "Invalid chat mode: " + mode); return; } } ChatManager.manager.channel.send("tellChat", ESteamCall.OTHERS, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[] { CSteamID.Nil, (byte)chatMode, color.Internal, message }); }
public static void Execute(CommandQueue queue, CommandEntry entry) { Client TheClient = (entry.Command as PlayCommand).TheClient; if (entry.Arguments.Count < 1) { ShowUsage(queue, entry); return; } string sfx = entry.GetArgument(queue, 0); float pitch = 1f; float gain = 1f; Location loc = Location.NaN; if (entry.Arguments.Count > 1) { pitch = (float)Utilities.StringToFloat(entry.GetArgument(queue, 1)); } if (entry.Arguments.Count > 2) { gain = (float)Utilities.StringToFloat(entry.GetArgument(queue, 2)); } if (entry.Arguments.Count > 3) { loc = Location.FromString(entry.GetArgument(queue, 3)); } float seek = 0; if (entry.Arguments.Count > 4) { seek = (float)(float)Utilities.StringToFloat(entry.GetArgument(queue, 4)); } entry.Good(queue, "Requesting audio..."); TheClient.Sounds.Play(TheClient.Sounds.GetSound(sfx), false, loc, pitch, gain, seek); }
/// <summary>Executes the command.</summary> /// <param name="queue">The command queue involved.</param> /// <param name="entry">Entry to be executed.</param> public static void Execute(CommandQueue queue, CommandEntry entry) { string configName = entry.GetArgument(queue, 0).ToLowerFast(); AutoConfiguration config = queue.Engine.Context.GetConfig(configName); if (config is null) { queue.HandleError(entry, $"Invalid config name '{TextStyle.SeparateVal(configName)}' - are you sure you typed it correctly?"); return; } string configKey = entry.GetArgument(queue, 1); AutoConfiguration.Internal.SingleFieldData field = config.TryGetFieldInternalData(configKey, out AutoConfiguration section, true); if (field is null) { queue.HandleError(entry, $"Invalid config setting key '{TextStyle.SeparateVal(configKey)}' - are you sure you typed it correctly?"); return; } TemplateObject newValue = entry.GetArgumentObject(queue, 2); object rawValue = ConvertForType(field.Field.FieldType, newValue, queue); field.SetValue(section, rawValue); field.OnChanged?.Invoke(); if (queue.ShouldShowGood()) { queue.GoodOutput($"For config '{TextStyle.SeparateVal(configName)}', set '{TextStyle.SeparateVal(configKey)}' to '{TextStyle.SeparateVal(rawValue)}'"); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(queue, entry); return; } ListTag list = ListTag.For(entry.GetArgument(queue, 0)); string message = "Kicked by the server."; if (entry.Arguments.Count >= 2) { message = "Kicked by the server: " + entry.GetArgument(queue, 1); } for (int i = 0; i < list.ListEntries.Count; i++) { PlayerEntity pl = TheServer.GetPlayerFor(list.ListEntries[i].ToString()); if (pl == null) { entry.Bad(queue, "Unknown player " + TagParser.Escape(list.ListEntries[i].ToString())); } else { pl.Kick(message); } } }
/// <summary>Executes the command.</summary> /// <param name="queue">The command queue involved.</param> /// <param name="entry">Entry to be executed.</param> public static void Execute(CommandQueue queue, CommandEntry entry) { string configName = entry.GetArgument(queue, 0).ToLowerFast(); AutoConfiguration config = queue.Engine.Context.GetConfig(configName); if (config is null) { queue.HandleError(entry, $"Invalid config name '{TextStyle.SeparateVal(configName)}' - are you sure you typed it correctly?"); return; } string configKey = entry.GetArgument(queue, 1); AutoConfiguration.Internal.SingleFieldData field = config.TryGetFieldInternalData(configKey, out AutoConfiguration section, true); if (field is null) { queue.HandleError(entry, $"Invalid config setting key '{TextStyle.SeparateVal(configKey)}' - are you sure you typed it correctly?"); return; } if (field.Field.FieldType != typeof(bool)) { queue.HandleError(entry, $"Invalid config setting key '{TextStyle.SeparateVal(configKey)}' - not a bool. Cannot be toggled."); return; } bool currentValue = (bool)field.GetValue(section); field.SetValue(section, !currentValue); field.OnChanged?.Invoke(); if (queue.ShouldShowGood()) { queue.GoodOutput($"For config '{TextStyle.SeparateVal(configName)}', toggled '{TextStyle.SeparateVal(configKey)}' to '{TextStyle.SeparateVal(!currentValue)}'"); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments[0].ToString() == "\0CALLBACK") { return; } if (entry.Arguments.Count < 3) { ShowUsage(queue, entry); return; } bool servermode = entry.GetArgument(queue, 0).ToLowerFast() == "server"; string name = entry.GetArgument(queue, 1).ToLowerFast(); string help = entry.GetArgument(queue, 2); if (entry.InnerCommandBlock == null) { queue.HandleError(entry, "Event command invalid: No block follows!"); return; } // NOTE: Commands are compiled! CommandScript script = new CommandScript("ut_command_" + name, entry.InnerCommandBlock, entry.BlockStart, queue.CurrentEntry.Types, true) { Debug = DebugMode.MINIMAL }; UnturnedCustomCommand ucc = new UnturnedCustomCommand(name, help, script); if (servermode) { Commander.commands.Insert(1, ucc); } else { UnturnedFreneticMod.Instance.PlayerCommands.Add(ucc); } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Registered command!"); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(queue, entry); return; } string sfx = entry.GetArgument(queue, 0); float pitch = 1f; float gain = 1f; Location loc = Location.NaN; if (entry.Arguments.Count > 1) { pitch = (float)Utilities.StringToFloat(entry.GetArgument(queue, 1)); } if (entry.Arguments.Count > 2) { gain = (float)Utilities.StringToFloat(entry.GetArgument(queue, 2)); } if (entry.Arguments.Count > 3) { loc = Location.FromString(entry.GetArgument(queue, 3)); } float seek = 0; if (entry.Arguments.Count > 4) { seek = (float)(float)Utilities.StringToFloat(entry.GetArgument(queue, 4)); } TheClient.Sounds.Play(TheClient.Sounds.GetSound(sfx), false, loc, pitch, gain, seek); }
public static void Execute(CommandQueue queue, CommandEntry entry) { Client TheClient = (entry.Command as ConnectCommand).TheClient; entry.Good(queue, "Connecting..."); TheClient.Network.Connect(entry.GetArgument(queue, 0), entry.GetArgument(queue, 1), false, entry.GetArgument(queue, 2)); }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { TemplateObject tcolor = entry.GetArgumentObject(queue, 0); ColorTag color = ColorTag.For(tcolor); if (color == null) { queue.HandleError(entry, "Invalid color: " + TagParser.Escape(tcolor.ToString())); return; } string message = entry.GetArgument(queue, 1); EChatMode chatMode = EChatMode.SAY; if (entry.Arguments.Count > 2) { string mode = entry.GetArgument(queue, 2); try { chatMode = (EChatMode)Enum.Parse(typeof(EChatMode), mode.ToUpper()); } catch (ArgumentException) { queue.HandleError(entry, "Invalid chat mode: " + mode); return; } } ChatManager.manager.channel.send("tellChat", ESteamCall.OTHERS, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[] { CSteamID.Nil, (byte)chatMode, color.Internal, message }); }
public override void Execute(CommandQueue queue, CommandEntry entry) { ListTag players = ListTag.For(entry.GetArgument(queue, 0)); TemplateObject tcolor = entry.GetArgumentObject(queue, 1); ColorTag color = ColorTag.For(tcolor); if (color == null) { queue.HandleError(entry, "Invalid color: " + TagParser.Escape(tcolor.ToString())); return; } string tchatter = entry.GetArgument(queue, 2); PlayerTag chatter = PlayerTag.For(tchatter); if (chatter == null) { queue.HandleError(entry, "Invalid chatting player: " + TagParser.Escape(tchatter)); return; } string message = entry.GetArgument(queue, 3); foreach (TemplateObject tplayer in players.ListEntries) { PlayerTag player = PlayerTag.For(tplayer.ToString()); if (player == null) { queue.HandleError(entry, "Invalid player: " + TagParser.Escape(tplayer.ToString())); continue; } ChatManager.manager.channel.send("tellChat", player.Internal.playerID.steamID, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, chatter.Internal.playerID.steamID, (byte)0 /* TODO: Configurable mode? */, color.Internal, message); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully sent a message."); } } }
public static void Execute(CommandQueue queue, CommandEntry entry) { Client TheClient = (entry.Command as BindCommand).TheClient; string key = entry.GetArgument(queue, 0); Key k = KeyHandler.GetKeyForName(key); // TODO: Bad key error if (entry.Arguments.Count == 1) { CommandScript cs = KeyHandler.GetBind(k); if (cs == null) { queue.HandleError(entry, "That key is not bound, or does not exist."); } else { entry.Info(queue, TagParser.Escape(KeyHandler.keystonames[k] + ": {\n" + cs.FullString() + "}")); } } else if (entry.Arguments.Count >= 2) { KeyHandler.BindKey(k, entry.GetArgument(queue, 1)); entry.Good(queue, "Keybind updated for " + KeyHandler.keystonames[k] + "."); } }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); if (player == null) { queue.HandleError(entry, "Invalid player!"); return; } ItemAssetTag item = ItemAssetTag.For(entry.GetArgument(queue, 1)); if (item == null) { queue.HandleError(entry, "Invalid item!"); return; } byte amount = 1; if (entry.Arguments.Count > 2) { amount = (byte)Utilities.StringToUInt(entry.GetArgument(queue, 2)); } PlayerInventory inventory = player.Internal.player.inventory; byte remainingAmount = amount; InventorySearch search; while (remainingAmount > 0 && (search = inventory.has(item.Internal.id)) != null) // TODO: Less awkward code!? { if (search.jar.item.amount <= remainingAmount) { inventory.removeItem(search.page, inventory.getIndex(search.page, search.jar.x, search.jar.y)); remainingAmount -= search.jar.item.amount; } else { inventory.sendUpdateAmount(search.page, search.jar.x, search.jar.y, (byte)(search.jar.item.amount - remainingAmount)); remainingAmount = 0; } } if (remainingAmount == 0) { if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully took " + amount + " " + TagParser.Escape(item.Internal.name) + "!"); } } else if (remainingAmount < amount) { if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully took " + (amount - remainingAmount) + " " + TagParser.Escape(item.Internal.name) + "! (" + remainingAmount + " more not found!)"); } } else { queue.HandleError(entry, "Failed to take item (does the inventory contain any?)!"); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Count < 2) { ShowUsage(queue, entry); return; } entry.Good(queue, "Connecting..."); TheClient.Network.Connect(entry.GetArgument(queue, 0), entry.GetArgument(queue, 1)); }
public override void Execute(CommandQueue queue, CommandEntry entry) { PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); if (player == null) { queue.HandleError(entry, "Invalid player!"); return; } ItemAssetTag item = ItemAssetTag.For(entry.GetArgument(queue, 1)); if (item == null) { queue.HandleError(entry, "Invalid item!"); return; } byte amount = 1; if (entry.Arguments.Count > 2) { amount = (byte)Utilities.StringToUInt(entry.GetArgument(queue, 2)); } PlayerInventory inventory = player.Internal.player.inventory; byte remainingAmount = amount; InventorySearch search; while (remainingAmount > 0 && (search = inventory.has(item.Internal.id)) != null) // TODO: Less awkward code!? { if (search.jar.item.amount <= remainingAmount) { inventory.removeItem(search.page, inventory.getIndex(search.page, search.jar.x, search.jar.y)); remainingAmount -= search.jar.item.amount; } else { inventory.sendUpdateAmount(search.page, search.jar.x, search.jar.y, (byte)(search.jar.item.amount - remainingAmount)); remainingAmount = 0; } } if (remainingAmount == 0) { if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully took " + amount + " " + TagParser.Escape(item.Internal.name) + "!"); } } else if (remainingAmount < amount) { if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully took " + (amount - remainingAmount) + " " + TagParser.Escape(item.Internal.name) + "! (" + remainingAmount + " more not found!)"); } } else { queue.HandleError(entry, "Failed to take item (does the inventory contain any?)!"); } }
/// <summary>Executes the command.</summary> /// <param name="queue">The command queue involved.</param> /// <param name="entry">Entry to be executed.</param> public static void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Length > 1 && BooleanTag.TryFor(entry.GetArgumentObject(queue, 1)).Internal) { throw new Exception("FreneticScript induced exception: '" + entry.GetArgument(queue, 0) + "'"); } else { queue.HandleError(entry, entry.GetArgument(queue, 0)); } }
/// <summary>Executes a define.</summary> /// <param name="queue">The command queue involved.</param> /// <param name="entry">Entry to be executed.</param> public static void Define(CommandEntry entry, CommandQueue queue) { string name = entry.GetArgument(queue, 1).ToLowerFast(); if (queue.Engine.Functions.ContainsKey(name)) { if (BooleanTag.TryFor(entry.GetNamedArgumentObject(queue, "quiet_fail"))?.Internal ?? false) { if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "Function '" + TextStyle.Separate + name + TextStyle.Base + "' already exists!"); } } else { queue.HandleError(entry, "Function '" + TextStyle.Separate + name + TextStyle.Base + "' already exists!"); } } else { queue.Engine.Functions.Add(name, new CommandScript(name, CommandScript.TYPE_NAME_FUNCTION, entry.InnerCommandBlock, entry.System, entry.BlockStart, entry.DBMode)); if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "Function '" + TextStyle.Separate + name + TextStyle.Base + "' defined."); } } }
/// <summary>Executes an undefine.</summary> /// <param name="queue">The command queue involved.</param> /// <param name="entry">Entry to be executed.</param> public static void Undefine(CommandEntry entry, CommandQueue queue) { string name = entry.GetArgument(queue, 1).ToLowerFast(); if (!queue.Engine.Functions.Remove(name)) { if (BooleanTag.TryFor(entry.GetNamedArgumentObject(queue, "quiet_fail"))?.Internal ?? false) { if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "Function '" + TextStyle.Separate + name + TextStyle.Base + "' doesn't exist!"); } } else { queue.HandleError(entry, "Function '" + TextStyle.Separate + name + TextStyle.Base + "' doesn't exist!"); } } else { if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "Function '" + TextStyle.Separate + name + TextStyle.Base + "' undefined."); } } }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { try { IntegerTag num = IntegerTag.TryFor(entry.GetArgumentObject(queue, 1)); if (num == null) { queue.HandleError(entry, "Invalid amount number!"); return; } PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); if (player == null) { queue.HandleError(entry, "Invalid player!"); return; } player.Internal.player.life.askWarm((uint)num.Internal); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully adjusted the warmth level of a player!"); } } catch (Exception ex) // TODO: Necessity? { queue.HandleError(entry, "Failed to adjust player's warmth level: " + ex.ToString()); } }
public override void Execute(CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(entry); return; } string host = entry.GetArgument(0); string port = "28010"; if (entry.Arguments.Count >= 2) { port = entry.GetArgument(1); } ClientNetworkBase.Connect(host, port); }
public static void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(queue, entry); return; } Client TheClient = (entry.Command as GP_BindblockCommand).TheClient; string key = entry.GetArgument(queue, 0); if (key == "\0CALLBACK") { return; } if (entry.InnerCommandBlock == null) { queue.HandleError(entry, "Must have a block of commands!"); return; } if (!Enum.TryParse(key, true, out GamePadButton btn)) { queue.HandleError(entry, "Unknown button: " + key); return; } TheClient.Gamepad.BindButton(btn, entry.InnerCommandBlock, entry.BlockStart); entry.GoodOutput(queue, "Keybind updated for " + btn + "."); CommandStackEntry cse = queue.CommandStack.Peek(); cse.Index = entry.BlockEnd + 2; }
public override void Execute(CommandQueue queue, CommandEntry entry) { string key = entry.GetArgument(queue, 0); Key k = KeyHandler.GetKeyForName(key); KeyHandler.BindKey(k, (string)null); entry.Good(queue, "Keybind removed for " + k + "."); }
public override void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(queue, entry); return; } Location start = TheClient.Player.GetEyePosition(); Location forward = TheClient.Player.ForwardVector(); Location end = start + forward * 5; switch (entry.GetArgument(queue, 0).ToLowerFast()) { case "cylinder": TheClient.Particles.Engine.AddEffect(ParticleEffectType.CYLINDER, (o) => start, (o) => end, (o) => 0.01f, 5f, Location.One, Location.One, true, TheClient.Textures.GetTexture("common/smoke")); break; case "line": TheClient.Particles.Engine.AddEffect(ParticleEffectType.LINE, (o) => start, (o) => end, (o) => 1f, 5f, Location.One, Location.One, true, TheClient.Textures.GetTexture("common/smoke")); break; case "explosion_small": TheClient.Particles.Explode(end, 2, 40); break; case "explosion_large": TheClient.Particles.Explode(end, 5); break; case "path_mark": TheClient.Particles.PathMark(end, () => TheClient.Player.GetPosition()); break; default: entry.Bad(queue, "Unknown effect name."); return; } entry.Good(queue, "Created effect."); }
public override void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(queue, entry); return; } string key = entry.GetArgument(queue, 0); if (key == "\0CALLBACK") { return; } if (entry.InnerCommandBlock == null) { queue.HandleError(entry, "Must have a block of commands!"); return; } Key k = KeyHandler.GetKeyForName(key); KeyHandler.BindKey(k, entry.InnerCommandBlock, entry.BlockStart); entry.Good(queue, "Keybind updated for " + KeyHandler.keystonames[k] + "."); CommandStackEntry cse = queue.CommandStack.Peek(); cse.Index = entry.BlockEnd + 2; }
public override void Execute(CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(entry); } else { string modechoice = entry.GetArgument(0); switch (modechoice.ToLower()) { case "full": entry.Queue.Debug = DebugMode.FULL; entry.Good("Queue debug mode set to <{color.emphasis}>full<{color.base}>."); break; case "minimal": entry.Queue.Debug = DebugMode.MINIMAL; entry.Good("Queue debug mode set to <{color.emphasis}>minimal<{color.base}>."); break; case "none": entry.Queue.Debug = DebugMode.NONE; entry.Good("Queue debug mode set to <{color.emphasis}>none<{color.base}>."); break; default: entry.Bad("Unknown debug mode '<{color.emphasis}>" + modechoice + "<{color.base}>'."); break; } } }
public override void Execute(CommandQueue queue, CommandEntry entry) { try { IntegerTag num = IntegerTag.TryFor(entry.GetArgumentObject(queue, 1)); if (num == null) { queue.HandleError(entry, "Invalid amount number!"); return; } PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); if (player == null) { queue.HandleError(entry, "Invalid player!"); return; } player.Internal.player.life.askWarm((uint)num.Internal); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully adjusted the warmth level of a player!"); } } catch (Exception ex) // TODO: Necessity? { queue.HandleError(entry, "Failed to adjust player's warmth level: " + ex.ToString()); } }
public static void Execute(CommandQueue queue, CommandEntry entry) { Client TheClient = (entry.Command as StartlocalserverCommand).TheClient; string arg0 = "28010"; if (entry.Arguments.Count >= 1) { arg0 = entry.GetArgument(queue, 0); } string game = "default"; if (entry.Arguments.Count >= 2) { game = entry.GetArgument(queue, 1); } if (TheClient.LocalServer != null) { entry.Good(queue, "Shutting down pre-existing server."); TheClient.LocalServer.ShutDown(); TheClient.LocalServer = null; } entry.Good(queue, "Generating new server..."); TheClient.LocalServer = new Server(Utilities.StringToInt(arg0)); Server.Central = TheClient.LocalServer; Action callback = null; if (entry.WaitFor && queue.WaitingOn == entry) { callback = () => { queue.WaitingOn = null; }; } Task.Factory.StartNew(() => { try { TheClient.LocalServer.StartUp(game, callback); } catch (Exception ex) { Utilities.CheckException(ex); SysConsole.Output("Running local server", ex); } }); }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { try { LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1)); if (loc == null) { queue.HandleError(entry, "Invalid location!"); return; } EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0)); if (entity == null) { queue.HandleError(entry, "Invalid entity!"); return; } PlayerTag player; if (entity.TryGetPlayer(out player)) { player.Internal.player.gameObject.AddComponent <LaunchComponent>().LaunchPlayer(loc.ToVector3()); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully launched player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!"); } return; } ZombieTag zombie; if (entity.TryGetZombie(out zombie)) { zombie.Internal.gameObject.AddComponent <LaunchComponent>().Launch(loc.ToVector3()); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully launched zombie " + TagParser.Escape(zombie.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!"); } return; } AnimalTag animal; if (entity.TryGetAnimal(out animal)) { animal.Internal.gameObject.AddComponent <LaunchComponent>().Launch(loc.ToVector3()); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully launched animal " + TagParser.Escape(animal.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!"); } return; } ItemEntityTag item; if (entity.TryGetItem(out item)) { // TODO: Find some way to teleport items, barricades, etc without voiding the InstanceID? } queue.HandleError(entry, "That entity can't be launched!"); } catch (Exception ex) // TODO: Necessity? { queue.HandleError(entry, "Failed to launch entity: " + ex.ToString()); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { try { LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1)); if (loc == null) { queue.HandleError(entry, "Invalid location!"); return; } EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0)); if (entity == null) { queue.HandleError(entry, "Invalid entity!"); return; } PlayerTag player; if (entity.TryGetPlayer(out player)) { player.Internal.player.gameObject.AddComponent<LaunchComponent>().LaunchPlayer(loc.ToVector3()); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully launched player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!"); } return; } ZombieTag zombie; if (entity.TryGetZombie(out zombie)) { zombie.Internal.gameObject.AddComponent<LaunchComponent>().Launch(loc.ToVector3()); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully launched zombie " + TagParser.Escape(zombie.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!"); } return; } AnimalTag animal; if (entity.TryGetAnimal(out animal)) { animal.Internal.gameObject.AddComponent<LaunchComponent>().Launch(loc.ToVector3()); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully launched animal " + TagParser.Escape(animal.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!"); } return; } ItemEntityTag item; if (entity.TryGetItem(out item)) { // TODO: Find some way to teleport items, barricades, etc without voiding the InstanceID? } queue.HandleError(entry, "That entity can't be launched!"); } catch (Exception ex) // TODO: Necessity? { queue.HandleError(entry, "Failed to launch entity: " + ex.ToString()); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(queue, entry); return; } entry.Good(queue, "'<{color.emphasis}>" + TagParser.Escape(entry.GetArgument(queue, 0)) + "<{color.base}>' to you as well from " + ThePlugin.Name + "!"); }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { IntegerTag num = IntegerTag.TryFor(entry.GetArgumentObject(queue, 2)); if (num == null) { queue.HandleError(entry, "Invalid amount number!"); return; } PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); if (player == null) { queue.HandleError(entry, "Invalid player!"); return; } bool award = entry.GetArgument(queue, 1) == "award"; if (num.Internal > 0) { PlayerSkills skills = player.Internal.player.skills; if (award) { skills._experience += (uint)num.Internal; } else { skills._experience -= (uint)num.Internal; } skills.channel.send("tellExperience", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { skills.experience }); } else { queue.HandleError(entry, "Amount must be positive!"); return; } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully " + (award ? "awarded experience to" : "took experience from") + " a player!"); } }
public static void Execute(CommandQueue queue, CommandEntry entry) { Client TheClient = (entry.Command as UnbindCommand).TheClient; string key = entry.GetArgument(queue, 0); Key k = KeyHandler.GetKeyForName(key); // TODO: Bad-key error. KeyHandler.BindKey(k, (string)null); entry.Good(queue, "Keybind removed for " + k + "."); }
public override void Execute(CommandQueue queue, CommandEntry entry) { string text = ""; if (entry.Arguments.Count > 0) { text = entry.GetArgument(queue, 0); } TheClient.ShowChat(); TheClient.SetChatText(text); }
public override void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(queue, entry); return; } TheServer.Files.LoadDir(entry.GetArgument(queue, 0)); entry.Good(queue, "Added path."); }
/// <summary>Executes the command.</summary> /// <param name="queue">The command queue involved.</param> /// <param name="entry">Entry to be executed.</param> public static void Execute(CommandQueue queue, CommandEntry entry) { string cmd = entry.GetArgument(queue, 0); if (!entry.Command.Engine.RegisteredCommands.TryGetValue(cmd, out AbstractCommand acmd)) { queue.HandleError(entry, "Unrecognized command name!"); return; } ShowUsage(queue, entry, false, acmd); }
public override void Execute(CommandQueue queue, CommandEntry entry) { IntegerTag num = IntegerTag.TryFor(entry.GetArgumentObject(queue, 2)); if (num == null) { queue.HandleError(entry, "Invalid amount number!"); return; } PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); if (player == null) { queue.HandleError(entry, "Invalid player!"); return; } bool award = entry.GetArgument(queue, 1) == "award"; if (num.Internal > 0) { PlayerSkills skills = player.Internal.player.skills; if (award) { skills._experience += (uint)num.Internal; } else { skills._experience -= (uint)num.Internal; } skills.channel.send("tellExperience", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { skills.experience }); } else { queue.HandleError(entry, "Amount must be positive!"); return; } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully " + (award ? "awarded experience to" : "took experience from") + " a player!"); } }
public static void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(queue, entry); return; } Server TheServer = (entry.Command as AddpathCommand).TheServer; TheServer.Files.LoadDir(entry.GetArgument(queue, 0)); entry.Good(queue, "Added path."); }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1)); if (loc == null) { queue.HandleError(entry, "Invalid location!"); return; } EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0)); if (entity == null) { queue.HandleError(entry, "Invalid entity!"); return; } ZombieTag zombie; if (entity.TryGetZombie(out zombie)) { zombie.Internal.target.position = loc.ToVector3(); zombie.Internal.seeker.canMove = true; zombie.Internal.seeker.canSearch = true; zombie.Internal.path = EZombiePath.RUSH; // TODO: Option for this? if (!zombie.Internal.isTicking) { zombie.Internal.isTicking = true; ZombieManager.tickingZombies.Add(zombie.Internal); } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully started a zombie walking to " + TagParser.Escape(loc.ToString()) + "!"); } return; } AnimalTag animal; if (entity.TryGetAnimal(out animal)) { animal.Internal.target = loc.ToVector3(); if (!animal.Internal.isTicking) { animal.Internal.isTicking = true; AnimalManager.tickingAnimals.Add(animal.Internal); } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully started an animal walking to " + TagParser.Escape(loc.ToString()) + "!"); } return; } queue.HandleError(entry, "That entity can't be made to walk!"); }
public static void Execute(CommandQueue queue, CommandEntry entry) { Client TheClient = (entry.Command as TalkCommand).TheClient; string text = ""; if (entry.Arguments.Count > 0) { text = entry.GetArgument(queue, 0); } TheClient.ShowChat(); TheClient.SetChatText(text); }
public override void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Count < 2) { ShowUsage(queue, entry); return; } string ip = entry.GetArgument(queue, 0); string port = entry.GetArgument(queue, 1); TheClient.Network.Ping(ip, port, (info) => { if (info.Success) { UIConsole.WriteLine("^r^2Ping success(" + ip + " " + port + "): " + info.Message + " (" + info.Ping + "ms)"); } else { UIConsole.WriteLine("^r^1Ping failure (" + ip + " " + port + "): " + info.Message); } }); }
public override void Execute(CommandQueue queue, CommandEntry entry) { PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); bool primary = entry.GetArgument(queue, 1) == "primary"; bool start = BooleanTag.TryFor(entry.GetArgumentObject(queue, 2)).Internal; if (player.Internal.player.equipment.useable == null) { entry.Bad(queue, "Failed to use item, holding nothing."); return; } if (primary) { if (start) { player.Internal.player.equipment.useable.startPrimary(); } else { player.Internal.player.equipment.useable.stopPrimary(); } } else { if (start) { player.Internal.player.equipment.useable.startSecondary(); } else { player.Internal.player.equipment.useable.stopSecondary(); } } player.Internal.player.equipment.useable.tick(); player.Internal.player.equipment.useable.tock(player.Internal.player.input.clock); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Player is " + (start ? "now" : "no longer") + " using the " + (primary ? "primary" : "secondary") + " mode on their held item!"); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1)); if (loc == null) { queue.HandleError(entry, "Invalid location!"); return; } string targetAssetType = entry.GetArgument(queue, 0).ToLower(); EffectAssetTag effectType = EffectAssetTag.For(targetAssetType); if (effectType == null) { queue.HandleError(entry, "Invalid effect type!"); return; } EffectManager.sendEffect(effectType.Internal.id, EffectManager.INSANE, loc.ToVector3()); // TODO: radius option instead of always 512 units (INSANE)! if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Played effect " + TagParser.Escape(effectType.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!"); } }
public override void Execute(CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(entry); } else { bool modechoice = entry.GetArgument(0).ToLower() == "on"; entry.Queue.ParseTags = modechoice; entry.Good("Queue parsing <{color.emphasis}>" + (modechoice ? "enabled" : "disabled") + "<{color.base}>."); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { string key = entry.GetArgument(queue, 0); Key k = KeyHandler.GetKeyForName(key); if (entry.Arguments.Count == 1) { CommandScript cs = KeyHandler.GetBind(k); if (cs == null) { queue.HandleError(entry, "That key is not bound, or does not exist."); } else { entry.Info(queue, TagParser.Escape(KeyHandler.keystonames[k] + ": {\n" + cs.FullString() + "}")); } } else if (entry.Arguments.Count >= 2) { KeyHandler.BindKey(k, entry.GetArgument(queue, 1)); entry.Good(queue, "Keybind updated for " + KeyHandler.keystonames[k] + "."); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments.Count < 1) { entry.Bad(queue, "Must specify a slot number!"); return; } if (TheClient.Player.ServerFlags.HasFlag(YourStatusFlags.RELOADING)) { return; } int slot = Math.Abs(Utilities.StringToInt(entry.GetArgument(queue, 0))) % (TheClient.Items.Count + 1); TheClient.SetHeldItemSlot(slot, DEFAULT_RENDER_EXTRA_ITEMS); }
/// <summary> /// Executes the command. /// </summary> /// <param name="entry">Entry to be executed.</param> public override void Execute(CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(entry); } else { string name = entry.GetArgument(0); List<string> args = new List<string>(entry.Arguments); args.RemoveAt(0); entry.Output.UnknownCommand(entry.Queue, name, args.ToArray()); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1)); if (loc == null) { queue.HandleError(entry, "Invalid location!"); return; } EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0)); if (entity == null) { queue.HandleError(entry, "Invalid entity!"); return; } ZombieTag zombie; if (entity.TryGetZombie(out zombie)) { zombie.Internal.target.position = loc.ToVector3(); zombie.Internal.seeker.canMove = true; zombie.Internal.seeker.canSearch = true; zombie.Internal.path = EZombiePath.RUSH; // TODO: Option for this? if (!zombie.Internal.isTicking) { zombie.Internal.isTicking = true; ZombieManager.tickingZombies.Add(zombie.Internal); } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully started a zombie walking to " + TagParser.Escape(loc.ToString()) + "!"); } return; } AnimalTag animal; if (entity.TryGetAnimal(out animal)) { animal.Internal.target = loc.ToVector3(); if (!animal.Internal.isTicking) { animal.Internal.isTicking = true; AnimalManager.tickingAnimals.Add(animal.Internal); } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully started an animal walking to " + TagParser.Escape(loc.ToString()) + "!"); } return; } queue.HandleError(entry, "That entity can't be made to walk!"); }
public override void Execute(CommandQueue queue, CommandEntry entry) { try { BooleanTag boolean = BooleanTag.TryFor(entry.GetArgumentObject(queue, 1)); if (boolean == null) { queue.HandleError(entry, "Invalid boolean!"); return; } PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); if (player == null) { queue.HandleError(entry, "Invalid player!"); return; } bool value = boolean.Internal; PlayerLife life = player.Internal.player.life; if (life.isBroken != value) { if (value) { life.breakLegs(); } else { life._isBroken = false; life.channel.send("tellBroken", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { life._isBroken }); } entry.Good(queue, "Successfully adjusted the broken legs of player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(boolean.ToString()) + "!"); } else { entry.Good(queue, "Player " + TagParser.Escape(player.ToString()) + " already has their broken legs set to " + TagParser.Escape(boolean.ToString()) + "!"); } } catch (Exception ex) // TODO: Necessity? { queue.HandleError(entry, "Failed to adjust player's broken legs: " + ex.ToString()); } }
public override void Execute(CommandEntry entry) { int count = 1; if (entry.Arguments.Count > 0) { count = StringToInt(entry.GetArgument(0)); } if (count <= 0) { ShowUsage(entry); return; } CommandEntry Owner = entry.BlockOwner; while (entry.Queue.CommandList.Length > 0 && count > 0) { if (Owner == null) { entry.Bad("Tried to break <{color.emphasis}>" + count + "<{color.base}> more brace" + (count == 1 ? "" : "s") + " than there are!"); return; } CommandEntry compOwner = entry.Queue.GetCommand(0).BlockOwner; if (compOwner == Owner) { entry.Queue.RemoveCommand(0); } else { Owner = compOwner; count--; } } count--; if (count > 0) { entry.Bad("Tried to break <{color.emphasis}>" + count + "<{color.base}> more brace" + (count == 1 ? "": "s") + " than there are!"); } else { entry.Good("Broke through all layers."); } }
public override void Execute(CommandQueue queue, CommandEntry entry) { try { BooleanTag boolean = BooleanTag.TryFor(entry.GetArgumentObject(queue, 1)); if (boolean == null) { queue.HandleError(entry, "Invalid boolean!"); return; } PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0)); if (player == null) { queue.HandleError(entry, "Invalid player!"); return; } bool value = boolean.Internal; PlayerLife life = player.Internal.player.life; if (life._isBleeding != value) { life._isBleeding = value; if (value) { uint sim = life.player.input.simulation; life.lastBleeding = sim; life.lastBleed = sim; } life.channel.send("tellBleeding", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { life.isBleeding }); entry.Good(queue, "Successfully adjusted the bleeding of player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(boolean.ToString()) + "!"); } else { entry.Good(queue, "Player " + TagParser.Escape(player.ToString()) + " already has their bleeding set to " + TagParser.Escape(boolean.ToString()) + "!"); } } catch (Exception ex) // TODO: Necessity? { queue.HandleError(entry, "Failed to adjust player's bleeding state: " + ex.ToString()); } }
public override void Execute(CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(entry); } else { string delay = entry.GetArgument(0); float seconds = StringToFloat(delay); if (entry.Queue.Delayable) { entry.Good("Delaying for <{color.emphasis}>" + seconds + "<{color.base}> seconds."); entry.Queue.Wait = seconds; } else { entry.Bad("Cannot delay, inside an instant queue!"); } } }
public override void Execute(CommandEntry entry) { if (entry.Arguments.Count < 1) { ShowUsage(entry); } else { string fname = entry.GetArgument(0); CommandScript script = entry.Queue.CommandSystem.GetScript(fname); if (script != null) { entry.Good("Inserting '<{color.emphasis}>" + TagParser.Escape(fname) + "<{color.base}>'..."); entry.Queue.AddCommandsNow(script.GetEntries()); } else { entry.Bad("Cannot insert script '<{color.emphasis}>" + TagParser.Escape(fname) + "<{color.base}>': file does not exist!"); } } }
public override void Execute(CommandEntry entry) { if (entry.Arguments.Count > 0 && entry.GetArgument(0).ToLower() == "all") { int qCount = entry.Queue.CommandSystem.Queues.Count; if (!entry.Queue.CommandSystem.Queues.Contains(entry.Queue)) { qCount++; } entry.Good("Stopping <{color.emphasis}>" + qCount + "<{color.base}> queue" + (qCount == 1 ? "." : "s.")); foreach (CommandQueue queue in entry.Queue.CommandSystem.Queues) { queue.Stop(); } entry.Queue.Stop(); } else { entry.Good("Stopping current queue."); entry.Queue.Stop(); } }