C#:
using System;
using Newtonsoft.Json;
namespace Oxide.Plugins
{
[Info("Connector", "walkinrey", "1.0.0")]
class Connector : RustPlugin
{
#region Конфиг
Configuration config = new Configuration();
class Configuration
{
[JsonProperty(PropertyName = "Steam ID 64 игроков, которых можно пропустить на сервер")]
public string[] steamIDs = {};
[JsonProperty(PropertyName = "Разрешать вход на сервер игрокам которые добавлены в ownerid сервера?")]
public bool ownersConnect = true;
[JsonProperty(PropertyName = "Закрывать доступ к серверу после вайпа?")]
public bool blockAfterWipe = true;
[JsonProperty(PropertyName = "Сообщение при кике с сервера")]
public string message = "Сервер временно закрыт. Вход будет открыт в ближайшее время!";
[JsonProperty(PropertyName = "Во сколько открыть сервер? (Формат: 01 December 2020 19:30:50)")]
public string date = "01 December 2020 19:30:50";
[JsonProperty(PropertyName = "Сейчас вход (true - не разрешен, false - разрешен)")]
public bool serverActive = false;
}
void LoadConfig()
{
base.LoadConfig();
try
{
config = Config.ReadObject<Configuration>();
}
catch
{
LoadDefaultConfig();
}
SaveConfig();
}
void SaveConfig()
{
Config.WriteObject(config);
}
protected override void LoadDefaultConfig()
{
config = new Configuration();
}
#endregion
#region Хуки
void OnNewSave(string filename)
{
if(config.blockAfterWipe == true) config.serverActive = true;
SaveConfig();
}
void OnPlayerConnected(BasePlayer player)
{
if(config.serverActive == false) return;
else
{
if(CheckIsExpired(Convert.ToDateTime(config.date)) == false) {player.Kick(config.message);}
else {config.serverActive = false; SaveConfig();}
}
if(!config.steamIDs.Contains(player.userID.ToString()))
{
if(config.ownersConnect == true && player.IsAdmin) return;
player.Kick(config.message);
}
}
void OnServerInitialized() => LoadConfig();
#endregion
#region Вспомогательные методы
bool CheckIsExpired(DateTime date)
{
if(date < DateTime.Now) {return true;}
else {return false;}
return false;
}
#endregion
}
}