Beispiel #1
0
        public static void print_prefabs(ConsoleSystem.Arg arg)
        {
            PrefabPoolCollection pool = GameManager.server.pool;

            if (pool.storage.Count == 0)
            {
                arg.ReplyWith("Prefab pool is empty.");
            }
            else
            {
                string    str1      = arg.GetString(0, string.Empty);
                TextTable textTable = new TextTable();
                textTable.AddColumn("id");
                textTable.AddColumn("name");
                textTable.AddColumn("count");
                foreach (KeyValuePair <uint, PrefabPool> keyValuePair in pool.storage)
                {
                    string str2 = keyValuePair.Key.ToString();
                    string path = StringPool.Get(keyValuePair.Key);
                    string str3 = keyValuePair.Value.Count.ToString();
                    if (string.IsNullOrEmpty(str1) || StringEx.Contains(path, str1, CompareOptions.IgnoreCase))
                    {
                        textTable.AddRow(new string[3]
                        {
                            str2,
                            Path.GetFileNameWithoutExtension(path),
                            str3
                        });
                    }
                }
                arg.ReplyWith(((object)textTable).ToString());
            }
        }
Beispiel #2
0
        public static void export_prefabs(ConsoleSystem.Arg arg)
        {
            PrefabPoolCollection pool = GameManager.server.pool;

            if (pool.storage.Count == 0)
            {
                arg.ReplyWith("Prefab pool is empty.");
            }
            else
            {
                string        str1          = arg.GetString(0, string.Empty);
                StringBuilder stringBuilder = new StringBuilder();
                foreach (KeyValuePair <uint, PrefabPool> keyValuePair in pool.storage)
                {
                    string str2 = keyValuePair.Key.ToString();
                    string path = StringPool.Get(keyValuePair.Key);
                    string str3 = keyValuePair.Value.Count.ToString();
                    if (string.IsNullOrEmpty(str1) || StringEx.Contains(path, str1, CompareOptions.IgnoreCase))
                    {
                        stringBuilder.AppendLine(string.Format("{0},{1},{2}", (object)str2, (object)Path.GetFileNameWithoutExtension(path), (object)str3));
                    }
                }
                File.WriteAllText("prefabs.csv", stringBuilder.ToString());
            }
        }
Beispiel #3
0
 private static bool ShouldIgnore(string path)
 {
     for (int index = 0; index < FileSystem_Warmup.excludeFilter.Length; ++index)
     {
         if (StringEx.Contains(path, FileSystem_Warmup.excludeFilter[index], CompareOptions.IgnoreCase))
         {
             return(true);
         }
     }
     return(false);
 }
        public static void breakitem(ConsoleSystem.Arg arg)
        {
            string str = arg.GetString(0, "");

            foreach (Item obj in arg.Player().inventory.containerMain.itemList)
            {
                if (StringEx.Contains(obj.info.shortname, str, CompareOptions.IgnoreCase) && obj.hasCondition)
                {
                    obj.LoseCondition(obj.condition * 2f);
                }
            }
        }
Beispiel #5
0
        public static IEnumerable <Output.Entry> search(ConsoleSystem.Arg arg)
        {
            string search = arg.GetString(0, (string)null);

            if (search == null)
            {
                return(Enumerable.Empty <Output.Entry>());
            }
            return(Output.HistoryOutput.Where <Output.Entry>((Func <Output.Entry, bool>)(x =>
            {
                if (x.Message.Length < 4096)
                {
                    return StringEx.Contains(x.Message, search, CompareOptions.IgnoreCase);
                }
                return false;
            })));
        }
Beispiel #6
0
 public static void print_assets(ConsoleSystem.Arg arg)
 {
     if (((Dictionary <System.Type, AssetPool.Pool>)AssetPool.storage).Count == 0)
     {
         arg.ReplyWith("Asset pool is empty.");
     }
     else
     {
         string    str1      = arg.GetString(0, string.Empty);
         TextTable textTable = new TextTable();
         textTable.AddColumn("type");
         textTable.AddColumn("allocated");
         textTable.AddColumn("available");
         using (Dictionary <System.Type, AssetPool.Pool> .Enumerator enumerator = ((Dictionary <System.Type, AssetPool.Pool>)AssetPool.storage).GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 KeyValuePair <System.Type, AssetPool.Pool> current = enumerator.Current;
                 string str2 = current.Key.ToString();
                 // ISSUE: explicit non-virtual call
                 string str3 = __nonvirtual(current.Value.allocated.ToString());
                 // ISSUE: explicit non-virtual call
                 string str4 = __nonvirtual(current.Value.available.ToString());
                 if (string.IsNullOrEmpty(str1) || StringEx.Contains(str2, str1, CompareOptions.IgnoreCase))
                 {
                     textTable.AddRow(new string[3]
                     {
                         str2,
                         str3,
                         str4
                     });
                 }
             }
         }
         arg.ReplyWith(((object)textTable).ToString());
     }
 }
