public static IEnumerable <Chat.ChatEntry> tail(ConsoleSystem.Arg arg) { int num = arg.GetInt(0, 200); int count = Chat.History.Count - num; if (count < 0) { count = 0; } return(Chat.History.Skip <Chat.ChatEntry>(count)); }
public static IEnumerable <Output.Entry> tail(ConsoleSystem.Arg arg) { int num = arg.GetInt(0, 200); int count = Output.HistoryOutput.Count - num; if (count < 0) { count = 0; } return(Output.HistoryOutput.Skip <Output.Entry>(count)); }
void cmdStatPlayer(ConsoleSystem.Arg arg) { if (arg.Connection != null && !arg.IsAdmin) { return; } var userId = arg.GetULong(0); if (!userId.IsSteamId()) { SendReply(arg, "Invalid UserId"); } var mod = arg.GetInt(1); List <KillData> killdata; if (!kills.TryGetValue(userId, out killdata)) { SendReply(arg, "User doesn't have kills"); return; } switch (mod) { case 0: killdata = killdata.OrderByDescending(p => p.Time).ToList(); break; case 1: killdata = killdata.OrderByDescending(p => p.Distance).ToList(); break; case 2: killdata = killdata.OrderBy(p => p.Weapon).ToList(); break; } var viewData = killdata.Where(p => float.Parse(p.Distance) >= 10).ToList(); var msg = new StringBuilder("\n"); msg.Append($"Максимальная дистанция: {viewData.Max(p => float.Parse(p.Distance))}\n"); var bones = new Dictionary <string, int>(); foreach (var k in viewData.Select(p => p.Bone).ToList()) { if (!bones.ContainsKey(k)) { bones.Add(k, viewData.Count(p => p.Bone == k)); } } msg.Append($"Любимая часть тела: {bones.OrderByDescending(p=>p.Value).ToList()[0].Key}\n"); msg.Append(ConsoleTable.From(viewData).ToMarkDownString()); Puts(msg.ToString()); }
private void cmdGroup(ConsoleSystem.Arg arg) { if (!PermissionsLoaded(arg)) { return; } if (arg.argUser != null && !arg.argUser.CanAdmin()) { return; } if (!arg.HasArgs(2)) { arg.ReplyWith("Usage: group <add|remove|set> <name> [title] [rank]"); return; } var mode = arg.GetString(0); var name = arg.GetString(1); var title = arg.GetString(2); var rank = arg.GetInt(3); if (mode.Equals("add")) { if (permission.GroupExists(name)) { arg.ReplyWith("Group '" + name + "' already exist"); return; } permission.CreateGroup(name, title, rank); arg.ReplyWith("Group '" + name + "' created"); } else if (mode.Equals("remove")) { if (!permission.GroupExists(name)) { arg.ReplyWith("Group '" + name + "' doesn't exist"); return; } permission.RemoveGroup(name); arg.ReplyWith("Group '" + name + "' deleted"); } else if (mode.Equals("set")) { if (!permission.GroupExists(name)) { arg.ReplyWith("Group '" + name + "' doesn't exist"); return; } permission.SetGroupTitle(name, title); permission.SetGroupRank(name, rank); arg.ReplyWith("Group '" + name + "' changed"); } }
public static void cancel(ConsoleSystem.Arg args) { BasePlayer basePlayer = args.Player(); if (!Object.op_Implicit((Object)basePlayer) || basePlayer.IsDead()) { return; } int itemid = args.GetInt(0, 0); basePlayer.inventory.crafting.CancelBlueprint(itemid); }
void ChangeSmeltSpeed_ConsoleCommand(ConsoleSystem.Arg args) { if (!args.IsAdmin) { return; } if (args.HasArgs(1)) { Settings.SmeltSpeed = args.GetInt(0, 1); } args.ReplyWith($"Smelt Speed: {Settings.SmeltSpeed}x (Default: 1)"); _settingsFile.Save(); }
void ChangeWoodRate_ConsoleCommand(ConsoleSystem.Arg args) { if (!args.IsAdmin) { return; } if (args.HasArgs(1)) { Settings.WoodRate = args.GetInt(0, 1); } args.ReplyWith($"Wood Rate: {Settings.WoodRate} (Default: 1)"); _settingsFile.Save(); }
/// <summary> /// Fakes a distance kill /// </summary> /// <param name="arg"></param> void fakeDistanceKill(ConsoleSystem.Arg arg) { var data = new Dictionary <string, string> { { "VictimID", "76561197997942034" }, { "KillerID", "76561198302518503" }, { "KillerHP", "100" }, { "Weapon", "Semi-Automatic Pistol" }, { "Distance", Convert.ToString(arg.GetInt(0, 1)) }, { "Bone", "head" } }; this.sendData(this.getEndpoint("playerKilled"), data, "Sending FAKE Kill to Website"); }
private void ConsoleGroup(ConsoleSystem.Arg arg) { if (!PermissionsLoaded(arg)) return; if (!IsAdmin(arg)) return; if (!arg.HasArgs(2)) { var reply = "Syntax: group <add|set> <name> [title] [rank]"; reply += "Syntax: group <remove> <name>\n"; reply += "Syntax: group <parent> <name> <parentName>"; arg.ReplyWith(reply); return; } var mode = arg.GetString(0); var name = arg.GetString(1); var title = arg.GetString(2); var rank = arg.GetInt(3); if (mode.Equals("add")) { if (permission.GroupExists(name)) { arg.ReplyWith("Group '" + name + "' already exist"); return; } permission.CreateGroup(name, title, rank); arg.ReplyWith("Group '" + name + "' created"); } else if (mode.Equals("remove")) { if (!permission.GroupExists(name)) { arg.ReplyWith("Group '" + name + "' doesn't exist"); return; } permission.RemoveGroup(name); arg.ReplyWith("Group '" + name + "' deleted"); } else if (mode.Equals("set")) { if (!permission.GroupExists(name)) { arg.ReplyWith("Group '" + name + "' doesn't exist"); return; } permission.SetGroupTitle(name, title); permission.SetGroupRank(name, rank); arg.ReplyWith("Group '" + name + "' changed"); } }
public static void giveid(ConsoleSystem.Arg arg) { string str = "SERVER"; if (Object.op_Inequality((Object)arg.Player(), (Object)null)) { str = arg.Player().displayName; } BasePlayer basePlayer = arg.Player(); if (!Object.op_Implicit((Object)basePlayer)) { return; } Item byItemId = ItemManager.CreateByItemID(arg.GetInt(0, 0), 1, 0UL); if (byItemId == null) { arg.ReplyWith("Invalid Item!"); } else { byItemId.amount = arg.GetInt(1, 1); byItemId.OnVirginSpawn(); if (!basePlayer.inventory.GiveItem(byItemId, (ItemContainer)null)) { byItemId.Remove(0.0f); arg.ReplyWith("Couldn't give item (inventory full?)"); } else { basePlayer.Command("note.inv", (object)byItemId.info.itemid, (object)byItemId.amount); Debug.Log((object)(" [ServerVar] giving " + basePlayer.displayName + " " + (object)byItemId.amount + " x " + byItemId.info.displayName.english)); Chat.Broadcast(str + " gave " + basePlayer.displayName + " " + (object)byItemId.amount + " x " + byItemId.info.displayName.english, "SERVER", "#eee", 0UL); } } }
public static void cancel(ConsoleSystem.Arg args) { BasePlayer basePlayer = args.Player(); if (!basePlayer) { return; } if (basePlayer.IsDead()) { return; } int num = args.GetInt(0, 0); basePlayer.inventory.crafting.CancelBlueprint(num); }
void ccmdAssetShow(ConsoleSystem.Arg arg) { if (!arg.HasArgs()) { return; } var player = arg.Player(); if (player == null) { return; } var shoppage = arg.GetInt(0); ShowAsset(player, shoppage); }
public static void canceltask(ConsoleSystem.Arg args) { BasePlayer basePlayer = args.Player(); if (!Object.op_Implicit((Object)basePlayer) || basePlayer.IsDead()) { return; } int iID = args.GetInt(0, 0); if (basePlayer.inventory.crafting.CancelTask(iID, true)) { return; } args.ReplyWith("Couldn't cancel task!"); }
void cmdAspect(ConsoleSystem.Arg arg) { var player = arg.Player(); if (player == null) { return; } var aspect = arg.GetInt(0, -1); if (aspect == -1) { return; } aspects[player.userID] = aspect; IDestroyUI(player, new UIData(Name, "aspect", 0)); onPlayerAspectChanged(player); }
private void ChangePage(ConsoleSystem.Arg arg) { if (arg.Connection == null || arg.Connection.player == null || !arg.HasArgs(2) || _settings == null) { return; } var player = arg.Connection.player as BasePlayer; if (player == null) { return; } if (!PlayerActiveTabs.ContainsKey(player.userID)) { return; } var playerInfoState = PlayerActiveTabs[player.userID]; var currentTab = _settings.Tabs[playerInfoState.ActiveTabIndex]; var currentPageIndex = playerInfoState.PageIndex; var pageToChangeTo = arg.GetInt(0, 65535); var currentTabContentPanelName = playerInfoState.ActiveTabContentPanelName; var mainPanelName = arg.GetString(1); if (pageToChangeTo == currentPageIndex) { return; } CuiHelper.DestroyUi(player, currentTabContentPanelName); playerInfoState.PageIndex = pageToChangeTo; var container = new CuiElementContainer(); var tabContentPanelName = CreateTabContent(currentTab, container, mainPanelName, pageToChangeTo); PlayerActiveTabs[player.userID].ActiveTabContentPanelName = tabContentPanelName; SendUI(player, container); }
public static void canceltask(ConsoleSystem.Arg args) { BasePlayer basePlayer = args.Player(); if (!basePlayer) { return; } if (basePlayer.IsDead()) { return; } int num = args.GetInt(0, 0); if (basePlayer.inventory.crafting.CancelTask(num, true)) { return; } args.ReplyWith("Couldn't cancel task!"); }
public static void debug_toggle(ConsoleSystem.Arg args) { int num = args.GetInt(0, 0); if (num == 0) { return; } BaseEntity baseEntity = BaseNetworkable.serverEntities.Find((uint)num) as BaseEntity; if (Object.op_Equality((Object)baseEntity, (Object)null)) { return; } baseEntity.SetFlag(BaseEntity.Flags.Debugging, !baseEntity.IsDebugging(), false, true); if (baseEntity.IsDebugging()) { baseEntity.OnDebugStart(); } args.ReplyWith("Debugging for " + (object)(uint)baseEntity.net.ID + " " + (baseEntity.IsDebugging() ? (object)"enabled" : (object)"disabled")); }
private void ConsoleCommand_TotalStacks(ConsoleSystem.Arg arg) { var player = arg.Player(); var lootSource = player.inventory.loot?.entitySource as BaseOven; if (!HasPermission(player)) { player.ConsoleMessage(lang.GetMessage("nopermission", this, player.UserIDString)); return; } if (lootSource == null || !compatibleOvens.Contains(lootSource.ShortPrefabName)) { player.ConsoleMessage(lang.GetMessage("lootsource_invalid", this, player.UserIDString)); 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 { Debug.LogWarning("[FurnaceSplitter] Unsupported furnace '" + ovenName + "'"); player.ConsoleMessage(lang.GetMessage("unsupported_furnace", this, player.UserIDString)); } CreateUiIfFurnaceOpen(player); }
public static void giveto(ConsoleSystem.Arg arg) { string str = "SERVER"; if (Object.op_Inequality((Object)arg.Player(), (Object)null)) { str = arg.Player().displayName; } BasePlayer basePlayer = BasePlayer.Find(arg.GetString(0, "")); if (Object.op_Equality((Object)basePlayer, (Object)null)) { arg.ReplyWith("Couldn't find player!"); } else { Item byPartialName = ItemManager.CreateByPartialName(arg.GetString(1, ""), 1); if (byPartialName == null) { arg.ReplyWith("Invalid Item!"); } else { byPartialName.amount = arg.GetInt(2, 1); byPartialName.OnVirginSpawn(); if (!basePlayer.inventory.GiveItem(byPartialName, (ItemContainer)null)) { byPartialName.Remove(0.0f); arg.ReplyWith("Couldn't give item (inventory full?)"); } else { basePlayer.Command("note.inv", (object)byPartialName.info.itemid, (object)byPartialName.amount); Debug.Log((object)(" [ServerVar] giving " + basePlayer.displayName + " " + (object)byPartialName.amount + " x " + byPartialName.info.displayName.english)); Chat.Broadcast(str + " gave " + basePlayer.displayName + " " + (object)byPartialName.amount + " x " + byPartialName.info.displayName.english, "SERVER", "#eee", 0UL); } } } }
public static void giveall(ConsoleSystem.Arg arg) { Item num = null; string str = "SERVER"; if (arg.Player() != null) { str = arg.Player().displayName; } foreach (BasePlayer basePlayer in BasePlayer.activePlayerList) { num = ItemManager.CreateByPartialName(arg.GetString(0, ""), 1); if (num != null) { num.amount = arg.GetInt(1, 1); num.OnVirginSpawn(); if (basePlayer.inventory.GiveItem(num, null)) { basePlayer.Command("note.inv", new object[] { num.info.itemid, num.amount }); Debug.Log(string.Concat(new object[] { " [ServerVar] giving ", basePlayer.displayName, " ", num.amount, " x ", num.info.displayName.english })); } else { num.Remove(0f); arg.ReplyWith("Couldn't give item (inventory full?)"); } } else { arg.ReplyWith("Invalid Item!"); return; } } if (num != null) { Chat.Broadcast(string.Concat(new object[] { str, " gave everyone ", num.amount, " x ", num.info.displayName.english }), "SERVER", "#eee", (ulong)0); } }
public static void debug_toggle(ConsoleSystem.Arg args) { int num = args.GetInt(0, 0); if (num == 0) { return; } BaseEntity baseEntity = BaseNetworkable.serverEntities.Find((uint)num) as BaseEntity; if (baseEntity == null) { return; } baseEntity.SetFlag(BaseEntity.Flags.Debugging, !baseEntity.IsDebugging(), false, true); if (baseEntity.IsDebugging()) { baseEntity.OnDebugStart(); } ConsoleSystem.Arg arg = args; object[] d = new object[] { "Debugging for ", baseEntity.net.ID, " ", null }; d[3] = (baseEntity.IsDebugging() ? "enabled" : "disabled"); arg.ReplyWith(string.Concat(d)); }
public static void giveall(ConsoleSystem.Arg arg) { Item obj = (Item)null; string str = "SERVER"; if (Object.op_Inequality((Object)arg.Player(), (Object)null)) { str = arg.Player().displayName; } foreach (BasePlayer activePlayer in BasePlayer.activePlayerList) { obj = ItemManager.CreateByPartialName(arg.GetString(0, ""), 1); if (obj == null) { arg.ReplyWith("Invalid Item!"); return; } obj.amount = arg.GetInt(1, 1); obj.OnVirginSpawn(); if (!activePlayer.inventory.GiveItem(obj, (ItemContainer)null)) { obj.Remove(0.0f); arg.ReplyWith("Couldn't give item (inventory full?)"); } else { activePlayer.Command("note.inv", (object)obj.info.itemid, (object)obj.amount); Debug.Log((object)(" [ServerVar] giving " + activePlayer.displayName + " " + (object)obj.amount + " x " + obj.info.displayName.english)); } } if (obj == null) { return; } Chat.Broadcast(str + " gave everyone " + (object)obj.amount + " x " + obj.info.displayName.english, "SERVER", "#eee", 0UL); }
void cmdConsoleKitShow(ConsoleSystem.Arg arg) { if (arg.Player() == null) { SendReply(arg, "You can't use this command from the server console"); return; } if (!arg.HasArgs()) { SendReply(arg, "You are not allowed to use manually this command"); return; } var player = arg.Player(); PLayerGUI playerGUI; if (!PlayerGUI.TryGetValue(player.userID, out playerGUI)) { return; } RefreshKitPanel(player, playerGUI.guiid, arg.GetInt(0)); }
/// <summary> /// Overrides the command handling system if a command has been entered that would issue an admin abuse announcement. /// </summary> /// <param name="arg"> The console argument containing information about the command.</param> /// <returns> An object that determines whether the command handling system should be overriden or not.</returns> object OnRunCommand(ConsoleSystem.Arg arg) { if (arg == null || arg.cmd == null) { return(null); } string command = arg.cmd.name; // give if (command.Equals("give")) { if (!HasPermission(arg, "give")) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("missing permission", this)); } return(true); } BasePlayer player = arg.Player(); if (!player) { return(true); } Item item = ItemManager.CreateByPartialName(arg.GetString(0), 1); if (item == null) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("invalid item", this)); } return(true); } if (itemBlackList.Contains(item.info.shortname)) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("black listed item", this)); } return(true); } item.amount = arg.GetInt(1, 1); if (!player.inventory.GiveItem(item, null)) { item.Remove(0f); if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("couldn't give item", this)); } return(true); } player.Command("note.inv", new object[] { item.info.itemid, item.amount }); Debug.Log(string.Concat(new object[] { "[admin] giving ", player.displayName, " ", item.amount, " x ", item.info.displayName.english })); return(true); } // giveall else if (command.Equals("giveall")) { if (!HasPermission(arg, "giveall")) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("missing permission", this)); } return(true); } foreach (BasePlayer player in BasePlayer.activePlayerList) { Item item = ItemManager.CreateByPartialName(arg.GetString(0), 1); if (item != null) { if (!itemBlackList.Contains(item.info.shortname)) { item.amount = arg.GetInt(1, 1); if (player.inventory.GiveItem(item, null)) { player.Command("note.inv", new object[] { item.info.itemid, item.amount }); Debug.Log(string.Concat(new object[] { "[admin] giving ", player.displayName, " ", item.amount, " x ", item.info.displayName.english })); return(true); } else { item.Remove(0f); if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("couldn't give item", this)); } return(true); } } else { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("black listed item", this)); } return(true); } } else { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("invalid item", this)); } return(true); } } } // givearm else if (command.Equals("givearm")) { if (!HasPermission(arg, "givearm")) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("missing permission", this)); } return(true); } BasePlayer player = arg.Player(); if (!player) { return(true); } Item item = ItemManager.CreateByItemID(arg.GetInt(0, 0), 1, false, 0); if (item == null) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("invalid item", this)); } return(true); } if (itemBlackList.Contains(item.info.shortname)) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("black listed item", this)); } return(true); } item.amount = arg.GetInt(1, 1); if (!player.inventory.GiveItem(item, player.inventory.containerBelt)) { item.Remove(0f); if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("couldn't give item", this)); } return(true); } player.Command("note.inv", new object[] { item.info.itemid, item.amount }); Debug.Log(string.Concat(new object[] { "[admin] giving ", player.displayName, " ", item.amount, " x ", item.info.displayName.english })); return(true); } // givebp else if (command.Equals("givebp")) { if (!HasPermission(arg, "givebp")) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("missing permission", this)); } return(true); } BasePlayer player = arg.Player(); if (!player) { return(true); } ItemDefinition definition = ItemManager.FindItemDefinition(arg.GetInt(0, 0)); if (definition == null) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("invalid item", this)); } return(true); } if (itemBlackList.Contains(definition.shortname)) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("black listed item", this)); } return(true); } player.blueprints.Learn(definition); Debug.Log(string.Concat(new object[] { "[admin] ", player.displayName, " learning blueprint ", definition.displayName.english })); return(true); } // givebpall else if (command.Equals("givebpall")) { if (!HasPermission(arg, "givebpall")) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("missing permission", this)); } return(true); } ItemDefinition definition = ItemManager.FindItemDefinition(arg.GetString(0)); if (definition == null) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("invalid item", this)); } return(true); } if (itemBlackList.Contains(definition.shortname)) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("black listed item", this)); } return(true); } foreach (BasePlayer player in BasePlayer.activePlayerList) { player.blueprints.Learn(definition); Debug.Log(string.Concat(new string[] { "[admin] teaching ", player.displayName, " ", definition.displayName.english, " blueprint" })); } return(true); } // giveid else if (command.Equals("giveid")) { if (!HasPermission(arg, "giveid")) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("missing permission", this)); } return(true); } BasePlayer player = arg.Player(); if (!player) { return(true); } Item item = ItemManager.CreateByItemID(arg.GetInt(0), 1, false, 0); if (item == null) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("invalid item", this)); } return(true); } if (itemBlackList.Contains(item.info.shortname)) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("black listed item", this)); } return(true); } item.amount = arg.GetInt(1, 1); if (!player.inventory.GiveItem(item, null)) { item.Remove(0f); if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("couldn't give item", this)); } return(true); } player.Command("note.inv", new object[] { item.info.itemid, item.amount }); Debug.Log(string.Concat(new object[] { "[admin] giving ", player.displayName, " ", item.amount, " x ", item.info.displayName.english })); return(true); } // giveto else if (command.Equals("giveto")) { if (!HasPermission(arg, "giveto")) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("missing permission", this)); } return(true); } BasePlayer player = BasePlayer.Find(arg.GetString(0)); if (player == null) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("couldn't find player", this)); } return(true); } Item item = ItemManager.CreateByPartialName(arg.GetString(1), 1); if (item == null) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("invalid item", this)); } return(true); } if (itemBlackList.Contains(item.info.shortname)) { if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("black listed item", this)); } return(true); } item.amount = arg.GetInt(2, 1); if (!player.inventory.GiveItem(item, null)) { item.Remove(0f); if (arg.Player()) { arg.Player().ChatMessage(lang.GetMessage("couldn't give item", this)); } return(true); } player.Command("note.inv", new object[] { item.info.itemid, item.amount }); Debug.Log(string.Concat(new object[] { "[admin] giving ", player.displayName, " ", item.amount, " x ", item.info.displayName.english })); return(true); } return(null); }
private void OnConsoleCommand(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 (pdata == null) { return; } switch (arg.GetString(0)) { case "index": GetFriends(player, players => UpdateUI(player, players, arg.GetInt(1)), true); break; case "close": DestroyUI(player); break; case "add": DestroyUI(player); Database.Query(Database.Build("SELECT * FROM users WHERE steam_id=@0 LIMIT 1;", arg.GetUInt64(1)), records => { if (records.Count == 0) { return; } int foundUser = Convert.ToInt32(records[0]["id"]); ulong foundUserId = Convert.ToUInt64(records[0]["steam_id"]); if (foundUser == pdata.id) { player.ChatMessage("You cannot add yourself to your friendlist."); return; } AddFriend(player, foundUserId, foundUser, result => { if (result > 0) { player.ChatMessage($"{records[0]["display_name"]} added to your friendlist."); } else if (result == 0) { player.ChatMessage($"{records[0]["display_name"]} is already in your friends list."); } else { player.ChatMessage($"Something went wrong (error code: {result})"); } }); }); break; case "remove": DestroyUI(player); Database.Query(Database.Build("SELECT * FROM users WHERE steam_id=@0 LIMIT 1;", arg.GetUInt64(1)), records => { if (records.Count == 0) { return; } int foundUser = Convert.ToInt32(records[0]["id"]); ulong foundUserId = Convert.ToUInt64(records[0]["steam_id"]); if (foundUser == pdata.id) { player.ChatMessage("You cannot remove yourself from your friendlist."); return; } RemoveFriend(player, foundUserId, foundUser, result => { if (result > 0) { player.ChatMessage($"{records[0]["display_name"]} removed from your friendlist."); } else if (result == 0) { player.ChatMessage($"{records[0]["display_name"]} is not in your friendlist."); } else { player.ChatMessage($"Something went wrong (error code: {result})"); } }); }); break; } }
private void CmdGroup(ConsoleSystem.Arg arg) { if (!PermissionsLoaded(arg)) { return; } if (!IsAdmin(arg)) { return; } if (!arg.HasArgs(2)) { var reply = "Usage: group <add|set> <name> [title] [rank]\n"; reply += "Usage: group <remove> <name>\n"; reply += "Usage: group <parent> <name> <parentName>"; arg.ReplyWith(reply); return; } var mode = arg.GetString(0); var name = arg.GetString(1); if (mode.Equals("add")) { if (permission.GroupExists(name)) { arg.ReplyWith("Group '" + name + "' already exist"); return; } permission.CreateGroup(name, arg.GetString(2), arg.GetInt(3)); arg.ReplyWith("Group '" + name + "' created"); } else if (mode.Equals("remove")) { if (!permission.GroupExists(name)) { arg.ReplyWith("Group '" + name + "' doesn't exist"); return; } permission.RemoveGroup(name); arg.ReplyWith("Group '" + name + "' deleted"); } else if (mode.Equals("set")) { if (!permission.GroupExists(name)) { arg.ReplyWith("Group '" + name + "' doesn't exist"); return; } permission.SetGroupTitle(name, arg.GetString(2)); permission.SetGroupRank(name, arg.GetInt(3)); arg.ReplyWith("Group '" + name + "' changed"); } else if (mode.Equals("parent")) { if (!permission.GroupExists(name)) { arg.ReplyWith("Group '" + name + "' doesn't exist"); return; } var parent = arg.GetString(2); if (!string.IsNullOrEmpty(parent) && !permission.GroupExists(parent)) { arg.ReplyWith("Parent group '" + parent + "' doesn't exist"); return; } if (permission.SetGroupParent(name, parent)) { arg.ReplyWith("Group '" + name + "' changed"); } else { arg.ReplyWith("Group '" + name + "' failed to change"); } } }
void ChatReceived(ref ConsoleSystem.Arg arg) { Fougerite.Player pl = Fougerite.Server.Cache[arg.argUser.userID]; var command = ChatCommand.GetCommand("tpto") as TeleportToCommand; if (command.GetTPWaitList().Contains(pl.UID)) { command.PartialNameTP(ref arg, arg.GetInt(0)); arg.ArgsStr = string.Empty; } else if (Core.friendWaitList.Contains(arg.argUser.userID)) { (ChatCommand.GetCommand("addfriend") as AddFriendCommand).PartialNameAddFriend(ref arg, arg.GetInt(0)); Core.friendWaitList.Remove(arg.argUser.userID); arg.ArgsStr = string.Empty; } else if (Core.shareWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("share") as ShareCommand).PartialNameDoorShare(ref arg, arg.GetInt(0)); Core.shareWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.banWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("ban") as BanCommand).PartialNameBan(ref arg, arg.GetInt(0)); Core.banWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.kickWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("kick") as KickCommand).PartialNameKick(ref arg, arg.GetInt(0)); Core.kickWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.killWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("kill") as KillCommand).PartialNameKill(ref arg, arg.GetInt(0)); Core.killWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.unfriendWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("unfriend") as UnfriendCommand).PartialNameUnfriend(ref arg, arg.GetInt(0)); Core.unfriendWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.unshareWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("unshare") as UnshareCommand).PartialNameUnshareDoors(ref arg, arg.GetInt(0)); Core.unshareWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.whiteWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("addwl") as WhiteListAddCommand).PartialNameWhitelist(ref arg, arg.GetInt(0)); Core.whiteWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.adminAddWaitList.Contains(arg.argUser.userID)) { (ChatCommand.GetCommand("addadmin") as AddAdminCommand).PartialNameNewAdmin(ref arg, arg.GetInt(0)); Core.adminAddWaitList.Remove(arg.argUser.userID); arg.ArgsStr = string.Empty; } else if (Core.adminRemoveWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("unadmin") as RemoveAdminCommand).PartialNameRemoveAdmin(ref arg, arg.GetInt(0)); Core.adminRemoveWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.adminFlagsWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("getflags") as GetFlagsCommand).PartialNameGetFlags(ref arg, arg.GetInt(0)); Core.adminFlagsWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.muteWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("mute") as MuteCommand).PartialNameMute(ref arg, arg.GetInt(0)); Core.muteWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.unmuteWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("unmute") as UnmuteCommand).PartialNameUnmute(ref arg, arg.GetInt(0)); Core.unmuteWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.adminFlagWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("addflag") as AddFlagCommand).PartialNameAddFlags(ref arg, arg.GetInt(0)); Core.adminFlagWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.adminUnflagWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("unflag") as RemoveFlagsCommand).PartialNameRemoveFlags(ref arg, arg.GetInt(0)); Core.adminUnflagWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.unbanWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("unban") as UnbanCommand).PartialNameUnban(ref arg, arg.GetInt(0)); Core.unbanWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } if (Core.IsEnabled()) { Core.handleCommand(ref arg); } }
void ChatReceived(ref ConsoleSystem.Arg arg) { Fougerite.Player pl = Fougerite.Server.Cache[arg.argUser.userID]; if (!Core.userLang.ContainsKey(pl.UID)) { if (arg.Args[0] != "ES" && arg.Args[0] != "PT") { pl.SendClientMessage("[color red]<Error>[/color] Idioma Incorrecto, escriba ES o PT."); arg.ArgsStr = string.Empty; } pl.SendClientMessage(Components.LanguageComponent.LanguageComponent.getMessage("warning_lang", arg.Args[0])); Core.userLang[pl.UID] = arg.Args[0]; arg.ArgsStr = string.Empty; AuthComponent.aTimer.Stop(); AuthComponent.aTimer.Dispose(); AuthComponent.ShowLoginMessages(pl); //RustPP.Components.LanguageComponent.LanguageComponent.waitingLanguage.Remove(pl.UID); } string lang = Components.LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(pl); var command = ChatCommand.GetCommand("ir") as TeleportToCommand; if (IsSpam(arg.ArgsStr)) { pl.SendClientMessage(Components.LanguageComponent.LanguageComponent.getMessage("spam_not_allowed", lang)); arg.ArgsStr = string.Empty; } if (command.GetTPWaitList().Contains(pl.UID)) { command.PartialNameTP(ref arg, arg.GetInt(0)); arg.ArgsStr = string.Empty; } else if (Core.shareWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("share") as ShareCommand).PartialNameDoorShare(ref arg, arg.GetInt(0)); Core.shareWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.killWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("kill") as KillCommand).PartialNameKill(ref arg, arg.GetInt(0)); Core.killWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.unfriendWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("unfriend") as UnfriendCommand).PartialNameUnfriend(ref arg, arg.GetInt(0)); Core.unfriendWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.unshareWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("unshare") as UnshareCommand).PartialNameUnshareDoors(ref arg, arg.GetInt(0)); Core.unshareWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.whiteWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("addwl") as WhiteListAddCommand).PartialNameWhitelist(ref arg, arg.GetInt(0)); Core.whiteWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.adminAddWaitList.Contains(arg.argUser.userID)) { (ChatCommand.GetCommand("addadmin") as AddAdminCommand).PartialNameNewAdmin(ref arg, arg.GetInt(0)); Core.adminAddWaitList.Remove(arg.argUser.userID); arg.ArgsStr = string.Empty; } else if (Core.adminRemoveWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("unadmin") as RemoveAdminCommand).PartialNameRemoveAdmin(ref arg, arg.GetInt(0)); Core.adminRemoveWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.adminFlagsWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("getflags") as GetFlagsCommand).PartialNameGetFlags(ref arg, arg.GetInt(0)); Core.adminFlagsWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.muteWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("mutear") as MuteCommand).PartialNameMute(ref arg, arg.GetInt(0)); Core.muteWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.adminFlagWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("addflag") as AddFlagCommand).PartialNameAddFlags(ref arg, arg.GetInt(0)); Core.adminFlagWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } else if (Core.adminUnflagWaitList.Contains(pl.UID)) { (ChatCommand.GetCommand("unflag") as RemoveFlagsCommand).PartialNameRemoveFlags(ref arg, arg.GetInt(0)); Core.adminUnflagWaitList.Remove(pl.UID); arg.ArgsStr = string.Empty; } if (Core.IsEnabled()) { Core.handleCommand(ref arg); } }
public static void restart(ConsoleSystem.Arg args) { ServerMgr.RestartServer(args.GetString(1, string.Empty), args.GetInt(0, 300)); }
public static void aiDebug_toggle(ConsoleSystem.Arg args) { int num = args.GetInt(0, 0); if (num == 0) { return; } BaseEntity baseEntity = BaseNetworkable.serverEntities.Find((uint)num) as BaseEntity; if (Object.op_Equality((Object)baseEntity, (Object)null)) { return; } NPCPlayerApex npcPlayerApex = baseEntity as NPCPlayerApex; if (Object.op_Inequality((Object)npcPlayerApex, (Object)null)) { TextTable textTable = new TextTable(); textTable.AddColumn("type"); textTable.AddColumn("state"); textTable.AddColumn("posSync"); textTable.AddColumn("health"); textTable.AddColumn("stuckTime"); textTable.AddColumn("hasPath"); textTable.AddColumn("hasEnemyTarget"); textTable.AddColumn("isMounted"); textTable.AddRow(new string[8] { npcPlayerApex.Family.ToString(), npcPlayerApex.IsDormant ? "dormant" : "awake", npcPlayerApex.syncPosition.ToString(), npcPlayerApex.health.ToString("N2"), npcPlayerApex.stuckDuration.ToString("N2"), npcPlayerApex.HasPath.ToString(), Object.op_Inequality((Object)npcPlayerApex.AttackTarget, (Object)null).ToString(), npcPlayerApex.isMounted ? "true" : "false" }); args.ReplyWith(((object)textTable).ToString()); } else { BaseAnimalNPC baseAnimalNpc = baseEntity as BaseAnimalNPC; if (Object.op_Inequality((Object)baseAnimalNpc, (Object)null)) { TextTable textTable1 = new TextTable(); textTable1.AddColumn("type"); textTable1.AddColumn("state"); textTable1.AddColumn("posSync"); textTable1.AddColumn("health"); textTable1.AddColumn("stuckTime"); textTable1.AddColumn("hasPath"); textTable1.AddColumn("hasEnemyTarget"); textTable1.AddColumn("hasFoodTarget"); TextTable textTable2 = textTable1; string[] strArray = new string[8] { baseAnimalNpc.Stats.Family.ToString(), baseAnimalNpc.IsDormant ? "dormant" : "awake", baseAnimalNpc.syncPosition.ToString(), baseAnimalNpc.health.ToString("N2"), baseAnimalNpc.stuckDuration.ToString("N2"), baseAnimalNpc.HasPath.ToString(), null, null }; bool flag = Object.op_Inequality((Object)baseAnimalNpc.AttackTarget, (Object)null); strArray[6] = flag.ToString(); flag = Object.op_Inequality((Object)baseAnimalNpc.FoodTarget, (Object)null); strArray[7] = flag.ToString(); textTable2.AddRow(strArray); args.ReplyWith(((object)textTable1).ToString()); } else { HTNPlayer htnPlayer = baseEntity as HTNPlayer; if (!Object.op_Inequality((Object)htnPlayer, (Object)null)) { return; } TextTable textTable = new TextTable(); textTable.AddColumn("type"); textTable.AddColumn("state"); textTable.AddColumn("posSync"); textTable.AddColumn("health"); textTable.AddColumn("hasEnemyTarget"); textTable.AddColumn("isMounted"); textTable.AddRow(new string[6] { htnPlayer.Family.ToString(), htnPlayer.IsDormant ? "dormant" : "awake", htnPlayer.syncPosition.ToString(), htnPlayer.health.ToString("N2"), Object.op_Inequality((Object)htnPlayer.MainTarget, (Object)null).ToString(), htnPlayer.isMounted ? "true" : "false" }); args.ReplyWith(((object)textTable).ToString()); } } }