public static VerifyAndCreate ( |
||
data | ||
Résultat | void |
private static void ValidateAndUpdateData(EconDataStruct data, List <MarketItemStruct> defaultPrices) { EconomyScript.Instance.ServerLogger.WriteInfo("Validating and Updating Data."); // Add missing items that are covered by Default items. foreach (var defaultItem in defaultPrices) { foreach (var market in data.Markets) { var item = market.MarketItems.FirstOrDefault(e => e.TypeId.Equals(defaultItem.TypeId) && e.SubtypeName.Equals(defaultItem.SubtypeName)); if (item == null) { market.MarketItems.Add(new MarketItemStruct { TypeId = defaultItem.TypeId, SubtypeName = defaultItem.SubtypeName, BuyPrice = defaultItem.BuyPrice, SellPrice = defaultItem.SellPrice, IsBlacklisted = defaultItem.IsBlacklisted, Quantity = defaultItem.Quantity }); EconomyScript.Instance.ServerLogger.WriteVerbose("MarketItem Adding Default item: {0} {1}.", defaultItem.TypeId, defaultItem.SubtypeName); } else { // Disable any blackmarket items. if (!defaultItem.IsBlacklisted) { item.IsBlacklisted = false; } } } } // Buy/Sell - check we have our NPC banker ready NpcMerchantManager.VerifyAndCreate(data); // Initial check of account on server load. AccountManager.CheckAccountExpiry(data); }
private static void ValidateAndUpdateData(EconDataStruct data, List <MarketItemStruct> defaultPrices) { EconomyScript.Instance.ServerLogger.WriteInfo("Validating and Updating Data."); if (data.Accounts != null) { if (data.Accounts.Count != 0) { if (data.Clients == null) { data.Clients = new List <ClientAccountStruct>(); } foreach (BankAccountStruct account in data.Accounts) { data.Clients.Add(new ClientAccountStruct { SteamId = account.SteamId, BankBalance = account.BankBalance, Date = account.Date, OpenedDate = account.OpenedDate, MissionId = account.MissionId, Language = account.Language, NickName = account.NickName }); } } data.Accounts = null; } foreach (ClientAccountStruct client in data.Clients) { if (client.ClientHudSettings == null) { client.ClientHudSettings = new ClientHudSettingsStruct(); } } foreach (var market in data.Markets) { AddMissingItemsToMarket(market, defaultPrices); } if (data.Missions == null) { data.Missions = new List <MissionBaseStruct>(); } // Buy/Sell - check we have our NPC banker ready NpcMerchantManager.VerifyAndCreate(data); // Initial check of account on server load. AccountManager.CheckAccountExpiry(data); }
private static void ValidateAndUpdateData(EconDataStruct data, List <MarketItemStruct> defaultPrices) { EconomyScript.Instance.ServerLogger.WriteInfo("Validating and Updating Data."); // Add missing items that are covered by Default items. foreach (var defaultItem in defaultPrices) { foreach (var market in data.Markets) { var item = market.MarketItems.FirstOrDefault(e => e.TypeId.Equals(defaultItem.TypeId) && e.SubtypeName.Equals(defaultItem.SubtypeName)); var isNpcMerchant = market.MarketId == EconomyConsts.NpcMerchantId; // make sure no stock is added to player markets. // TODO: remove this later. It's a temporary fix to setup the new Open property. // Added 01.125. if (isNpcMerchant) { market.Open = true; } if (item == null) { market.MarketItems.Add(new MarketItemStruct { TypeId = defaultItem.TypeId, SubtypeName = defaultItem.SubtypeName, BuyPrice = defaultItem.BuyPrice, SellPrice = defaultItem.SellPrice, IsBlacklisted = defaultItem.IsBlacklisted, Quantity = isNpcMerchant ? defaultItem.Quantity : 0 }); EconomyScript.Instance.ServerLogger.WriteVerbose("MarketItem Adding Default item: {0} {1}.", defaultItem.TypeId, defaultItem.SubtypeName); } else { // Disable any blackmarket items. if (defaultItem.IsBlacklisted) { item.IsBlacklisted = true; } } } } if (data.Missions == null) { data.Missions = new List <MissionBaseStruct>(); } // Buy/Sell - check we have our NPC banker ready NpcMerchantManager.VerifyAndCreate(data); // Initial check of account on server load. AccountManager.CheckAccountExpiry(data); }