public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer callr = (UnturnedPlayer)caller; string kitName = null; if (command.Length == 0) { if (!AutoSave.ContainsKey(callr.CSteamID)) { if (Plugin.CustomKitsPlugin.Instance.Configuration.Instance.DefaultKitName == "preset_name") { foreach (Plugin.CustomKitsConfig.Preset Preset in Plugin.CustomKitsPlugin.Instance.Configuration.Instance.Presets) { if (caller.HasPermission(Plugin.CustomKitsPlugin.PERMISSION + Preset.Name)) { kitName = Preset.Name; } } } else { kitName = Plugin.CustomKitsPlugin.Instance.Configuration.Instance.DefaultKitName; } } else { AutoSave.Remove(callr.CSteamID); UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autosave_off"), Color.green); return; } } int slotCount = SlotManager.Slots[callr.CSteamID.m_SteamID].Count; if (kitName == "*") { UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("unsupported_character", "*"), Color.red); return; } if (KitManager.KitCount(callr, KitManager.Kits) >= slotCount) { if (!caller.IsAdmin || !caller.HasPermission("ck.admin")) { UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("no_kits_left"), Color.red); return; } } if (!AutoSave.ContainsKey(callr.CSteamID)) { AutoSave.Add(callr.CSteamID, kitName); UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autosave_on", kitName), Color.green); } else { AutoSave[callr.CSteamID] = kitName; UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autosave_on", kitName), Color.green); } }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer callr = (UnturnedPlayer)caller; string kitName = Plugin.CustomKitsPlugin.Instance.Configuration.Instance.DefaultKitName; string presetName = "ADMIN_KIT"; List <InventoryManager.Item> itemList = InventoryManager.ListItems(callr); int inventoryCount = itemList.Count; if (!caller.IsAdmin || !caller.HasPermission("ck.admin")) { string[] blackList = new string[] { }; int itemLimit = int.MaxValue; foreach (Plugin.CustomKitsConfig.Preset Preset in Plugin.CustomKitsPlugin.Instance.Configuration.Instance.Presets) { if (caller.HasPermission(Plugin.CustomKitsPlugin.PERMISSION + Preset.Name)) { presetName = Preset.Name; if (Preset.Blacklist != "") { blackList = Preset.Blacklist.Split(','); break; } } else { UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("set_permissions"), Color.red); return; } } if (KitManager.KitCount(callr, KitManager.Kits) >= SlotManager.SlotCount(callr)) { UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("no_kits_left"), Color.red); return; } var v = KitManager.KitCount(callr, KitManager.Kits); var slot = SlotManager.Slots[callr.CSteamID.m_SteamID][v]; itemLimit = slot.itemLimit; if (blackList.Length > 0) { foreach (InventoryManager.Item item in itemList) { List <int> bList = new List <int>(); foreach (var itemID in blackList) { bList.Add(int.Parse(itemID)); } if (bList.Contains(item.id)) { UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("blacklisted", UnturnedItems.GetItemAssetById(item.id)), Color.red); } } } if (inventoryCount > itemLimit) { UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("item_limit", itemLimit), Color.red); return; } } if (Plugin.CustomKitsPlugin.Instance.Configuration.Instance.DefaultKitName == "preset_name") { kitName = presetName; } if (command.Length == 1) { kitName = command[0]; } if (kitName == "*") { UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("unsupported_character", "*"), Color.red); return; } if (inventoryCount < 1 || itemList == null) { UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("empty_inventory"), Color.red); return; } if (KitManager.HasKit(callr, kitName, KitManager.Kits)) { KitManager.DeleteKit(callr, kitName, KitManager.Kits); } KitManager.SaveKit(callr, callr, kitName, KitManager.Kits); UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("kit_saved", kitName), Color.green); }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = null; if (command.Length == 0) { if (caller is ConsolePlayer) { Logger.LogError("<player>"); return; } player = (UnturnedPlayer)caller; } else if (command.Length == 1) { if (caller.HasPermission(OTHER_PERM)) { player = UnturnedPlayer.FromName(command[0]); } else { UnturnedChat.Say(caller, "You do not have permissions to execute this command.", Color.red); return; } } if (player == null) { if (caller is ConsolePlayer) { Logger.Log(Plugin.CustomKitsPlugin.Instance.Translate("player_doesn't_exist", command[0]), ConsoleColor.Red); return; } UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("player_doesn't_exist", command[0]), Color.red); return; } if (KitManager.Kits.ContainsKey(player.CSteamID.m_SteamID)) { if (KitManager.KitCount(player, KitManager.Kits) > 1) { string kitList = string.Join(", ", KitManager.Kits[player.CSteamID.m_SteamID].Keys.ToArray()); if (caller is ConsolePlayer) { Logger.Log(Plugin.CustomKitsPlugin.Instance.Translate("kit_list", kitList), ConsoleColor.Green); return; } UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("kit_list", kitList), Color.green); } else if (KitManager.KitCount(player, KitManager.Kits) == 1) { foreach (var kit in KitManager.Kits[player.CSteamID.m_SteamID].Keys) { if (caller is ConsolePlayer) { Logger.Log(Plugin.CustomKitsPlugin.Instance.Translate("kit_list", kit), ConsoleColor.Green); return; } UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("kit_list", kit), Color.green); } } else { if (caller is ConsolePlayer) { Logger.Log(Plugin.CustomKitsPlugin.Instance.Translate("no_saved_kits"), ConsoleColor.Red); return; } UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("no_saved_kits"), Color.red); } } else { if (caller is ConsolePlayer) { Logger.Log(Plugin.CustomKitsPlugin.Instance.Translate("no_saved_kits"), ConsoleColor.Red); return; } UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("no_saved_kits"), Color.red); } }