private void CmdConsoleHandler(ConsoleSystem.Arg args) { BasePlayer player = args.Player(); if (player == null || !args.HasArgs(1)) { return; } switch (args.Args[0].ToLower()) { case "show": { if (!args.HasArgs(2)) { return; } int index = 0; if (!int.TryParse(args.Args[1], out index) || Settings.Servers.ElementAtOrDefault(index) == null) { return; } UI_DrawInterface(player, index); break; } case "hide": { UI_DrawInterface(player, -2); break; } } }
void ConsoleCommand_vehicleshop_give(ConsoleSystem.Arg arg) { BasePlayer p = arg?.Player() ?? null; if (p != null && !p.IsAdmin) { return; } if (!arg.HasArgs(2)) { SendReply(arg, _(p, "ConsoleSyntax", string.Join("|", VehicleInfo.ShortNameList()))); return; } BasePlayer player = BasePlayer.Find(arg.GetString(0)); if (player == null) { SendReply(arg, _(p, "PlayerNotFound", arg.GetString(0))); return; } VehicleInfo vehicle = VehicleInfo.FindByShortname(arg.GetString(1)); if (vehicle == null) { SendReply(arg, _(p, "VehicleNotFound", arg.GetString(1))); SendReply(arg, _(p, "ConsoleSyntax", string.Join("|", VehicleInfo.ShortNameList()))); return; } string shortname = _config.vehicleShortPrefabName; if (arg.HasArgs(3) && arg.GetString(2) != "default") { ItemDefinition info = ItemManager.FindItemDefinition(arg.GetString(2)); if (info == null) { SendReply(arg, _(p, "ShortnameNotFound", arg.GetString(2))); return; } shortname = info.shortname; } SendReply(arg, _(p, "SuccessfullyGive", vehicle.Give(player, shortname, arg.GetString(3, "console")), player.displayName)); }
private void OnConsoleCommandInfoClose(ConsoleSystem.Arg arg) { if (arg.Connection == null || arg.Connection.player == null || !arg.HasArgs()) { return; } var player = (BasePlayer)arg.Connection.player; switch (arg.Args[0]) { case "open": if (arg.Args.Length < 2) { break; } CreateGUI(player, arg.Args[1]); break; case "close": DestroyGUI(player); break; case "buy": if (arg.Args.Length < 2) { break; } BuyItem(player, arg.Args[1]); break; } }
private void CraftCommandConsole(ConsoleSystem.Arg arg) { if (!arg.HasArgs()) { arg.ReplyWith(string.Format(CurrentCraftingRate, CraftingRate)); return; } if (arg.Player() != null && !arg.Player().IsAdmin()) { arg.ReplyWith(NoPermission); return; } var rate = arg.GetFloat(0, -1f); if (rate == -1f) { arg.ReplyWith(ModifyError); return; } CraftingRate = rate; SetConfigValue("Options", "CraftingRate", rate); UpdateCraftingRate(); arg.ReplyWith(string.Format(ModifyCraftingRate, CraftingRate)); }
private void commandSetDecayTime(ConsoleSystem.Arg arg) { BasePlayer player = arg.Player(); if (player != null && !player.IsAdmin) { return; } int value; if (arg.HasArgs() && int.TryParse(arg.Args[0], out value)) { if (value < decayTimeMinimum) { value = decayTimeMinimum; } else if (value > decayTimeMaximum) { value = decayTimeMaximum; } decayTime = value; Config["decaytime"] = decayTime; SaveConfig(); } arg.ReplyWith("hwb.decaytime: " + decayTime.ToString() + " second(s)"); }
private void ConsoleReload(ConsoleSystem.Arg arg) { if (arg.argUser != null && !arg.argUser.admin) { return; } if (!IsAdmin(arg)) { return; } if (!arg.HasArgs()) { arg.ReplyWith("Usage: reload *|<pluginname>+"); return; } if (arg.GetString(0).Equals("*")) { Interface.Oxide.ReloadAllPlugins(); return; } foreach (var name in arg.Args) { if (!string.IsNullOrEmpty(name)) { Interface.Oxide.ReloadPlugin(name); } } }
//////////////////////////////////////// /// Console Command Handling //////////////////////////////////////// void RunAsChatCommand(ConsoleSystem.Arg arg, Action <BasePlayer, string, string[]> command) { if (arg == null) { return; } BasePlayer player = null; string cmd = string.Empty; string[] args = new string[0]; if (arg.HasArgs()) { args = arg.Args; } if (arg.connection.player == null) { return; } player = arg.connection.player as BasePlayer; cmd = arg.cmd?.name ?? "unknown"; command(player, cmd, args); }
private void ResetStatsCmd(ConsoleSystem.Arg arg) { if (!arg.IsRcon) { return; } if (!arg.HasArgs()) { return; } if (arg.Args.Count() != 1) { PrintWarning($"Usage : stats.reset <SteamID64>"); return; } string ID = arg.Args[0]; if (!ID.IsSteamId()) { PrintWarning(string.Format(msg("ConsoleNotFoundMSG"), new object[] { ID })); return; } string Name = GetPlayer(ulong.Parse(ID)); PrintWarning(string.Format(msg("ConsoleResetMSG"), new object[] { Name })); }
private void CmdUnload(ConsoleSystem.Arg arg) { if (!IsAdmin(arg)) { return; } if (!arg.HasArgs()) { ReplyWith(arg.connection, "CommandUsageUnload"); return; } if (arg.GetString(0).Equals("*")) { Interface.Oxide.UnloadAllPlugins(); return; } foreach (var name in arg.Args) { if (!string.IsNullOrEmpty(name)) { Interface.Oxide.UnloadPlugin(name); } } }
void AddGloballyAllowedCommand(ConsoleSystem.Arg arg) { if (!arg.HasArgs(1)) { arg.ReplyWith("[AdminRestrictions]: Invalid syntax: adminrestrictions.addgloballyallowedcommand <command.name> [<command.name>...]"); return; } int processed = 0; for (int i = 0; i < arg.Args.Length; i++) { var command = arg.Args[i]; if (string.IsNullOrWhiteSpace(command)) { continue; } if (_configuration.globallyAllowedCommands.Contains(command)) { continue; } _configuration.globallyAllowedCommands.Add(command); processed++; } if (processed > 0) { SaveConfiguration(); } arg.ReplyWith("[AdminRestrictions]: Added " + processed + " command(s) to the globally allowed list"); }
void RemoveGloballyBlockedCommand(ConsoleSystem.Arg arg) { if (!arg.HasArgs(1)) { arg.ReplyWith("[AdminRestrictions]: Invalid syntax: adminrestrictions.removegloballyblockedcommand <command.name> [<command.name>...]"); return; } int processed = 0; for (int i = 0; i < arg.Args.Length; i++) { var command = arg.Args[i]; if (string.IsNullOrWhiteSpace(command)) { continue; } if (!_configuration.globallyBlockedCommands.Remove(command)) { continue; } processed++; } if (processed > 0) { SaveConfiguration(); } arg.ReplyWith("[AdminRestrictions]: Removed " + processed + " command(s) from the globally blocked list"); }
private void ConsoleLoad(ConsoleSystem.Arg arg) { if (!IsAdmin(arg.Player())) { return; } if (!arg.HasArgs()) { Reply(arg.connection, "CommandUsageLoad"); return; } if (arg.GetString(0).Equals("*")) { Interface.Oxide.LoadAllPlugins(); return; } foreach (var name in arg.Args) { if (string.IsNullOrEmpty(name)) { continue; } Interface.Oxide.LoadPlugin(name); pluginmanager.GetPlugin(name); } }
private void ConsoleCommand_TotalStacks(ConsoleSystem.Arg arg) { var player = arg.Player(); var lootSource = player.inventory.loot?.entitySource as BaseOven; if (lootSource == null || !compatibleOvens.Contains(lootSource.ShortPrefabName)) { player.ConsoleMessage("Current loot source invalid"); return; } string ovenName = lootSource.ShortPrefabName; var playerOption = allPlayerOptions[player.userID]; if (playerOption.TotalStacks.ContainsKey(ovenName)) { if (!arg.HasArgs()) { player.ConsoleMessage(playerOption.TotalStacks[ovenName].ToString()); } else { var newValue = (int)Mathf.Clamp(arg.GetInt(0), 0, lootSource.inventory.capacity); playerOption.TotalStacks[ovenName] = newValue; } } else { player.ConsoleMessage("Unsupported furnace '" + ovenName + "'"); } CreateUiIfFurnaceOpen(player); }
private void OnConsoleCommandCinfo(ConsoleSystem.Arg arg) { if (arg.Connection == null || arg.Connection.player == null || !arg.HasArgs()) { return; } BasePlayer player = (BasePlayer)arg.Connection.player; PlayerData.PData pdata = PlayerData.Get(player); if (player == null || pdata == null) { return; } switch (arg.GetString(0)) { case "close": DestroyUI(player); break; case "page": UpdatePageUI(player, arg.GetString(1, "welcome")); break; case "settings": pdata.SetSetting(arg.GetString(1), arg.GetString(2)); UpdateSettingsUI(player); break; } }
private void OnConsoleCommandTeleport(ConsoleSystem.Arg arg) { if (arg.Connection == null || arg.Connection.player == null || !arg.HasArgs()) { return; } BasePlayer player = (BasePlayer)arg.Connection.player; switch (arg.GetString(0)) { case "home": switch (arg.GetString(1)) { case "close": DestroyHomeUI(player); break; case "add": AddHome(player, arg.GetString(2, "1")); break; case "remove": DeleteHome(player, arg.GetString(2, "1")); break; case "teleport": TeleportHome(player, arg.GetString(2, "1")); DestroyHomeUI(player); break; case "index": UpdateHomeUI(player, arg.GetInt(2, 0)); break; } break; case "tpr": switch (arg.GetString(1)) { case "close": DestroyTprUI(player); break; case "request": DestroyTprUI(player); BasePlayer target = Helper.FindPlayerById(arg.GetUInt64(2)); if (target != null) { TeleportRequest(player, target); } break; case "index": UpdateTprUI(player, BasePlayer.activePlayerList, arg.GetInt(2, 0)); break; } break; } }
void cmdMultiplier(ConsoleSystem.Arg args) { if (args.Player() != null) { if (!args.Player().IsAdmin() && !permission.UserHasPermission(args.Player().UserIDString, "antilootdespawn.multiplier")) { return; } } else { if (!args.CheckPermissions()) { return; } } if (args.HasArgs()) { despawnMultiplier = Convert.ToSingle(args.Args[0]); Config["multiplier"] = despawnMultiplier; SaveConfig(); } args.ReplyWith($"antilootdespawn.multiplier = {despawnMultiplier}"); }
private void CmdUnload(ConsoleSystem.Arg arg) { if (!IsAdmin(arg)) { return; } if (!arg.HasArgs()) { arg.ReplyWith("Syntax: unload *|<pluginname>+"); return; } if (arg.GetString(0).Equals("*")) { Interface.Oxide.UnloadAllPlugins(); return; } foreach (var name in arg.Args) { if (!string.IsNullOrEmpty(name)) { Interface.Oxide.UnloadPlugin(name); } } }
void cmdEnabled(ConsoleSystem.Arg args) { if (args.Player() != null) { if (!args.Player().IsAdmin() && !permission.UserHasPermission(args.Player().UserIDString, "antilootdespawn.enabled")) { return; } } else { if (!args.CheckPermissions()) { return; } } if (args.HasArgs()) { enabled = (args.Args[0] == "true" ? true : args.Args[0] == "false" ? false : args.Args[0] == "1" ? true : args.Args[0] == "0" ? false : true); Config["enabled"] = enabled; SaveConfig(); } args.ReplyWith($"antilootdespawn.enabled = {enabled}"); }
private void CmdLoad(ConsoleSystem.Arg arg) { if (!IsAdmin(arg)) { return; } if (!arg.HasArgs()) { arg.ReplyWith("Usage: load *|<pluginname>+"); return; } if (arg.GetString(0).Equals("*")) { Interface.Oxide.LoadAllPlugins(); return; } foreach (var name in arg.Args) { if (string.IsNullOrEmpty(name)) { continue; } Interface.Oxide.LoadPlugin(name); pluginmanager.GetPlugin(name); } }
private object OnServerCommand(ConsoleSystem.Arg arg) { if (arg?.cmd?.FullName == null || arg.cmd.FullName != "global.say") { return(null); } BasePlayer player = arg.Player(); if (player != null && !permission.UserHasPermission(player.UserIDString, "bettersay.use")) { arg.ReplyWith(lang.GetMessage("No Permission", this, player.UserIDString)); return(true); } if (!arg.HasArgs()) { arg.ReplyWith(lang.GetMessage("Syntax Reminder", this)); return(true); } string chatOutput = _config.Format .Replace("{Title}", $"[#{_config.TitleColor.TrimStart('#')}]{_config.Title}[/#]") .Replace("{Message}", $"[#{_config.MessageColor.TrimStart('#')}]{string.Join(" ", arg.Args)}[/#]"); string consoleOutput = _config.Format .Replace("{Title}", _config.Title) .Replace("{Message}", string.Join(" ", arg.Args)); Server.Broadcast(chatOutput, _config.ChatIcon); Puts(consoleOutput); return(true); }
private void ExcavatorTickRate(ConsoleSystem.Arg arg) { if (arg.Player() != null && !arg.Player().IsAdmin) { arg.ReplyWith(NotAllowed); return; } if (!arg.HasArgs()) { arg.ReplyWith(InvalidArgumentsSpeed); return; } var modifier = arg.GetFloat(0, -1); if (modifier < 1) { arg.ReplyWith(InvalidSpeed); return; } ExcavatorResourceTickRate = modifier; SetConfigValue("Options", "ExcavatorResourceTickRate", ExcavatorResourceTickRate); arg.ReplyWith(string.Format(ModifySpeed, modifier)); var excavators = UnityEngine.Object.FindObjectsOfType <MiningQuarry>(); foreach (var excavator in excavators.Where(excavator => excavator.IsOn())) { excavator.CancelInvoke("ProcessResources"); excavator.InvokeRepeating("ProcessResources", ExcavatorResourceTickRate, ExcavatorResourceTickRate); } }
private void menubutton(ConsoleSystem.Arg arg) { if (arg.HasArgs(2)) { UserInfo.HandleMenuButton(arg.Player(), arg.Args[0], arg.Args[1]); } }
private void GCConsoleCommand(ConsoleSystem.Arg arg) { if (!arg.IsRcon) { arg.ReplyWith(Lang("NoPermission")); return; } if (!arg.HasArgs()) { arg.ReplyWith(Lang("InvalidSyntax")); return; } switch (arg.GetString(0).ToLower()) { case "start": StartEvent(null, arg.Args.Skip(1).ToArray()); break; case "stop": StopEvents(null); break; default: arg.ReplyWith(Lang("InvalidSyntax")); break; } }
private void menuonoffbutton(ConsoleSystem.Arg arg) { if (arg.HasArgs()) { UserInfo.HandleMenuOnOffButton(arg.Player(), arg.Args[0]); } }
private void commandSetBarricadeHealth(ConsoleSystem.Arg arg) { BasePlayer player = arg.Player(); if (player != null && !player.IsAdmin) { return; } float value; if (arg.HasArgs() && float.TryParse(arg.Args[0], out value)) { if (value < barricadeHealthPercentageMinimum) { value = barricadeHealthPercentageMinimum; } else if (value > barricadeHealthPercentageMaximum) { value = barricadeHealthPercentageMaximum; } barricadeHealthPercentage = value; Config["health"] = barricadeHealthPercentage; SaveConfig(); } arg.ReplyWith("hwb.health: " + Math.Round(barricadeHealthPercentage * 100.0f).ToString() + "%"); }
public static void teleport(ConsoleSystem.Arg args) { if (args.HasArgs(2)) { BasePlayer player = args.GetPlayer(0); if (!Object.op_Implicit((Object)player) || !player.IsAlive()) { return; } BasePlayer playerOrSleeper = args.GetPlayerOrSleeper(1); if (!Object.op_Implicit((Object)playerOrSleeper) || !playerOrSleeper.IsAlive()) { return; } player.Teleport(playerOrSleeper); } else { BasePlayer basePlayer = args.Player(); if (!Object.op_Implicit((Object)basePlayer) || !basePlayer.IsAlive()) { return; } BasePlayer playerOrSleeper = args.GetPlayerOrSleeper(0); if (!Object.op_Implicit((Object)playerOrSleeper) || !playerOrSleeper.IsAlive()) { return; } basePlayer.Teleport(playerOrSleeper); } }
private void cmdUnload(ConsoleSystem.Arg arg) { // Check arg 1 exists if (!arg.HasArgs(1)) { arg.ReplyWith("Syntax: oxide.unload <pluginname>"); return; } // Get the plugin name string name = arg.GetString(0); if (string.IsNullOrEmpty(name)) { return; } // Unload if (!Interface.GetMod().UnloadPlugin(name)) { arg.ReplyWith(string.Format("Plugin '{0}' not found!", name)); } else { arg.ReplyWith(string.Format("Plugin '{0}' unloaded.", name)); } }
object OnServerCommand(ConsoleSystem.Arg arg) { if (arg?.cmd?.FullName != null && arg?.cmd?.FullName == "global.say") { if (arg.Connection != null && arg.Connection.player != null) { BasePlayer player = arg.Connection.player as BasePlayer; if (!permission.UserHasPermission(player.UserIDString, "bettersay.use")) { return(true); } } string[] args = new string[0]; string output = Config["Settings", "Formatting"] as string; if (arg.HasArgs()) { args = arg.Args; } string message = ListToString(args.ToList(), 0, " "); output = output.Replace("{Title}", $"<color={Config["Settings", "Title Color"].ToString()}>{Config["Settings", "Title"].ToString()}</color>").Replace("{Message}", $"<color={Config["Settings", "Message Color"].ToString()}>{message}</color>"); BroadcastChat(output); Puts(RemoveFormatting(output)); return(true); } else { return(null); } }
private void BlockCommandConsole(ConsoleSystem.Arg arg) { if (arg.Player() != null && !arg.Player().IsAdmin()) { arg.ReplyWith(NoPermission); return; } if (!arg.HasArgs(1)) { arg.ReplyWith(NoItemSpecified); return; } var item = string.Join(" ", arg.Args); if (!Items.Contains(item)) { arg.ReplyWith(string.Format(InvalidItem, item)); return; } if (BlockedItems.Contains(item)) { arg.ReplyWith(string.Format(BlockedItem, item)); return; } BlockedItems.Add(item); SetConfigValue("Options", "BlockedItems", BlockedItems); arg.ReplyWith(string.Format(BlockSucces, item)); }
private void CommandConsoleAuth(ConsoleSystem.Arg arg) { if (arg.Connection == null || arg.Player() == null || !arg.HasArgs()) { return; } switch (arg.Args[0].ToLower()) { case "a.cupboard": AuthorizationCupboard(arg.Player()); return; case "a.autoturret": AuthorizationAutoTurret(arg.Player()); return; case "a.codelock": AuthorizationCodeLocks(arg.Player()); return; case "d.cupboard": DeauthorizationCupboard(arg.Player()); return; case "d.autoturret": DeauthorizationAutoTurret(arg.Player()); return; case "d.codelock": DeauthorizationCodeLocks(arg.Player()); return; } }