Beispiel #7
0
        public static void status(ConsoleSystem.Arg arg)
        {
            string str1 = arg.GetString(0, "");
            string str2 = string.Empty;

            if (str1.Length == 0)
            {
                str2 = str2 + "hostname: " + Server.hostname + "\n" + "version : " + 2161.ToString() + " secure (secure mode enabled, connected to Steam3)\n" + "map     : " + Server.level + "\n" + "players : " + (object)BasePlayer.activePlayerList.Count <BasePlayer>() + " (" + (object)Server.maxplayers + " max) (" + (object)((ServerMgr)SingletonComponent <ServerMgr> .Instance).connectionQueue.Queued + " queued) (" + (object)((ServerMgr)SingletonComponent <ServerMgr> .Instance).connectionQueue.Joining + " joining)\n\n";
            }
            TextTable textTable = new TextTable();

            textTable.AddColumn("id");
            textTable.AddColumn("name");
            textTable.AddColumn("ping");
            textTable.AddColumn("connected");
            textTable.AddColumn("addr");
            textTable.AddColumn("owner");
            textTable.AddColumn("violation");
            textTable.AddColumn("kicks");
            foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
            {
                try
                {
                    if (activePlayer.IsValid())
                    {
                        string userIdString = activePlayer.UserIDString;
                        if (activePlayer.net.get_connection() == null)
                        {
                            textTable.AddRow(new string[2]
                            {
                                userIdString,
                                "NO CONNECTION"
                            });
                        }
                        else
                        {
                            // ISSUE: explicit non-virtual call
                            string str3 = __nonvirtual(activePlayer.net.get_connection().ownerid.ToString());
                            string str4 = StringExtensions.QuoteSafe(activePlayer.GetSubName(32));
                            string str5 = ((Server)Net.sv).GetAveragePing(activePlayer.net.get_connection()).ToString();
                            string str6 = (string)activePlayer.net.get_connection().ipaddress;
                            string str7 = activePlayer.violationLevel.ToString("0.0");
                            string str8 = activePlayer.GetAntiHackKicks().ToString();
                            if (!arg.get_IsAdmin() && !arg.get_IsRcon())
                            {
                                str6 = "xx.xxx.xx.xxx";
                            }
                            string str9 = activePlayer.net.get_connection().GetSecondsConnected().ToString() + "s";
                            if (str1.Length > 0 && !StringEx.Contains(str4, str1, CompareOptions.IgnoreCase) && (!userIdString.Contains(str1) && !str3.Contains(str1)))
                            {
                                if (!str6.Contains(str1))
                                {
                                    continue;
                                }
                            }
                            textTable.AddRow(new string[8]
                            {
                                userIdString,
                                str4,
                                str5,
                                str9,
                                str6,
                                str3 == userIdString ? string.Empty : str3,
                                str7,
                                str8
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    textTable.AddRow(new string[2]
                    {
                        activePlayer.UserIDString,
                        StringExtensions.QuoteSafe(ex.Message)
                    });
                }
            }
            arg.ReplyWith(str2 + ((object)textTable).ToString());
        }
Beispiel #8
0
        public static void stats(ConsoleSystem.Arg arg)
        {
            TextTable table = new TextTable();

            table.AddColumn("id");
            table.AddColumn("name");
            table.AddColumn("time");
            table.AddColumn("kills");
            table.AddColumn("deaths");
            table.AddColumn("suicides");
            table.AddColumn("player");
            table.AddColumn("building");
            table.AddColumn("entity");
            Action <ulong, string> action = (Action <ulong, string>)((id, name) =>
            {
                ServerStatistics.Storage storage = ServerStatistics.Get(id);
                string shortString = TimeSpan.FromSeconds((double)storage.Get("time")).ToShortString();
                string str1        = storage.Get("kill_player").ToString();
                string str2        = (storage.Get("deaths") - storage.Get("death_suicide")).ToString();
                string str3        = storage.Get("death_suicide").ToString();
                string str4        = storage.Get("hit_player_direct_los").ToString();
                string str5        = storage.Get("hit_player_indirect_los").ToString();
                string str6        = storage.Get("hit_building_direct_los").ToString();
                string str7        = storage.Get("hit_building_indirect_los").ToString();
                string str8        = storage.Get("hit_entity_direct_los").ToString();
                string str9        = storage.Get("hit_entity_indirect_los").ToString();
                table.AddRow(new string[9]
                {
                    id.ToString(),
                    name,
                    shortString,
                    str1,
                    str2,
                    str3,
                    str4 + " / " + str5,
                    str6 + " / " + str7,
                    str8 + " / " + str9
                });
            });
            ulong filterID = arg.GetUInt64(0, 0UL);

            if (filterID == 0UL)
            {
                string str1 = arg.GetString(0, "");
                foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
                {
                    try
                    {
                        if (activePlayer.IsValid())
                        {
                            string str2 = StringExtensions.QuoteSafe(activePlayer.GetSubName(32));
                            if (str1.Length > 0)
                            {
                                if (!StringEx.Contains(str2, str1, CompareOptions.IgnoreCase))
                                {
                                    continue;
                                }
                            }
                            action(activePlayer.userID, str2);
                        }
                    }
                    catch (Exception ex)
                    {
                        table.AddRow(new string[2]
                        {
                            activePlayer.UserIDString,
                            StringExtensions.QuoteSafe(ex.Message)
                        });
                    }
                }
            }
            else
            {
                string     str        = "N/A";
                BasePlayer basePlayer = BasePlayer.activePlayerList.Find((Predicate <BasePlayer>)(p => (long)p.userID == (long)filterID));
                if (Object.op_Implicit((Object)basePlayer))
                {
                    str = StringExtensions.QuoteSafe(basePlayer.GetSubName(32));
                }
                action(filterID, str);
            }
            arg.ReplyWith(((object)table).ToString());
        }
    public static Item CreateByPartialName(string strName, int iAmount = 1)
    {
        ItemDefinition itemDefinition = ItemManager.itemList.Find((Predicate <ItemDefinition>)(x => x.shortname == strName));

        if (Object.op_Equality((Object)itemDefinition, (Object)null))
        {
            itemDefinition = ItemManager.itemList.Find((Predicate <ItemDefinition>)(x => StringEx.Contains(x.shortname, strName, CompareOptions.IgnoreCase)));
        }
        if (Object.op_Equality((Object)itemDefinition, (Object)null))
        {
            return((Item)null);
        }
        return(ItemManager.CreateByItemID(itemDefinition.itemid, iAmount, 0UL));
    }
Beispiel #10
0
        public static string svspawnitem(string name, Vector3 pos)
        {
            if (string.IsNullOrEmpty(name))
            {
                return("No entity name provided");
            }
            string[] array = ItemManager.itemList.Select <ItemDefinition, string>((Func <ItemDefinition, string>)(x => x.shortname)).Where <string>((Func <string, bool>)(x => StringEx.Contains(x, name, CompareOptions.IgnoreCase))).ToArray <string>();
            if (array.Length == 0)
            {
                return("Entity type not found");
            }
            if (array.Length > 1)
            {
                string str = ((IEnumerable <string>)array).FirstOrDefault <string>((Func <string, bool>)(x => string.Compare(x, name, StringComparison.OrdinalIgnoreCase) == 0));
                if (str == null)
                {
                    return("Unknown entity - could be:\n\n" + string.Join("\n", array));
                }
                array[0] = str;
            }
            Item byName = ItemManager.CreateByName(array[0], 1, 0UL);

            if (byName == null)
            {
                return("Couldn't spawn " + name);
            }
            byName.CreateWorldObject(pos, (Quaternion)null, (BaseEntity)null, 0U);
            return("spawned " + (object)byName + " at " + (object)pos);
        }
Beispiel #11
0
        public static string svspawn(string name, Vector3 pos)
        {
            if (string.IsNullOrEmpty(name))
            {
                return("No entity name provided");
            }
            string[] array = ((IEnumerable <string>)GameManifest.Current.entities).Where <string>((Func <string, bool>)(x => StringEx.Contains(Path.GetFileNameWithoutExtension(x), name, CompareOptions.IgnoreCase))).Select <string, string>((Func <string, string>)(x => x.ToLower())).ToArray <string>();
            if (array.Length == 0)
            {
                return("Entity type not found");
            }
            if (array.Length > 1)
            {
                string str = ((IEnumerable <string>)array).FirstOrDefault <string>((Func <string, bool>)(x => string.Compare(Path.GetFileNameWithoutExtension(x), name, StringComparison.OrdinalIgnoreCase) == 0));
                if (str == null)
                {
                    return("Unknown entity - could be:\n\n" + string.Join("\n", ((IEnumerable <string>)array).Select <string, string>(new Func <string, string>(Path.GetFileNameWithoutExtension)).ToArray <string>()));
                }
                array[0] = str;
            }
            BaseEntity entity = GameManager.server.CreateEntity(array[0], pos, (Quaternion)null, true);

            if (Object.op_Equality((Object)entity, (Object)null))
            {
                return("Couldn't spawn " + name);
            }
            entity.Spawn();
            return("spawned " + (object)entity + " at " + (object)pos);
        }