Пример #1
0
        /// <summary>
        /// Called when all other extensions have been loaded
        /// </summary>
        public override void OnModLoad()
        {
            if (!Interface.Oxide.EnableConsole()) return;

            Application.RegisterLogCallback(HandleLog);
            Interface.Oxide.ServerConsole.Input += ServerConsoleOnInput;

            var commandLineParser = new CommandLineParser();
            var serverConfig = "serverConfig";
            if (commandLineParser.method_1("config"))
                serverConfig = commandLineParser.method_2("config");
            dedicatedServerConfiguration.method_0(serverConfig, AssetsCollection.instance);

            Interface.Oxide.ServerConsole.Title = () =>
            {
                var players = FpsMultiplayerGame.instance.playersList.method_5().Count;
                var hostname = dedicatedServerConfiguration.string_10;
                return string.Concat(players, " | ", hostname);
            };

            Interface.Oxide.ServerConsole.Status1Left = () =>
            {
                var hostname = dedicatedServerConfiguration.string_10;
                return string.Concat(" ", hostname);
            };
            Interface.Oxide.ServerConsole.Status1Right = () =>
            {
                var fps = Mathf.RoundToInt(1f / Time.smoothDeltaTime);
                var seconds = TimeSpan.FromSeconds(Time.realtimeSinceStartup);
                var uptime = $"{seconds.TotalHours:00}h{seconds.Minutes:00}m{seconds.Seconds:00}s".TrimStart(' ', 'd', 'h', 'm', 's', '0');
                return string.Concat(fps, "fps, ", uptime);
            };

            Interface.Oxide.ServerConsole.Status2Left = () =>
            {
                var players = FpsMultiplayerGame.instance.playersList.method_5().Count;
                var playerLimit = dedicatedServerConfiguration.int_1.ToString();
                return string.Concat(" ", players, "/", playerLimit, " players");
            };
            Interface.Oxide.ServerConsole.Status2Right = () =>
            {
                // TODO: Network in/out
                return "";
            };

            Interface.Oxide.ServerConsole.Status3Left = () =>
            {
                // TODO: Server game time, map name
                return "";
            };
            Interface.Oxide.ServerConsole.Status3Right = () =>
            {
                var gameVersion = Constants.smethod_0();
                var oxideVersion = OxideMod.Version.ToString();
                return string.Concat("Oxide ", oxideVersion, " for ", gameVersion);
            };
            Interface.Oxide.ServerConsole.Status3RightColor = ConsoleColor.Yellow;
        }