Esempio n. 1
0
 //Game Functions
 public void OnModulesLoaded()
 {
     if (File.Exists(Directory.GetCurrentDirectory() + "\\save\\PyPlugins\\Clans\\Clans.ini"))
     {
         ClansSupport = true;
         ClansIni     = new IniParser(Directory.GetCurrentDirectory() + "\\save\\PyPlugins\\Clans\\Clans.ini");
     }
     else
     {
         ConsoleSystem.PrintError("Plugin " + Name + " " + Version.ToString() + " Integration with Clans has Failed!!");
         ClansSupport = false;
     }
 }
Esempio n. 2
0
 public static void LogError(string msg, bool inConsole = true)
 {
     using (FileStream fileStream = new FileStream(Loader.RustLogFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
     {
         using (StreamWriter streamWriter = new StreamWriter(fileStream))
         {
             streamWriter.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "[ERROR]: " + msg);
         }
     }
     File.SetLastWriteTime(Loader.RustLogFile, DateTime.Now);
     if (inConsole)
     {
         ConsoleSystem.PrintError(msg, false);
     }
 }
Esempio n. 3
0
 public static void SQL_UpdateServer()
 {
     MySQL.Result result = MySQL.Query("SELECT * FROM `db_server`;", true);
     if (result != null)
     {
         foreach (MySQL.Row row in result.Row)
         {
             if (row.Get("name").AsString.Equals("rcon_command", StringComparison.OrdinalIgnoreCase) && !row.Get("value").IsNull)
             {
                 ConsoleSystem.Arg arg = new ConsoleSystem.Arg(row.Get("value").AsString);
                 if (!ConsoleSystem.RunCommand(ref arg, true))
                 {
                     ConsoleSystem.PrintError(arg.Reply, false);
                 }
                 MySQL.Update(string.Format(SQL_SERVER_SET, row.Get("name").AsString, "NULL"));
             }
         }
     }
     MySQL.Update(string.Format(SQL_SERVER_SET, "time_update", MySQL.QuoteString(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))));
 }
