C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Facepunch;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("ZealModerations", "Kira", "1.0.5")]
// ReSharper disable once ClassNeverInstantiated.Global
public class ZealModerations : RustPlugin
{
#region [References] / [Ссылки]
[PluginReference] private Plugin ImageLibrary, ZealStatisticsReborn;
private static ZealModerations _;
#endregion
#region [Vars] / [Переменные]
private StoredData _dataBase = new StoredData();
private const string UILayerModeratorPanel = "UI_Layer_ModeratorPanel";
private const string UILayerPlayerList = "UI_Layer_ModeratorPanel_PlayerList";
private const string Sharp = "assets/content/ui/ui.background.tile.psd";
private const string Blur = "assets/content/ui/uibackgroundblur.mat";
private const string BlurInMenu = "assets/content/ui/uibackgroundblur-ingamemenu.mat";
private const string Radial = "assets/content/ui/ui.background.transparent.radial.psd";
private const string Regular = "robotocondensed-regular.ttf";
private const int MAXReports = 9;
#endregion
#region [Dictionaries | Lists] / [Словари | Списки]
private readonly Dictionary<BasePlayer, Check> _checks = new Dictionary<BasePlayer, Check>();
private static readonly Dictionary<string, Verdict> Verdicts = new Dictionary<string, Verdict>
{
["CHEATS"] = new Verdict
{
Name = "ЗАПРЕЩЁННОЕ ПО",
BanDays = 999
},
["PLAYING_WITH_CHEATER"] = new Verdict
{
Name = "ИГРА С ЧИТЕРОМ",
BanDays = 30
},
["REFUSAL_TO_CHECK"] = new Verdict
{
Name = "ОТКАЗ ОТ ПРОВЕРКИ",
BanDays = 30
},
["CLEAR"] = new Verdict
{
Name = "ИГРОК ЧИСТ",
BanDays = 0
}
};
private static readonly Dictionary<string, string> Menu = new Dictionary<string, string>
{
["CHECK"] = "assets/icons/bullet.png",
["FAVORITE"] = "assets/icons/sign.png"
};
#endregion
#region [Lang]
protected override void LoadDefaultMessages()
{
var ru = new Dictionary<string, string>
{
["CHECK_STATUS"] = "СОСТОЯНИЕ ПРОВЕРКИ",
["CHECK_DISCORD_REMAINING"] = "Вам осталось {0} с либо вам будет засчитан отказ от проверки",
["MODERATOR_DISCONNECTED"] = "Модератор отключился, у него осталось {0} для переподключения",
["VERIFIABLE_DISCONNECTED"] = "Проверяемый игрок отключился, у него осталось {0} для переподключения",
["CHECK_CALLED"] = "Вас вызвали на проверку",
["INPUT_DISCORD"] = "В данном поле введите пожалуйста ваш дискорд (NAME#ID)"
};
var en = new Dictionary<string, string>
{
["CHECK_STATUS"] = "CHECK STATUS",
["CHECK_DISCORD_REMAINING"] = "You have {0} left or you will be given a refusal to check",
["MODERATOR_DISCONNECTED"] = "The moderator disconnected, he still has {0} to reconnect",
["VERIFIABLE_DISCONNECTED"] = "The checked player disconnected, he has {0} left to reconnect",
["CHECK_CALLED"] = "You have been called for a check",
["INPUT_DISCORD"] = "In this field, please enter your discord (NAME#ID)"
};
lang.RegisterMessages(ru, this, "ru");
lang.RegisterMessages(en, this);
}
#endregion
#region [Classes] / [Классы]
private class Verdict
{
public string Name;
public int BanDays;
}
#endregion
#region [MonoBehaviours]
public class Check : MonoBehaviour
{
#region [Fields]
public BasePlayer moderator;
public BasePlayer verifiablePlayer;
public Verifiable verifiable;
public bool moderatorIsOnline = true;
public bool verifiableIsOnline = true;
public bool inputDiscord;
private bool _verdictisOpen;
private const string UILayerCheckInput = "UI_Layer_CheckInput";
private const string UILayerCheckStatus = "UI_Layer_CheckStatus";
private const string Online = "assets/icons/vote_up.png";
private const string Offline = "assets/icons/vote_down.png";
private const string Wait = "assets/icons/stopwatch.png";
public int timerDisconnectModerator = 300;
public int timerDisconnectVerifiable = 300;
public int timerInputRemaining = 300;
public int timer;
#endregion
#region [Initialization]
private void Awake()
{
moderator = GetComponent<BasePlayer>();
Initialization();
}
public void Initialization()
{
if (verifiablePlayer == null || moderator == null)
{
Invoke(nameof(Initialization), 0.1f);
return;
}
verifiable = verifiablePlayer.gameObject.AddComponent<Verifiable>();
verifiable.check = this;
verifiable.moderator = moderator;
DrawUI_CheckStatus(moderator);
InvokeRepeating(nameof(Timer), 1f, 1f);
}
public void StartCheck()
{
inputDiscord = true;
CuiHelper.DestroyUi(verifiablePlayer, UILayerCheckInput);
DrawUI_CheckStatus(moderator);
DrawUI_CheckStatus(verifiablePlayer);
}
#endregion
#region [UI]
public void DrawUI_CheckStatus(BasePlayer player)
{
var ui = new CuiElementContainer
{
{
new CuiPanel
{
Image =
{
Color = HexToRustFormat("#918E8E19"),
Material = Sharp
},
RectTransform =
{
AnchorMin = "0.3442701 0.1129631",
AnchorMax = "0.6411451 0.226852"
}
},
"Overlay", UILayerCheckStatus
},
{
new CuiLabel
{
Text =
{
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#918E8E"),
Text = _.lang.GetMessage("CHECK_STATUS", _, player.UserIDString),
FontSize = 14
},
RectTransform =
{
AnchorMin = "0 0.75",
AnchorMax = "1 1"
}
},
UILayerCheckStatus
},
new CuiElement
{
Name = $"{UILayerCheckStatus}_ModeratorIC",
Parent = UILayerCheckStatus,
Components =
{
new CuiRawImageComponent
{
Png = (string) _.ImageLibrary.Call("GetImage", moderator.UserIDString),
Color = "1 1 1 0.7"
},
new CuiRectTransformComponent
{
AnchorMin = "0.3245648 0.2488146",
AnchorMax = "0.4122826 0.6553186"
}
}
},
new CuiElement
{
Name = $"{UILayerCheckStatus}_PlayerIC",
Parent = UILayerCheckStatus,
Components =
{
new CuiRawImageComponent
{
Png = (string) _.ImageLibrary.Call("GetImage",
verifiablePlayer.UserIDString),
Color = "1 1 1 0.7"
},
new CuiRectTransformComponent
{
AnchorMin = "0.5912311 0.2488146", AnchorMax = "0.6789504 0.6553186"
}
}
},
new CuiElement
{
Name = $"{UILayerCheckStatus}_StatusModerator",
Parent = $"{UILayerCheckStatus}_ModeratorIC",
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat(moderatorIsOnline ? "#59B65E" : "#B65959"),
Sprite = moderatorIsOnline ? Online : Offline
},
new CuiRectTransformComponent {AnchorMin = "0.2 0.2", AnchorMax = "0.8 0.8"},
new CuiOutlineComponent {Color = HexToRustFormat("#0000005D"), Distance = "1 1"}
}
},
{
new CuiButton
{
Button =
{
Command = "zmoderation.verdict",
Color = HexToRustFormat("#918E8EFF"),
Sprite = "assets/icons/examine.png"
},
Text = {Text = " "},
RectTransform = {AnchorMin = "0.4789498 0.3089416", AnchorMax = "0.5421077 0.6016245"}
},
UILayerCheckStatus, $"{UILayerCheckStatus}_StatusIC"
}
};
var icPlayer = Wait;
var colorPlayer = "#B65959";
if (inputDiscord)
{
icPlayer = verifiableIsOnline ? Online : Offline;
colorPlayer = verifiableIsOnline ? "#59B65E" : "#B65959";
}
ui.Add(new CuiElement
{
Name = $"{UILayerCheckStatus}_StatusPlayer",
Parent = $"{UILayerCheckStatus}_PlayerIC",
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat(colorPlayer),
Sprite = icPlayer
},
new CuiRectTransformComponent
{
AnchorMin = "0.2 0.2",
AnchorMax = "0.8 0.8"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000005D"),
Distance = "1 1"
}
}
});
CuiHelper.DestroyUi(player, UILayerCheckStatus);
CuiHelper.AddUi(player, ui);
DrawUI_Timer(player);
}
public void DrawUI_Timer(BasePlayer player)
{
if (player == null) return;
var ui = new CuiElementContainer();
var parseTime = TimeSpan.FromSeconds(timer);
ui.Add(new CuiLabel
{
Text =
{
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#918E8E"),
Text = $"{parseTime.Hours} h {parseTime.Minutes} m {parseTime.Seconds} s",
FontSize = 11
},
RectTransform =
{
AnchorMin = "0.3245648 0.05691048",
AnchorMax = "0.6771959 0.2195109"
}
}, UILayerCheckStatus, $"{UILayerCheckStatus}_Timer");
CuiHelper.DestroyUi(player, $"{UILayerCheckStatus}_Timer");
CuiHelper.AddUi(player, ui);
}
public void DrawUI_Verdict()
{
var ui = new CuiElementContainer();
if (_verdictisOpen)
{
foreach (var verdict in Verdicts)
CuiHelper.DestroyUi(moderator, $"{UILayerCheckStatus}_{verdict.Key}");
_verdictisOpen = false;
return;
}
_verdictisOpen = true;
var y = 0;
foreach (var verdict in Verdicts)
{
ui.Add(new CuiButton
{
Button =
{
Command = $"zmoderation.verdict {verdict.Key}",
Color = HexToRustFormat("#918E8E19"),
Material = Sharp
},
Text =
{
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#918E8E"),
Text = $"{verdict.Value.Name}",
FontSize = 14
},
RectTransform =
{
AnchorMin = $"0 {1.040649 + (y * 0.35)}",
AnchorMax = $"1 {1.333331 + (y * 0.35)}"
}
}, UILayerCheckStatus, $"{UILayerCheckStatus}_{verdict}");
y++;
}
CuiHelper.AddUi(moderator, ui);
}
public void DrawUI_VerifiableDisconnected()
{
if (moderator == null) return;
var ui = new CuiElementContainer();
var parseTime = TimeSpan.FromSeconds(timerDisconnectVerifiable);
ui.Add(new CuiElement
{
Name = $"{UILayerCheckStatus}_VerifiableDisconnect",
Parent = UILayerCheckStatus,
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#FF000053"),
Material = Sharp
},
new CuiRectTransformComponent
{
AnchorMin = "0 1.04",
AnchorMax = "0.998 1.29"
}
}
});
ui.Add(new CuiLabel
{
Text =
{
Align = TextAnchor.MiddleCenter,
Color = "1 1 1 0.5",
Text = _.lang.GetMessage("VERIFIABLE_DISCONNECTED", _, moderator.UserIDString).Replace("{0}", $"{parseTime.Minutes} m {parseTime.Seconds} s"),
FontSize = 11
},
RectTransform =
{
AnchorMin = "0 0",
AnchorMax = "1 1"
}
}, $"{UILayerCheckStatus}_VerifiableDisconnect", $"{UILayerCheckStatus}_TimerDisconnectVerifiable");
CuiHelper.DestroyUi(moderator, $"{UILayerCheckStatus}_VerifiableDisconnect");
CuiHelper.AddUi(moderator, ui);
}
#endregion
#region [Logic]
public void Timer()
{
timer++;
if (timerInputRemaining <= 0) Destroy(this);
if (!inputDiscord & verifiableIsOnline)
{
timerInputRemaining--;
verifiable.DrawUI_TimerInput();
}
if (!verifiableIsOnline)
{
if (BasePlayer.activePlayerList.Contains(verifiablePlayer))
{
OnVerifiableConnected();
return;
}
timerDisconnectVerifiable--;
if (timerDisconnectVerifiable <= 0) Destroy(this);
DrawUI_VerifiableDisconnected();
}
if (!moderatorIsOnline)
{
if (BasePlayer.activePlayerList.Contains(moderator))
{
OnModeratorConnected();
return;
}
timerDisconnectModerator--;
if (timerDisconnectModerator <= 0) Destroy(this);
verifiable.DrawUI_ModeratorDisconnected();
}
if (moderatorIsOnline)
DrawUI_Timer(moderator);
if (verifiableIsOnline & inputDiscord)
DrawUI_Timer(verifiablePlayer);
}
#endregion
#region [Iternal Hooks]
public void OnVerdictConfirm(string verdict)
{
if (!Verdicts.ContainsKey(verdict)) return;
var verdictDB = Verdicts[verdict];
moderator.ChatMessage($"Проверка окончена\nВы вынесли вердикт {verdict}");
verifiablePlayer.ChatMessage($"Проверка окончена\nВам вынесли вердикт {verdict}");
_.CheckInDataBaseModerators(moderator.userID);
_.CheckInDataBaseReports(verifiablePlayer.userID);
var database = _._dataBase;
var checkOutput = new StoredData.Checks();
var stat = new StoredData.Checks.Statistic
{
Kills = (int) _.ZealStatisticsReborn.Call("GetKillsPlayer", verifiablePlayer.userID),
Deaths = (int) _.ZealStatisticsReborn.Call("GetDeathsPlayer", verifiablePlayer.userID),
Time = (float) _.ZealStatisticsReborn.Call("GetPlayingTimePlayer", verifiablePlayer.userID),
Reports = database.Reports[verifiablePlayer.userID].Reports.Count
};
checkOutput.Time = DateTime.Now;
checkOutput.CheckDuration = timer;
checkOutput.Verifiable = verifiablePlayer.userID;
checkOutput.Verifier = moderator.userID;
checkOutput.VerifierName = moderator.displayName;
checkOutput.VerifiableName = verifiablePlayer.displayName;
checkOutput.Stat = stat;
checkOutput.Result = verdict;
if (Verdicts[verdict].BanDays > 0)
{
ServerUsers.Set(verifiablePlayer.userID, ServerUsers.UserGroup.Banned, verifiablePlayer.displayName,
$"{verdictDB.Name}");
ServerUsers.Save();
verifiablePlayer.Kick($"{verdictDB.Name}");
}
database.ModeratorChecks[moderator.userID].ChecksDB.Add(checkOutput);
database.ModeratorChecks[moderator.userID].ChecksCount++;
database.Reports[verifiablePlayer.userID].ChecksDB.Add(checkOutput);
database.Reports[verifiablePlayer.userID].Reports.Clear();
Destroy(this);
}
public void OnModeratorDisconnected()
{
moderatorIsOnline = false;
timerDisconnectModerator = 200;
DrawUI_CheckStatus(verifiablePlayer);
}
public void OnModeratorConnected()
{
timerDisconnectModerator = 200;
moderatorIsOnline = true;
DrawUI_CheckStatus(moderator);
DrawUI_CheckStatus(verifiablePlayer);
}
public void OnVerifiableDisconnected()
{
Destroy(verifiable);
verifiableIsOnline = false;
timerDisconnectVerifiable = 200;
DrawUI_CheckStatus(moderator);
}
public void OnVerifiableConnected()
{
verifiable = verifiablePlayer.gameObject.AddComponent<Verifiable>();
verifiable.check = this;
verifiable.moderator = moderator;
timerDisconnectVerifiable = 200;
verifiableIsOnline = true;
if (inputDiscord) DrawUI_CheckStatus(moderator);
else verifiable.DrawUI_CheckInput();
}
private void OnDestroy()
{
_._checks.Remove(moderator);
Destroy(verifiable);
CuiHelper.DestroyUi(moderator, UILayerCheckStatus);
}
#endregion
public class Verifiable : MonoBehaviour
{
#region [Fields]
private BasePlayer _verifiablePlayer;
public BasePlayer moderator;
public Check check;
#endregion
#region [Initialization]
private void Awake()
{
_verifiablePlayer = GetComponent<BasePlayer>();
Initialization();
}
public void Initialization()
{
if (_verifiablePlayer == null || moderator == null)
{
Invoke(nameof(Initialization), 0.1f);
return;
}
if (!check.inputDiscord)
{
DrawUI_CheckInput();
DrawUI_TimerInput();
}
else check.DrawUI_CheckStatus(_verifiablePlayer);
}
#endregion
#region [UI]
public void DrawUI_CheckInput()
{
var ui = new CuiElementContainer
{
{
new CuiPanel
{
Image = {Color = HexToRustFormat("#918E8E19"), Material = Sharp},
RectTransform =
{
AnchorMin = "0.3442701 0.1129631", AnchorMax = "0.6411451 0.226852"
}
},
"Overlay", UILayerCheckInput
},
{
new CuiLabel
{
Text =
{
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#918E8E"),
Text = _.lang.GetMessage("CHECK_CALLED", _, _verifiablePlayer.UserIDString),
FontSize = 14
},
RectTransform = {AnchorMin = "0 0.75", AnchorMax = "1 1"}
},
UILayerCheckInput
},
{
new CuiLabel
{
Text =
{
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#918E8E7B"),
Text = _.lang.GetMessage("INPUT_DISCORD", _, _verifiablePlayer.UserIDString),
FontSize = 11
},
RectTransform = {AnchorMin = "0 0", AnchorMax = "1 0.3414623"}
},
UILayerCheckInput
},
{
new CuiPanel
{
Image = {Color = HexToRustFormat("#918E8E16"), Material = Sharp},
RectTransform =
{
AnchorMin = "0.3315814 0.3658522", AnchorMax = "0.6701779 0.6585351"
}
},
UILayerCheckInput, $"{UILayerCheckInput}_InputBG"
},
new CuiElement
{
Name = $"{UILayerCheckInput}_InputElem",
Parent = $"{UILayerCheckInput}_InputBG",
Components =
{
new CuiInputFieldComponent
{
Align = TextAnchor.MiddleCenter,
CharsLimit = 50,
Command = "zmoderation.input ",
Font = Regular,
FontSize = 11
},
new CuiRectTransformComponent {AnchorMin = "0 0", AnchorMax = "1 1"}
}
}
};
CuiHelper.DestroyUi(_verifiablePlayer, UILayerCheckInput);
CuiHelper.AddUi(_verifiablePlayer, ui);
DrawUI_TimerInput();
}
public void DrawUI_TimerInput()
{
var ui = new CuiElementContainer();
var parseTime = TimeSpan.FromSeconds(check.timerInputRemaining);
ui.Add(new CuiElement
{
Name = $"{UILayerCheckInput}_InputRemaining",
Parent = UILayerCheckInput,
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#FF000053"),
Material = Sharp
},
new CuiRectTransformComponent
{
AnchorMin = "0 1.04065",
AnchorMax = "0.998 1.292681"
}
}
});
ui.Add(new CuiLabel
{
Text =
{
Align = TextAnchor.MiddleCenter,
Color = "1 1 1 0.5",
Text = _.lang.GetMessage("CHECK_DISCORD_REMAINING", _, _verifiablePlayer.UserIDString).Replace("{0}", $"{parseTime.Minutes} m {parseTime.Seconds} s"),
FontSize = 10
},
RectTransform =
{
AnchorMin = "0 0",
AnchorMax = "1 1"
}
}, $"{UILayerCheckInput}_InputRemaining");
CuiHelper.DestroyUi(_verifiablePlayer, $"{UILayerCheckInput}_InputRemaining");
CuiHelper.AddUi(_verifiablePlayer, ui);
}
public void DrawUI_ModeratorDisconnected()
{
if (_verifiablePlayer == null) return;
var ui = new CuiElementContainer();
var parseTime = TimeSpan.FromSeconds(check.timerDisconnectModerator);
ui.Add(new CuiElement
{
Name = $"{UILayerCheckStatus}_ModeratorDisconnect",
Parent = UILayerCheckStatus,
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#FF000053"),
Material = Sharp
},
new CuiRectTransformComponent
{
AnchorMin = "0 1.04065",
AnchorMax = "0.998 1.292681"
}
}
});
ui.Add(new CuiLabel
{
Text =
{
Align = TextAnchor.MiddleCenter,
Color = "1 1 1 0.5",
Text = _.lang.GetMessage("MODERATOR_DISCONNECTED", _, _verifiablePlayer.UserIDString).Replace("{0}", $"{parseTime.Minutes} m {parseTime.Seconds} s"),
FontSize = 11
},
RectTransform =
{
AnchorMin = "0 0",
AnchorMax = "1 1"
}
}, $"{UILayerCheckStatus}_ModeratorDisconnect", $"{UILayerCheckStatus}_TimerDisconnectModerator");
CuiHelper.DestroyUi(_verifiablePlayer, $"{UILayerCheckStatus}_ModeratorDisconnect");
CuiHelper.AddUi(_verifiablePlayer, ui);
}
#endregion
#region [Iternal Hooks]
public void OnInputField(string input)
{
if (input == null) return;
const string message = "Введён некорректный дискорд, повторите попытку";
if (!input.Contains("#"))
{
_verifiablePlayer.ChatMessage(message);
return;
}
if (input.Split('#')[1].Length != 4)
{
_verifiablePlayer.ChatMessage(message);
return;
}
moderator.ChatMessage($"Дискорд проверяемого : {input}");
check.StartCheck();
}
private void OnDestroy()
{
CuiHelper.DestroyUi(_verifiablePlayer, UILayerCheckStatus);
CuiHelper.DestroyUi(_verifiablePlayer, UILayerCheckInput);
}
#endregion
}
}
#endregion
#region [DrawUI] / [Отрисовка UI]
private void DrawUI_ModeratorPanel(BasePlayer player)
{
var ui = new CuiElementContainer();
const float fadeIn = 0.3f;
ui.Add(new CuiPanel
{
CursorEnabled = true,
Image =
{
Color = HexToRustFormat("#000000B2"),
Material = Blur
},
RectTransform =
{
AnchorMin = "0 0",
AnchorMax = "1 1"
}
}, "Overlay", UILayerModeratorPanel);
ui.Add(new CuiElement
{
Name = $"{UILayerModeratorPanel}_PanelName",
Parent = UILayerModeratorPanel,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#EAEAEAFF"),
FontSize = 20,
Text = "СПИСОК ИГРОКОВ"
},
new CuiRectTransformComponent
{
AnchorMin = "0.1651042 0.9213709",
AnchorMax = "1 1"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000004C"),
Distance = "0.9 0.9"
}
}
});
#region [Profile]
var layerProfile = $"{UILayerModeratorPanel}_Profile";
ui.Add(new CuiPanel
{
Image =
{
Color = HexToRustFormat("#000000AA"),
Material = Blur,
Sprite = Radial,
FadeIn = fadeIn
},
RectTransform =
{
AnchorMin = "0 0",
AnchorMax = "0.1651042 1"
}
}, UILayerModeratorPanel, layerProfile);
ui.Add(new CuiPanel
{
Image =
{
Color = HexToRustFormat("#8EBF5B77"),
Material = Sharp,
FadeIn = fadeIn
},
RectTransform =
{
AnchorMin = ".999 0",
AnchorMax = "1 1"
}
}, layerProfile);
ui.Add(new CuiElement
{
Name = $"{layerProfile}_PanelName",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#EAEAEAFF"),
FontSize = 15,
Text = "ПАНЕЛЬ МОДЕРАТОРА",
FadeIn = fadeIn
},
new CuiRectTransformComponent
{
AnchorMin = "0 0.94",
AnchorMax = "1 1"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000004C"),
Distance = "0.9 0.9"
}
}
});
ui.Add(new CuiElement
{
Name = $"{layerProfile}_Avatar",
Parent = layerProfile,
Components =
{
new CuiRawImageComponent
{
Png = (string) ImageLibrary.Call("GetImage", player.UserIDString),
FadeIn = fadeIn
},
new CuiRectTransformComponent
{
AnchorMin = "0.2618299 0.8092595",
AnchorMax = "0.7350159 0.9481484"
}
}
});
ui.Add(new CuiElement
{
Name = $"{layerProfile}_Nick",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleCenter,
Font = Regular,
FontSize = 15,
Text = player.displayName,
FadeIn = fadeIn
},
new CuiRectTransformComponent
{
AnchorMin = "0 0.7629628",
AnchorMax = "1 0.7953702"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000004C"),
Distance = "0.9 0.9"
}
}
});
#region [Statistic]
var moderatorDB = _dataBase.ModeratorChecks[player.userID];
ui.Add(new CuiElement
{
Name = $"{layerProfile}_ChecksCountIC",
Parent = layerProfile,
Components =
{
new CuiImageComponent
{
Sprite = "assets/icons/examine.png",
Color = HexToRustFormat("#EAEAEAFF"),
FadeIn = fadeIn
},
new CuiRectTransformComponent
{
AnchorMin = "0.1230283 0.6962962",
AnchorMax = "0.2334382 0.7287036"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000004C"),
Distance = "0.9 0.9"
}
}
});
ui.Add(new CuiElement
{
Name = $"{layerProfile}_ChecksCount",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
FontSize = 15,
Text = $"{moderatorDB.ChecksCount}",
FadeIn = fadeIn
},
new CuiRectTransformComponent
{
AnchorMin = "0.2649842 0.6962962",
AnchorMax = "0.4384854 0.7287036"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000004C"),
Distance = "0.9 0.9"
}
}
});
ui.Add(new CuiElement
{
Name = $"{layerProfile}_ChecksTimeIC",
Parent = layerProfile,
Components =
{
new CuiImageComponent
{
Sprite = "assets/icons/stopwatch.png",
Color = HexToRustFormat("#EAEAEAFF"),
FadeIn = fadeIn
},
new CuiRectTransformComponent
{
AnchorMin = "0.1041008 0.6490754",
AnchorMax = "0.2145106 0.6814828"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000004C"),
Distance = "0.9 0.9"
}
}
});
ui.Add(new CuiElement
{
Name = $"{layerProfile}_ChecksTimeValue",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
FontSize = 15,
Text = "NULL",
FadeIn = fadeIn
},
new CuiRectTransformComponent
{
AnchorMin = "0.2649842 0.6490754",
AnchorMax = "0.4384856 0.6814828"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000004C"),
Distance = "0.9 0.9"
}
}
});
ui.Add(new CuiElement
{
Name = $"{layerProfile}_ChecksSuccessIC",
Parent = layerProfile,
Components =
{
new CuiImageComponent
{
Sprite = "assets/icons/target.png",
Color = HexToRustFormat("#EAEAEAFF"),
FadeIn = fadeIn
},
new CuiRectTransformComponent
{
AnchorMin = "0.5741327 0.698148",
AnchorMax = "0.6687698 0.7259258"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000004C"),
Distance = "0.9 0.9"
}
}
});
ui.Add(new CuiElement
{
Name = $"{layerProfile}_ChecksSuccessValue",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
FontSize = 15,
Text = "NULL",
FadeIn = fadeIn
},
new CuiRectTransformComponent
{
AnchorMin = "0.735016 0.6962962",
AnchorMax = "0.9085176 0.7287036"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000004C"),
Distance = "0.9 0.9"
}
}
});
ui.Add(new CuiElement
{
Name = $"{layerProfile}_RatingIC",
Parent = layerProfile,
Components =
{
new CuiImageComponent
{
Sprite = "assets/icons/study.png",
Color = HexToRustFormat("#EAEAEAFF"),
FadeIn = fadeIn
},
new CuiRectTransformComponent
{
AnchorMin = "0.5741327 0.6500013",
AnchorMax = "0.6750785 0.6796309"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000004C"),
Distance = "0.9 0.9"
}
}
});
ui.Add(new CuiElement
{
Name = $"{layerProfile}_RatingValue",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
FontSize = 15,
Text = "NULL",
FadeIn = fadeIn
},
new CuiRectTransformComponent
{
AnchorMin = "0.735016 0.6490754",
AnchorMax = "0.9085176 0.6814828"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#0000004C"),
Distance = "0.9 0.9"
}
}
});
#endregion
#endregion
CuiHelper.DestroyUi(player, UILayerModeratorPanel);
CuiHelper.AddUi(player, ui);
DrawUI_PlayerList(player, 0, GetSortedReports());
DrawUI_InputFind(player);
}
private void DrawUI_PlayerList(BasePlayer player, int page,
IEnumerable<KeyValuePair<ulong, StoredData.PObj>> players)
{
var ui = new CuiElementContainer();
var uiButtons = new CuiElementContainer();
const float fadeIn = 0.1f;
ui.Add(new CuiPanel
{
Image =
{
Color = "0 0 0 0"
},
RectTransform =
{
AnchorMin = "0.1651042 0",
AnchorMax = "1 0.9213709"
}
}, UILayerModeratorPanel, UILayerPlayerList);
ui.Add(new CuiButton
{
Button =
{
Close = UILayerModeratorPanel,
Color = "0 0 0 0"
},
Text =
{
Text = " "
},
RectTransform =
{
AnchorMin = "0 0",
AnchorMax = "1 1"
}
}, UILayerPlayerList);
int x = 0, y = 0, i = 0;
foreach (var index in players.Skip(page * 28).Take(28))
{
var plobj = BasePlayer.FindByID(index.Key);
var isOnline = plobj == null;
if (x >= 4)
{
y++;
x = 0;
}
var element = $"{UILayerModeratorPanel}_PlayerList_Elem{i}";
ui.Add(new CuiElement
{
Name = element,
Parent = UILayerPlayerList,
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#00000051"),
FadeIn = fadeIn + (i * fadeIn)
},
new CuiRectTransformComponent
{
AnchorMin = $"{0.011 + (x * 0.245)} {0.88 - (y * 0.128)}",
AnchorMax = $"{0.25 + (x * 0.245)} {0.998 - (y * 0.128)}"
}
}
});
ui.Add(new CuiElement
{
Name = $"{element}_Avatar",
Parent = element,
Components =
{
new CuiRawImageComponent
{
Png = (string) ImageLibrary.Call("GetImage", $"{index.Key}"),
FadeIn = fadeIn + (i * fadeIn)
},
new CuiRectTransformComponent
{
AnchorMin = "0.001 0.004",
AnchorMax = "0.305 0.98"
}
}
});
ui.Add(new CuiElement
{
Name = $"{element}_userid",
Parent = $"{element}_Avatar",
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleCenter,
FontSize = 8,
Text = $"{index.Key}",
FadeIn = fadeIn + (i * fadeIn)
},
new CuiRectTransformComponent
{
AnchorMin = "0
// ... [Code preview truncated due to length. Full source in attached file] ...