Иконка ресурса

FREE Restart : 1.0.0 1.0.0

Нет прав для скачивания
C#:
using System;
using System.Collections;
using System.Linq;
using Newtonsoft.Json;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Restart", "Ryamkk", "1.0.0")] 
    class Restart : RustPlugin
    {
        public Coroutine Process = null;

        [ConsoleCommand("restarts")]
        void checkOxideCommits(ConsoleSystem.Arg arg)
        {
            if(arg.Connection != null && arg.Connection.authLevel < 2) return;
            Process = ServerMgr.Instance.StartCoroutine(ServerRestartWarning(arg.Args[0], 600));
        }
        
        void Unload()
        {
            if (Process != null) ServerMgr.Instance.StopCoroutine(Process);
        }

        private IEnumerator ServerRestartWarning(string info, int iSeconds)
        {
            if (iSeconds < 0) yield break;
            
            if (!string.IsNullOrEmpty(info))
            {
                ConsoleNetwork.BroadcastToAllClients("chat.add", new object[] { 2, 0, "<color=#fff>SERVER</color> Restarting: " + info });
                PrintWarning("<color=#fff>SERVER</color> Restarting: " + info);
            }
            
            int j;
            for (int i = iSeconds; i > 0; i = j - 1)
            {
                if (i == iSeconds || i % 60 == 0 || (i < 300 && i % 30 == 0) || (i < 60 && i % 10 == 0) || i < 10)
                {
                    ConsoleNetwork.BroadcastToAllClients("chat.add", new object[] { 2, 0,  string.Format("<color=#fff>SERVER</color> Restarting in {0} seconds ({1})!", i, info) });
                    Debug.Log(string.Format("Restarting in {0} seconds", i));
                    PrintWarning("<color=#fff>SERVER</color> Restarting in {0} seconds ({1})!", i, info);
                }
                
                yield return new WaitForSeconds(1f);
                j = i;
            }
            
            ConsoleNetwork.BroadcastToAllClients("chat.add", new object[] { 2, 0, "<color=#fff>SERVER</color> Restarting (" + info + ")" });
            PrintWarning("<color=#fff>SERVER</color> Restarting (" + info + ")");
            yield return new WaitForSeconds(2f);
            
            BasePlayer[] array = BasePlayer.activePlayerList.ToArray<BasePlayer>();
            for (j = 0; j < array.Length; j++) { array[j].Kick("Сервер перезагружается!"); }
            yield return new WaitForSeconds(1f);
        }
    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок

Другие ресурсы пользователя 15FPS

Сверху