public void Execute(IRocketPlayer caller, string[] command) { if (command.Length == 0 || command.Length > 1) { UnturnedChat.Say(caller, Syntax + " - " + Help); return; } UnturnedPlayer player = (UnturnedPlayer)caller; PVirtStorage pComponent = player.GetComponent <PVirtStorage>(); Dictionary <string, object[]> containers = VirtualStorage.Database.GetContainerList(player.CSteamID); string defaultContainer = VirtualStorage.Database.GetDefaultContainer(player.CSteamID); object[] container = containers.Values.FirstOrDefault(contents => contents[2].ToString().ToLower() == command[0].ToLower().Trim()); if (container == null) { UnturnedChat.Say(caller, VirtualStorage.Instance.Translate("container_name_not_found"), Color.red); return; } ContainerManager cData = null; // Load the container data, if it isn't already loaded. if (VirtualStorage.Containers.ContainsKey(player.CSteamID) && VirtualStorage.Containers[player.CSteamID].ContainerName.ToLower() == container[2].ToString().Trim().ToLower()) { cData = VirtualStorage.Containers[player.CSteamID]; VirtualStorage.Containers.Remove(player.CSteamID); } if (cData == null) { object[] cObject = VirtualStorage.Database.GetContainerData(player.CSteamID, container[2].ToString()); cData = new ContainerManager(player); if (!cData.SetContainer((ushort)cObject[0], (byte[])cObject[1], player, (string)cObject[2], (byte)cObject[3], (byte)cObject[4])) { if (!cData.SetContainer(VirtualStorage.Instance.Configuration.Instance.FallbackAssetID, (byte[])cObject[1], player, (string)cObject[2], (byte)cObject[3], (byte)cObject[4])) { UnturnedChat.Say(caller, VirtualStorage.Instance.Translate("open_invalid"), Color.red); return; } } } if (!string.IsNullOrEmpty(defaultContainer)) { if (defaultContainer.ToLower() == command[0].Trim().ToLower()) { VirtualStorage.Database.SaveDefaultContainer(player.CSteamID, string.Empty); } } VirtualStorage.Database.RemoveContainerFromDB(player.CSteamID, container[2].ToString()); cData.Break(); }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; PVirtStorage pComponent = player.GetComponent <PVirtStorage>(); string DefaultContainer = VirtualStorage.Database.GetDefaultContainer(player.CSteamID); ContainerManager cData = null; if (string.IsNullOrEmpty(DefaultContainer)) { UnturnedChat.Say(caller, VirtualStorage.Instance.Translate("no_default_set"), Color.red); return; } object[] cInfo = VirtualStorage.Database.GetContainerData(player.CSteamID, DefaultContainer); if (cInfo == null) { UnturnedChat.Say(caller, VirtualStorage.Instance.Translate("open_data_not_found"), Color.red); return; } if (VirtualStorage.Containers.ContainsKey(player.CSteamID) && VirtualStorage.Containers[player.CSteamID].ContainerName == DefaultContainer) { cData = VirtualStorage.Containers[player.CSteamID]; } else { if (VirtualStorage.Containers.ContainsKey(player.CSteamID)) { VirtualStorage.Containers[player.CSteamID].Cleanup(); } cData = new ContainerManager(player); if (!cData.SetContainer((ushort)cInfo[0], (byte[])cInfo[1], player, (string)cInfo[2], (byte)cInfo[3], (byte)cInfo[4])) { UnturnedChat.Say(caller, VirtualStorage.Instance.Translate("open_invalid"), Color.red); return; } } if (VirtualStorage.TryCharge(caller, VirtualStorage.Instance.Configuration.Instance.OpenChargeCost, "vs.overrideopencost")) { if (!VirtualStorage.Containers.ContainsKey(player.CSteamID)) { VirtualStorage.Containers.Add(player.CSteamID, cData); } if (!caller.HasPermission("vs.overrideopencost")) { UnturnedChat.Say(caller, VirtualStorage.Instance.Translate("open_charged", Math.Round(VirtualStorage.Instance.Configuration.Instance.OpenChargeCost, 2), fr34kyn01535.Uconomy.Uconomy.Instance.Configuration.Instance.MoneyName), Color.cyan); } pComponent.cData = cData; cData.Open(); } else { UnturnedChat.Say(caller, VirtualStorage.Instance.Translate("not_enough_credits", fr34kyn01535.Uconomy.Uconomy.Instance.Configuration.Instance.MoneyName), Color.red); } }