Esempio n. 4
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. 5
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;
 }
        private static bool smethod_0()
        {
            System.Collections.Generic.List <string> list = File.ReadAllLines(LootsFile).ToList <string>();
            if (predicate_0 == null)
            {
                predicate_0 = new Predicate <string>(Override.smethod_6);
            }
            if (!list.Exists(predicate_0))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"AILootList\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            if (predicate_1 == null)
            {
                predicate_1 = new Predicate <string>(Override.smethod_7);
            }
            if (!list.Exists(predicate_1))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"AmmoSpawnList\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            if (predicate_2 == null)
            {
                predicate_2 = new Predicate <string>(Override.smethod_8);
            }
            if (!list.Exists(predicate_2))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"JunkSpawnList\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            if (predicate_3 == null)
            {
                predicate_3 = new Predicate <string>(Override.smethod_9);
            }
            if (!list.Exists(predicate_3))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"MedicalSpawnList\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            if (predicate_4 == null)
            {
                predicate_4 = new Predicate <string>(Override.smethod_10);
            }
            if (!list.Exists(predicate_4))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"WeaponSpawnList\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            if (predicate_5 == null)
            {
                predicate_5 = new Predicate <string>(Override.smethod_11);
            }
            if (!list.Exists(predicate_5))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"SupplyDropSpawnListMaster\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            DatablockDictionary._lootSpawnLists.Clear();
            Dictionary <string, LootSpawnList> dictionary = new Dictionary <string, LootSpawnList>();

            foreach (string str in list)
            {
                string str2 = str.Trim();
                if (!string.IsNullOrEmpty(str2) && !str2.StartsWith("//"))
                {
                    if (str2.Contains("//"))
                    {
                        str2 = str2.Split(new string[] { "//" }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                    }
                    if ((!string.IsNullOrEmpty(str2) && str2.StartsWith("[")) && str2.EndsWith("]"))
                    {
                        str2             = str2.Substring(1, str2.Length - 2);
                        dictionary[str2] = ScriptableObject.CreateInstance <LootSpawnList>();
                    }
                }
            }
            LootSpawnList list2 = null;

            LootSpawnList.LootWeightedEntry item = null;
            System.Collections.Generic.List <LootSpawnList.LootWeightedEntry> list3 = null;
            foreach (string str3 in list)
            {
                string str4 = str3.Trim();
                if (!string.IsNullOrEmpty(str4) && !str4.StartsWith("//"))
                {
                    if (str4.Contains("//"))
                    {
                        str4 = str4.Split(new string[] { "//" }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                    }
                    if (!string.IsNullOrEmpty(str4))
                    {
                        if (str4.StartsWith("[") && str4.EndsWith("]"))
                        {
                            string str5 = str4.Substring(1, str4.Length - 2);
                            list2      = dictionary[str5];
                            list2.name = str5;
                            DatablockDictionary._lootSpawnLists.Add(list2.name, list2);
                            list3 = new System.Collections.Generic.List <LootSpawnList.LootWeightedEntry>();
                        }
                        else if (str4.Contains("=") && (list2 != null))
                        {
                            string   str6;
                            string[] strArray = str4.Split(new char[] { '=' });
                            if ((strArray.Length >= 2) && ((str6 = strArray[0].ToUpper()) != null))
                            {
                                if (str6 == "PACKAGESTOSPAWN")
                                {
                                    if (strArray[1].Contains(","))
                                    {
                                        strArray = strArray[1].Split(new char[] { ',' });
                                    }
                                    else
                                    {
                                        strArray = new string[] { strArray[1], strArray[1] };
                                    }
                                    int.TryParse(strArray[0], out list2.minPackagesToSpawn);
                                    int.TryParse(strArray[1], out list2.maxPackagesToSpawn);
                                }
                                else if (str6 == "SPAWNONEOFEACH")
                                {
                                    bool.TryParse(strArray[1], out list2.spawnOneOfEach);
                                }
                                else if (str6 == "NODUPLICATES")
                                {
                                    bool.TryParse(strArray[1], out list2.noDuplicates);
                                }
                                else if (str6 == "PACKAGELIST")
                                {
                                    strArray = strArray[1].Split(new string[] { "\t" }, StringSplitOptions.RemoveEmptyEntries);
                                    item     = new LootSpawnList.LootWeightedEntry();
                                    if (!dictionary.ContainsKey(strArray[1]))
                                    {
                                        ConsoleSystem.LogError(string.Format("Package {0} has a reference to an spawn list named {1}, but it not exist.", list2.name, strArray[1]));
                                    }
                                    else
                                    {
                                        item.obj = dictionary[strArray[1]];
                                        float.TryParse(strArray[0], out item.weight);
                                        int.TryParse(strArray[2], out item.amountMin);
                                        int.TryParse(strArray[3], out item.amountMax);
                                        list3.Add(item);
                                        list2.LootPackages = list3.ToArray();
                                    }
                                }
                                else if (str6 == "PACKAGEITEM")
                                {
                                    strArray = strArray[1].Split(new string[] { "\t" }, StringSplitOptions.RemoveEmptyEntries);
                                    item     = new LootSpawnList.LootWeightedEntry {
                                        obj = DatablockDictionary.GetByName(strArray[1])
                                    };
                                    if (item.obj == null)
                                    {
                                        ConsoleSystem.LogError(string.Format("Package {0} has a reference to an item named {1}, but it not exist.", list2.name, strArray[1]));
                                    }
                                    else
                                    {
                                        float.TryParse(strArray[0], out item.weight);
                                        int.TryParse(strArray[2], out item.amountMin);
                                        int.TryParse(strArray[3], out item.amountMax);
                                        list3.Add(item);
                                        list2.LootPackages = list3.ToArray();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }