Esempio n. 1
0
 public static void Initialize()
 {
     Shop.Initialized = false;
     Config.Get("SHOP", "Enabled", ref Shop.Enabled, true);
     Config.Get("SHOP", "TradeZoneOnly", ref Shop.TradeZoneOnly, true);
     Config.Get("SHOP", "CanSell", ref Shop.CanSell, true);
     Config.Get("SHOP", "CanBuy", ref Shop.CanBuy, true);
     Shop.GroupCount   = 0;
     Shop.ItemCount    = 0;
     Shop.shopGroup_0  = new ShopGroup(null, 0);
     Shop.dictionary_0 = new Dictionary <ShopGroup, List <ShopItem> >();
     Shop.dictionary_0.Add(Shop.shopGroup_0, new List <ShopItem>());
     string[] array = null;
     Config.Get("SHOP.LIST", "ENTRY", ref array, true);
     string[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         string   text   = array2[i];
         string[] array3 = text.Split(new char[]
         {
             '='
         });
         if (array3.Length >= 2)
         {
             if (array3[0].Equals("SHOPITEM", StringComparison.OrdinalIgnoreCase))
             {
                 ShopItem shopItem = Shop.smethod_0(array3[1]);
                 if (shopItem == null)
                 {
                     goto IL_199;
                 }
                 Shop.dictionary_0[Shop.shopGroup_0].Add(shopItem);
             }
             if (array3[0].Equals("SHOPGROUP", StringComparison.OrdinalIgnoreCase))
             {
                 array3[1] = array3[1].Trim(new char[]
                 {
                     '"'
                 });
                 Shop.GroupCount++;
                 ShopGroup key = new ShopGroup(array3[1], Shop.GroupCount);
                 Shop.dictionary_0.Add(key, new List <ShopItem>());
             }
         }
         IL_199 :;
     }
     foreach (ShopGroup current in Shop.dictionary_0.Keys)
     {
         string[] array4 = null;
         if (current.Name != null)
         {
             if (Config.Get("SHOP.GROUP", current.Name, ref array4, true))
             {
                 string[] array5 = array4;
                 for (int j = 0; j < array5.Length; j++)
                 {
                     string   text2  = array5[j];
                     string[] array6 = text2.Split(new char[]
                     {
                         '='
                     });
                     string[] array7    = Helper.SplitQuotes(array6[1], ',');
                     ShopItem shopItem2 = Shop.smethod_0(array6[1]);
                     if (shopItem2 == null)
                     {
                         ConsoleSystem.PrintError("[SHOP]ERROR: Item not found or not enough of parameters for '" + array7[0] + "'.", false);
                     }
                     else if (Shop.dictionary_0[current].Contains(shopItem2))
                     {
                         ConsoleSystem.PrintError(string.Concat(new string[]
                         {
                             "[SHOP]ERROR: Item '",
                             array7[0],
                             "' already exists in group '",
                             current.Name,
                             "'."
                         }), false);
                     }
                     else
                     {
                         Shop.dictionary_0[current].Add(shopItem2);
                     }
                 }
             }
             else
             {
                 ConsoleSystem.PrintError("[SHOP]ERROR: Group named '" + current.Name + "' not exists in configuration. Skipped.", false);
             }
         }
     }
     Shop.Initialized = true;
 }
Esempio n. 2
0
 public static void Initialize()
 {
     Initialized = false;
     Config.Get("SHOP", "Enabled", ref Enabled, true);
     Config.Get("SHOP", "TradeZoneOnly", ref TradeZoneOnly, true);
     Config.Get("SHOP", "CanSell", ref CanSell, true);
     Config.Get("SHOP", "CanBuy", ref CanBuy, true);
     GroupCount   = 0;
     ItemCount    = 0;
     shopGroup_0  = new ShopGroup(null, 0);
     dictionary_0 = new Dictionary <ShopGroup, System.Collections.Generic.List <ShopItem> >();
     dictionary_0.Add(shopGroup_0, new System.Collections.Generic.List <ShopItem>());
     string[] result = null;
     Config.Get("SHOP.LIST", "ENTRY", ref result, true);
     foreach (string str in result)
     {
         string[] strArray2 = str.Split(new char[] { '=' });
         if (strArray2.Length >= 2)
         {
             if (strArray2[0].Equals("SHOPITEM", StringComparison.OrdinalIgnoreCase))
             {
                 ShopItem item = smethod_0(strArray2[1]);
                 if (item == null)
                 {
                     continue;
                 }
                 dictionary_0[shopGroup_0].Add(item);
             }
             if (strArray2[0].Equals("SHOPGROUP", StringComparison.OrdinalIgnoreCase))
             {
                 strArray2[1] = strArray2[1].Trim(new char[] { '"' });
                 GroupCount++;
                 ShopGroup key = new ShopGroup(strArray2[1], GroupCount);
                 dictionary_0.Add(key, new System.Collections.Generic.List <ShopItem>());
             }
         }
     }
     foreach (ShopGroup group2 in dictionary_0.Keys)
     {
         string[] strArray3 = null;
         if (group2.Name != null)
         {
             if (Config.Get("SHOP.GROUP", group2.Name, ref strArray3, true))
             {
                 foreach (string str2 in strArray3)
                 {
                     string[] strArray4 = str2.Split(new char[] { '=' });
                     string[] strArray5 = Helper.SplitQuotes(strArray4[1], ',');
                     ShopItem item2     = smethod_0(strArray4[1]);
                     if (item2 == null)
                     {
                         ConsoleSystem.PrintError("[SHOP]ERROR: Item not found or not enough of parameters for '" + strArray5[0] + "'.", false);
                     }
                     else if (dictionary_0[group2].Contains(item2))
                     {
                         ConsoleSystem.PrintError("[SHOP]ERROR: Item '" + strArray5[0] + "' already exists in group '" + group2.Name + "'.", false);
                     }
                     else
                     {
                         dictionary_0[group2].Add(item2);
                     }
                 }
             }
             else
             {
                 ConsoleSystem.PrintError("[SHOP]ERROR: Group named '" + group2.Name + "' not exists in configuration. Skipped.", false);
             }
         }
     }
     Initialized = true;
 }