public void HangarList() { if (!AlliancePlugin.config.HangarEnabled) { Context.Respond("Hangar not enabled."); return; } if (Context.Player != null) { //Do stuff with taking components from grid storage //GridCosts localGridCosts = GetComponentsAndCost(projectedGrid); //gridCosts.setComponents(localGridCosts.getComponents()); IMyFaction faction = FacUtils.GetPlayersFaction(Context.Player.IdentityId); if (faction == null) { Context.Respond("Must be in a faction to use alliance features."); return; } Alliance alliance = AlliancePlugin.GetAlliance(faction as MyFaction); if (alliance == null) { Context.Respond("You are not a member of an alliance with an unlocked hangar."); return; } if (AlliancePlugin.HasFailedUpkeep(alliance)) { Context.Respond("Alliance failed to pay upkeep. Upgrades disabled."); return; } if (alliance.hasUnlockedHangar) { HangarData hangar = alliance.LoadHangar(); if (hangar == null) { Context.Respond("Error loading the hangar."); return; } Context.Respond("Hangar Slots available : " + hangar.SlotsAmount, Color.LightBlue, "Alliance Hangar"); for (int i = 1; i <= hangar.SlotsAmount; i++) { if (hangar.ItemsInHangar.ContainsKey(i)) { hangar.ItemsInHangar.TryGetValue(i, out HangarItem slot); Context.Respond(slot.name.Split('_')[0] + " : " + AlliancePlugin.GetPlayerName(slot.steamid), Color.LightBlue, "[ " + i + " ]"); } else { Context.Respond("", Color.Green, "[ Available ]"); } } } } }
public static Boolean Taxes(Dictionary <Guid, Dictionary <long, float> > taxes) { try { using (var db = new LiteDatabase(connectionString)) { var collection = db.GetCollection <BankData>("BankData"); foreach (KeyValuePair <Guid, Dictionary <long, float> > key in taxes) { Alliance alliance = AlliancePlugin.GetAlliance(key.Key); long amount = 0; foreach (float f in key.Value.Values) { amount += (long)f; } var bank = collection.FindById(key.Key); if (bank == null) { bank = new BankData { Id = key.Key, balance = amount }; collection.Insert(bank); } else { bank.balance += amount; collection.Update(bank); } foreach (KeyValuePair <long, float> tax in key.Value) { if (EconUtils.getBalance(tax.Key) >= tax.Value) { alliance.DepositTax((long)tax.Value, MySession.Static.Players.TryGetSteamId(tax.Key)); EconUtils.takeMoney(tax.Key, (long)tax.Value); } } AlliancePlugin.SaveAllianceData(alliance); } } } catch (Exception ex) { AlliancePlugin.Log.Error("Error with taxes"); AlliancePlugin.Log.Error(ex); return(false); } return(true); }
public void DoAllianceChat(string message = "") { MyFaction fac = MySession.Static.Factions.GetPlayerFaction(Context.Player.IdentityId); if (fac == null) { Context.Respond("Only factions can be in alliances."); return; } PlayerData data; if (File.Exists(AlliancePlugin.path + "//PlayerData//" + Context.Player.SteamUserId + ".xml")) { data = utils.ReadFromXmlFile <PlayerData>(AlliancePlugin.path + "//PlayerData//" + Context.Player.SteamUserId + ".xml"); } else { data = new PlayerData(); } Alliance alliance = AlliancePlugin.GetAlliance(fac); if (AllianceChat.PeopleInAllianceChat.ContainsKey(Context.Player.SteamUserId)) { data.InAllianceChat = false; AllianceChat.IdentityIds.Remove(Context.Player.SteamUserId); AllianceChat.PeopleInAllianceChat.Remove(Context.Player.SteamUserId); Context.Respond("Leaving alliance chat.", Color.Red); utils.WriteToXmlFile <PlayerData>(AlliancePlugin.path + "//PlayerData//" + Context.Player.SteamUserId + ".xml", data); return; } if (alliance != null) { { AllianceChat.IdentityIds.Remove(Context.Player.SteamUserId); AllianceChat.IdentityIds.Add(Context.Player.SteamUserId, Context.Player.Identity.IdentityId); data.InAllianceChat = true; AllianceChat.PeopleInAllianceChat.Add(Context.Player.SteamUserId, alliance.AllianceId); Context.Respond("Entering alliance chat.", Color.Cyan); utils.WriteToXmlFile <PlayerData>(AlliancePlugin.path + "//PlayerData//" + Context.Player.SteamUserId + ".xml", data); } } else { Context.Respond("You must be in an alliance to use alliance chat."); } }
public void BankLog(string timeformat = "MM-dd-yyyy") { if (Context.Player != null) { //Do stuff with taking components from grid storage //GridCosts localGridCosts = GetComponentsAndCost(projectedGrid); //gridCosts.setComponents(localGridCosts.getComponents()); IMyFaction faction = FacUtils.GetPlayersFaction(Context.Player.IdentityId); if (faction == null) { Context.Respond("You must be in a faction to use alliance features."); return; } Alliance alliance = AlliancePlugin.GetAlliance(faction as MyFaction); if (alliance == null) { Context.Respond("You are not a member of an alliance with an unlocked shipyard."); return; } if (AlliancePlugin.HasFailedUpkeep(alliance)) { Context.Respond("Alliance failed to pay upkeep. Upgrades disabled."); return; } if (alliance.hasUnlockedHangar) { HangarData data = alliance.LoadHangar(); HangarLog log = data.GetHangarLog(alliance); StringBuilder sb = new StringBuilder(); log.log.Reverse(); foreach (HangarLogItem item in log.log) { sb.AppendLine(item.time.ToString(timeformat) + " : " + AlliancePlugin.GetPlayerName(item.steamid) + " " + item.action + " " + item.GridName.Split('_')[0]); continue; } DialogMessage m = new DialogMessage("Alliance Hangar Records", alliance.name, sb.ToString()); ModCommunication.SendMessageTo(m, Context.Player.SteamUserId); } else { Context.Respond("Alliance has not unlocked hangar."); } } }
public void RentGate(string name) { MyFaction fac = MySession.Static.Factions.GetPlayerFaction(Context.Player.IdentityId); if (fac == null) { Context.Respond("Only factions can be in alliances."); return; } Alliance alliance = AlliancePlugin.GetAlliance(fac); if (alliance == null) { Context.Respond("Only members of an alliance may rent a gate."); return; } if (alliance != null) { if (alliance.SupremeLeader == Context.Player.SteamUserId || alliance.HasAccess(Context.Player.SteamUserId, AccessLevel.PayFromBank)) { JumpGate gate1 = null; JumpGate gate2 = null; AlliancePlugin.LoadAllGates(); foreach (JumpGate gate in AlliancePlugin.AllGates.Values) { if (gate.GateName.Equals(name) && gate.CanBeRented && DateTime.Now >= gate.NextRentAvailable) { gate1 = gate; gate2 = AlliancePlugin.AllGates[gate.TargetGateId]; break; } } if (gate1 == null || gate2 == null) { Context.Respond("Could not find one of those gates."); return; } if (alliance.CurrentMetaPoints >= gate1.MetaPointRentCost) { alliance.CurrentMetaPoints -= gate1.MetaPointRentCost; gate1.OwnerAlliance = alliance.AllianceId; gate2.OwnerAlliance = alliance.AllianceId; gate1.NextRentAvailable = DateTime.Now.AddDays(gate1.DaysPerRent); gate2.NextRentAvailable = DateTime.Now.AddDays(gate1.DaysPerRent); AlliancePlugin.AllGates[gate1.GateId] = gate1; AlliancePlugin.AllGates[gate2.GateId] = gate2; gate1.Save(); gate2.Save(); Context.Respond("Successfully rented gate for " + gate1.DaysPerRent + " Days. Fees can now be set with !jumpgate fee <gateName> <amount>"); Context.Respond("Gate names, " + gate1.GateName + ", " + gate2.GateName); AlliancePlugin.SaveAllianceData(alliance); return; } else { Context.Respond("Cannot afford the meta point cost of " + gate1.MetaPointRentCost); return; } } else { Context.Respond("You dont have the rank to do this."); } } }
public void SetFee(string name, string target, string inputAmount) { MyFaction fac = MySession.Static.Factions.GetPlayerFaction(Context.Player.IdentityId); if (fac == null) { Context.Respond("Only factions can be in alliances."); return; } Int64 amount; inputAmount = inputAmount.Replace(",", ""); inputAmount = inputAmount.Replace(".", ""); inputAmount = inputAmount.Replace(" ", ""); try { amount = Int64.Parse(inputAmount); } catch (Exception) { Context.Respond("Error parsing amount", Color.Red, "Bank Man"); return; } if (amount < 0 || amount == 0) { Context.Respond("Must be a positive amount", Color.Red, "Bank Man"); return; } if (amount >= AlliancePlugin.config.MaximumGateFee) { Context.Respond("Amount exceeds the maximum of " + String.Format("{0:n0}", AlliancePlugin.config.MaximumGateFee) + " SC."); return; } Alliance alliance = AlliancePlugin.GetAlliance(fac); if (alliance == null) { Context.Respond("Only members of an alliance can set a gate fee."); return; } if (alliance != null) { if (alliance.SupremeLeader == Context.Player.SteamUserId || alliance.HasAccess(Context.Player.SteamUserId, AccessLevel.PayFromBank)) { JumpGate gate1 = null; JumpGate gate2 = null; foreach (JumpGate gate in AlliancePlugin.AllGates.Values) { if (gate.GateName.Equals(name) && gate.OwnerAlliance == alliance.AllianceId) { gate1 = gate; continue; } if (gate.GateName.Equals(target) && gate.OwnerAlliance == alliance.AllianceId) { gate2 = gate; continue; } } if (gate1 == null || gate2 == null) { Context.Respond("Could not find one of those gates, does the alliance own it?."); return; } Context.Respond("Fee updated."); gate1.fee = amount; gate2.fee = amount; AlliancePlugin.AllGates[gate1.GateId] = gate1; AlliancePlugin.AllGates[gate2.GateId] = gate2; gate1.Save(); gate2.Save(); } else { Context.Respond("You dont have the rank to do this."); } } }
public void SaveToHangar() { if (!AlliancePlugin.config.HangarEnabled) { Context.Respond("Alliance hangar is not enabled."); return; } if (MySession.Static.IsSaveInProgress) { Context.Respond("World is saving! Try again soon."); return; } if (cooldowns.TryGetValue(Context.Player.IdentityId, out DateTime value)) { if (DateTime.Now <= value) { Context.Respond(GetCooldownMessage(value)); return; } else { cooldowns[Context.Player.IdentityId] = DateTime.Now.AddSeconds(60); } } else { cooldowns.Add(Context.Player.IdentityId, DateTime.Now.AddSeconds(60)); } if (MyGravityProviderSystem.IsPositionInNaturalGravity(Context.Player.GetPosition())) { Context.Respond("You cannot use this command in natural gravity!"); return; } foreach (DeniedLocation denied in AlliancePlugin.HangarDeniedLocations) { if (Vector3.Distance(Context.Player.GetPosition(), new Vector3(denied.x, denied.y, denied.z)) <= denied.radius) { Context.Respond("Cannot hangar here! Too close to a denied location."); return; } } Boolean console = false; if (Context.Player == null) { console = true; } MyFaction fac = MySession.Static.Factions.GetPlayerFaction(Context.Player.IdentityId); if (fac == null) { Context.Respond("You must be in a faction to use alliance features."); return; } Alliance alliance = AlliancePlugin.GetAlliance(fac); if (alliance == null) { Context.Respond("You are not a member of an alliance."); return; } if (AlliancePlugin.HasFailedUpkeep(alliance)) { Context.Respond("Alliance failed to pay upkeep. Upgrades disabled."); return; } if (!alliance.HasAccess(Context.Player.SteamUserId, AccessLevel.HangarSave)) { Context.Respond("Current rank does not have access to hangar save."); return; } if (alliance.hasUnlockedHangar) { HangarData hangar = alliance.LoadHangar(); if (hangar == null) { Context.Respond("Error loading the hangar."); return; } string name = ""; int pcu = 0; if (hangar.getAvailableSlot() > 0) { ConcurrentBag <MyGroups <MyCubeGrid, MyGridPhysicalGroupData> .Group> gridWithSubGrids = GridFinder.FindLookAtGridGroup(Context.Player.Character); List <MyCubeGrid> grids = new List <MyCubeGrid>(); foreach (var item in gridWithSubGrids) { foreach (MyGroups <MyCubeGrid, MyGridPhysicalGroupData> .Node groupNodes in item.Nodes) { MyCubeGrid grid = groupNodes.NodeData; if (grid.Projector != null) { continue; } if (FacUtils.IsOwnerOrFactionOwned(grid, Context.Player.IdentityId, true)) { pcu += grid.BlocksPCU; foreach (MyProjectorBase proj in grid.GetFatBlocks().OfType <MyProjectorBase>()) { proj.Clipboard.Clear(); } grids.Add(grid); if (name == "") { name = grid.DisplayName; name = name.Replace("/", ""); name = name.Replace("-", ""); name = name.Replace("\\", ""); } } else { Context.Respond("The grid you are looking at includes a grid that isnt owned by you or a faction member."); return; } } } if (grids.Count == 0) { Context.Respond("Could not find grid."); return; } if (name == "") { name = "Temporary Name"; } if (pcu >= AlliancePlugin.config.MaxHangarSlotPCU) { Context.Respond("PCU is greater than the configured maximum"); return; } bool result = hangar.SaveGridToHangar(name + "_" + string.Format("{0:yyyy-MM-dd_HH-mm-ss-fff}", DateTime.Now), Context.Player.SteamUserId, alliance, Context.Player.Character.PositionComp.GetPosition(), fac, grids, Context.Player.IdentityId); if (!result) { Context.Respond("Could not save. Are enemies within 15km?"); } else { Context.Respond("Grid saved."); foreach (MyCubeGrid grid in grids) { if (grid != null) { grid.Close(); } } } } else { Context.Respond("Hangar is full, to upgrade use !ah upgrade true."); } } else { Context.Respond("Alliance has not unlocked the hangar to unlock use !ah unlock."); } }
public void LoadFromHangar(string slotNumber) { if (!AlliancePlugin.config.HangarEnabled) { Context.Respond("Alliance hangar is not enabled."); return; } if (cooldowns.TryGetValue(Context.Player.IdentityId, out DateTime value)) { if (DateTime.Now <= value) { Context.Respond(GetCooldownMessage(value)); return; } else { cooldowns[Context.Player.IdentityId] = DateTime.Now.AddSeconds(60); } } else { cooldowns.Add(Context.Player.IdentityId, DateTime.Now.AddSeconds(60)); } MyFaction fac = MySession.Static.Factions.GetPlayerFaction(Context.Player.IdentityId); if (fac == null) { Context.Respond("You must be in a faction to use alliance features."); return; } Alliance alliance = AlliancePlugin.GetAlliance(fac); if (alliance == null) { Context.Respond("You are not a member of an alliance."); return; } if (AlliancePlugin.HasFailedUpkeep(alliance)) { Context.Respond("Alliance failed to pay upkeep. Upgrades disabled."); return; } if (!alliance.HasAccess(Context.Player.SteamUserId, AccessLevel.HangarLoad) && !alliance.HasAccess(Context.Player.SteamUserId, AccessLevel.HangarLoadOther)) { Context.Respond("Current rank does not have access to hangar load."); return; } if (alliance.hasUnlockedHangar) { HangarData hangar = alliance.LoadHangar(); if (hangar == null) { Context.Respond("Error loading the hangar."); return; } int slot; try { slot = int.Parse(slotNumber); } catch (Exception) { Context.Respond("Cannot parse that number."); return; } if (!hangar.ItemsInHangar.ContainsKey(slot)) { Context.Respond("No grid available to load for that number!"); return; } HangarItem item = hangar.ItemsInHangar[slot]; //this took up way too much of one line if (hangar.LoadGridFromHangar(slot, Context.Player.SteamUserId, alliance, Context.Player.Identity as MyIdentity, fac)) { Context.Respond("Grid should be loaded!"); } else { Context.Respond("Could not load, are there enemies within 15km?"); MyGps gps = new MyGps { Coords = item.position, Name = item.name + " Failed load location", DisplayName = item.name + " Failed load location", Description = "Failed load location", GPSColor = Color.LightBlue, IsContainerGPS = true, ShowOnHud = true, DiscardAt = new TimeSpan(50000) }; gps.UpdateHash(); MyGpsCollection gpscol = (MyGpsCollection)MyAPIGateway.Session?.GPS; gpscol.SendAddGps(Context.Player.IdentityId, ref gps); } } else { Context.Respond("Alliance has not unlocked the hangar to unlock use !ah unlock."); } }
public void UnlockHangar() { if (!AlliancePlugin.config.HangarEnabled) { Context.Respond("Alliance hangar is not enabled."); return; } Boolean console = false; if (Context.Player == null) { console = true; } MyFaction fac = MySession.Static.Factions.GetPlayerFaction(Context.Player.IdentityId); if (fac == null) { Context.Respond("You must be in a faction to use alliance features."); return; } Alliance alliance = AlliancePlugin.GetAlliance(fac); if (alliance == null) { Context.Respond("You are not a member of an alliance."); return; } if (AlliancePlugin.HasFailedUpkeep(alliance)) { Context.Respond("Alliance failed to pay upkeep. Upgrades disabled."); return; } if (!alliance.hasUnlockedHangar) { ConcurrentBag <MyGroups <MyCubeGrid, MyGridPhysicalGroupData> .Group> gridWithSubGrids = GridFinder.FindLookAtGridGroup(Context.Player.Character); List <MyCubeGrid> grids = new List <MyCubeGrid>(); foreach (var item in gridWithSubGrids) { foreach (MyGroups <MyCubeGrid, MyGridPhysicalGroupData> .Node groupNodes in item.Nodes) { MyCubeGrid grid = groupNodes.NodeData; if (grid.Projector != null) { continue; } if (FacUtils.GetPlayersFaction(FacUtils.GetOwner(grid)) != null) { if (FacUtils.InSameFaction(FacUtils.GetOwner(grid), Context.Player.IdentityId)) { if (!grids.Contains(grid)) { grids.Add(grid); } } } else { if (FacUtils.GetOwner(grid).Equals(Context.Player.Identity.IdentityId)) { if (!grids.Contains(grid)) { grids.Add(grid); } } } } } //Do stuff with taking components from grid storage //GridCosts localGridCosts = GetComponentsAndCost(projectedGrid); //gridCosts.setComponents(localGridCosts.getComponents()); UpgradeCost cost = new UpgradeCost(); List <VRage.Game.ModAPI.IMyInventory> invents = new List <VRage.Game.ModAPI.IMyInventory>(); foreach (MyCubeGrid grid in grids) { invents.AddList(ShipyardCommands.GetInventories(grid)); } cost = ShipyardCommands.LoadUnlockCost(AlliancePlugin.path + "//HangarUnlockCost.txt"); if (cost != null) { if (cost.MetaPointCost > 0) { if (alliance.CurrentMetaPoints < cost.MetaPointCost) { Context.Respond("Cannot afford the meta point cost of " + cost.MetaPointCost); return; } } if (cost.MoneyRequired > 0) { if (EconUtils.getBalance(Context.Player.IdentityId) >= cost.MoneyRequired) { if (ShipyardCommands.ConsumeComponents(invents, cost.itemsRequired, Context.Player.SteamUserId)) { alliance.CurrentMetaPoints -= cost.MetaPointCost; EconUtils.takeMoney(Context.Player.IdentityId, cost.MoneyRequired); alliance.hasUnlockedHangar = true; HangarData hangar = alliance.LoadHangar(); AlliancePlugin.SaveAllianceData(alliance); ShipyardCommands.SendMessage("[Alliance Hangar]", "Unlocking the hangar. You were charged: " + String.Format("{0:n0}", cost.MoneyRequired) + " and components taken", Color.Green, (long)Context.Player.SteamUserId); } } else { ShipyardCommands.SendMessage("[Alliance Hangar]", "You cant afford the upgrade price of: " + String.Format("{0:n0}", cost.MoneyRequired), Color.Red, (long)Context.Player.SteamUserId); } } else { if (ShipyardCommands.ConsumeComponents(invents, cost.itemsRequired, Context.Player.SteamUserId)) { alliance.CurrentMetaPoints -= cost.MetaPointCost; alliance.hasUnlockedHangar = true; HangarData hangar = alliance.LoadHangar(); AlliancePlugin.SaveAllianceData(alliance); } } } else { Context.Respond("Error loading upgrade details."); return; } } }
public void Upgrade(Boolean upgrade = false) { if (!AlliancePlugin.config.HangarEnabled) { Context.Respond("Hangar not enabled."); return; } if (Context.Player != null) { IMyFaction faction = FacUtils.GetPlayersFaction(Context.Player.IdentityId); if (faction == null) { ShipyardCommands.SendMessage("[Hangar]", " You arent in a faction.", Color.Red, (long)Context.Player.SteamUserId); return; } Alliance alliance = AlliancePlugin.GetAlliance(faction as MyFaction); if (alliance == null) { Context.Respond("You are not a member of an alliance with an unlocked shipyard."); return; } if (AlliancePlugin.HasFailedUpkeep(alliance)) { Context.Respond("Alliance failed to pay upkeep. Upgrades disabled."); return; } if (!alliance.hasUnlockedHangar) { ShipyardCommands.SendMessage("[Alliance Hangar]", "To unlock use !ah unlock", Color.Cyan, (long)Context.Player.SteamUserId); return; } HangarData hangar = alliance.LoadHangar(); UpgradeCost cost = new UpgradeCost(); if (!upgrade) { ShipyardCommands.SendMessage("[Alliance Hangar]", "To upgrade use !ah upgrade true ,while looking at an owned grid.", Color.Cyan, (long)Context.Player.SteamUserId); StringBuilder sb = new StringBuilder(); try { cost = slotUpgrades[hangar.SlotUpgradeNum += 1]; } catch (Exception ex) { Context.Respond("Cannot upgrade any further as there are no more defined upgrade files."); return; } if (cost != null) { if (cost.MoneyRequired > 0) { ShipyardCommands.SendMessage("[Alliance Hangar]", "SC Cost for next slot upgrade " + String.Format("{0:n0}", cost.MoneyRequired), Color.Cyan, (long)Context.Player.SteamUserId); } if (cost.MetaPointCost > 0) { ShipyardCommands.SendMessage("[Alliance Hangar]", "Metapoint cost for next slot upgrade " + cost.MetaPointCost, Color.Cyan, (long)Context.Player.SteamUserId); } sb.AppendLine("Items required."); foreach (KeyValuePair <MyDefinitionId, int> id in cost.itemsRequired) { sb.AppendLine(id.Key.ToString() + " - " + id.Value); } Context.Respond(sb.ToString()); } } else { ConcurrentBag <MyGroups <MyCubeGrid, MyGridMechanicalGroupData> .Group> gridWithSubGrids = GridFinder.FindLookAtGridGroupMechanical(Context.Player.Character); List <MyCubeGrid> grids = new List <MyCubeGrid>(); foreach (var item in gridWithSubGrids) { foreach (MyGroups <MyCubeGrid, MyGridMechanicalGroupData> .Node groupNodes in item.Nodes) { MyCubeGrid grid = groupNodes.NodeData; if (grid.Projector != null) { continue; } if (FacUtils.GetPlayersFaction(FacUtils.GetOwner(grid)) != null) { if (FacUtils.InSameFaction(FacUtils.GetOwner(grid), Context.Player.IdentityId)) { if (!grids.Contains(grid)) { grids.Add(grid); } } } else { if (FacUtils.GetOwner(grid).Equals(Context.Player.Identity.IdentityId)) { if (!grids.Contains(grid)) { grids.Add(grid); } } } } } List <VRage.Game.ModAPI.IMyInventory> invents = new List <VRage.Game.ModAPI.IMyInventory>(); foreach (MyCubeGrid grid in grids) { invents.AddList(ShipyardCommands.GetInventories(grid)); } if (hangar.SlotsAmount >= AlliancePlugin.config.MaxHangarSlots) { Context.Respond("Cannot upgrade any further"); return; } try { cost = slotUpgrades[hangar.SlotUpgradeNum += 1]; } catch (Exception) { Context.Respond("Cannot upgrade any further as there are no more defined upgrade files."); return; } if (cost != null) { if (cost.MetaPointCost > 0) { if (alliance.CurrentMetaPoints < cost.MetaPointCost) { Context.Respond("Cannot afford the meta point cost of " + cost.MetaPointCost); return; } } if (cost.MoneyRequired > 0) { if (EconUtils.getBalance(Context.Player.IdentityId) >= cost.MoneyRequired) { if (ShipyardCommands.ConsumeComponents(invents, cost.itemsRequired, Context.Player.SteamUserId)) { alliance.CurrentMetaPoints -= cost.MetaPointCost; EconUtils.takeMoney(Context.Player.IdentityId, cost.MoneyRequired); hangar.SlotsAmount = (int)cost.NewLevel; hangar.SlotUpgradeNum++; hangar.SaveHangar(alliance); AlliancePlugin.SaveAllianceData(alliance); ShipyardCommands.SendMessage("[Alliance Hangar]", "Upgrading slots. You were charged: " + String.Format("{0:n0}", cost.MoneyRequired), Color.LightBlue, (long)Context.Player.SteamUserId); } } else { ShipyardCommands.SendMessage("[Alliance Hangar]", "You cant afford the upgrade price of: " + String.Format("{0:n0}", cost.MoneyRequired), Color.Red, (long)Context.Player.SteamUserId); } } else { if (ShipyardCommands.ConsumeComponents(invents, cost.itemsRequired, Context.Player.SteamUserId)) { alliance.CurrentMetaPoints -= cost.MetaPointCost; hangar.SlotsAmount = (int)cost.NewLevel; hangar.SlotUpgradeNum++; hangar.SaveHangar(alliance); AlliancePlugin.SaveAllianceData(alliance); } } } else { Context.Respond("Error loading upgrade details."); return; } } } }