C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using Newtonsoft.Json;
using System.Linq;
using Oxide.Core.Libraries.Covalence;
using System;
using UnityEngine;
using Oxide.Game.Rust.Cui;
using ConVar;
using System.Collections.Generic;
using Oxide.Core;
using Oxide.Core.Plugins;
namespace Oxide.Plugins {
[Info("XPrison", "Monster", "1.0.4")]
class XPrison : RustPlugin {
[ConsoleCommand("zona_c")]
private void ccmdCategory(ConsoleSystem.Arg args) {
BasePlayer player = args.Player();
if(player != null && (player.IsAdmin || permission.UserHasPermission(player.UserIDString, "xprison.admin"))) {
if(Cooldowns.ContainsKey(player)) if(Cooldowns[player].Subtract(DateTime.Now).TotalSeconds >= 0) return;
Effect x = new Effect("assets/bundled/prefabs/fx/notice/loot.drag.grab.fx.prefab", player, 0, new Vector3(), new Vector3());
switch(args.Args[0]) {
case "category" : {
int page = Convert.ToInt32(args.Args[2]);
CuiHelper.DestroyUi(player, ".GUI_ADD");
CuiHelper.DestroyUi(player, ".GUI_REMOVE");
CuiHelper.DestroyUi(player, ".ZONA_ONLINE");
CuiHelper.DestroyUi(player, ".ZONA_OFFLINE");
CuiHelper.DestroyUi(player, ".ZONA_PRISONER");
switch(args.Args[1]) {
case "online" : {
CategoryGUI(player, page);
OnlineGUI(player);
break;
}
case "offline" : {
CategoryGUI(player, page);
OfflineGUI(player);
break;
}
case "prisoner" : {
CategoryGUI(player, page);
PrisonerGUI(player);
break;
}
}
break;
}
case "prisoner" : {
ulong steamID = Convert.ToUInt64(args.Args[2]);
switch(args.Args[1]) {
case "add" : {
_adminsPrisonerCreate[player.userID] = new PrisonerCreate {
SteamID = steamID, Life = false, Duration = 3600, Sentence = false, Reason = "Text reason"
}
;
AddPrisonerGUI(player);
break;
}
case "remove" : {
RemovePrisonerGUI(player, steamID);
break;
}
}
break;
}
case "prisoner_A" : {
switch(args.Args[1]) {
case "add" : {
string arg = args.GetString(2);
if(_adminsPrisonerCreate.ContainsKey(player.userID)) {
switch(arg) {
case "steamID" : {
ulong.TryParse(args.GetString(3), out ulong steamID);
_adminsPrisonerCreate[player.userID].SteamID = steamID;
break;
}
case "life" : {
_adminsPrisonerCreate[player.userID].Life = args.GetBool(3);
break;
}
case "duration" : {
_adminsPrisonerCreate[player.userID].Duration = args.GetInt(3);
break;
}
case "sentence" : {
_adminsPrisonerCreate[player.userID].Sentence = args.GetBool(3);
break;
}
case "reason" : {
_adminsPrisonerCreate[player.userID].Reason = string.Join(" ", args.Args.Skip(3));
break;
}
}
PrisonerCreate create = _adminsPrisonerCreate[player.userID];
AddPrisonerGUI(player);
}
break;
}
case "remove" : {
ulong steamID = 0;
foreach(string arg in args.Args) if(arg.StartsWith("STEAMID:")) if(arg == "STEAMID:") ulong.TryParse(args.Args.Last(), out steamID);
else ulong.TryParse(arg.Replace("STEAMID:", ""), out steamID);
RemovePrisonerGUI(player, steamID);
break;
}
}
break;
}
}
EffectNetwork.Send(x, player.Connection);
Cooldowns[player] = DateTime.Now.AddSeconds(0.3f);
}
}
private object OnPlayerRespawn(BasePlayer player) {
if(API_IsOnlinePrisoner(player.userID)) {
NextTick(() => GiveAttire(player));
if(_spawnpoints.Count == 0) {
PrintWarning(LanguageEnglish ? $"No spawn points found! Prisoner [ {player} ] be out!" : $"Не найдено точек для спавна! Заключенный [ {player} ] на свободе!");
return null;
}
return new BasePlayer.SpawnPoint {
pos = _spawnpoints.GetRandom()
}
;
}
else return null;
}
private object OnPlayerCommand(BasePlayer player, string command, string[] args) {
if(player.IsAdmin || permission.UserHasPermission(player.UserIDString, "xprison.admin")) return null;
if(!config.Setting.ChatCommand.Contains(command) && API_IsOnlinePrisoner(player.userID)) {
Player.Reply(player, $"[ <color=#b9de0f>ZONA</color> ] - {lang.GetMessage("CMD_BLOCK", this, player.UserIDString)}", config.Setting.SteamID);
return true;
}
return null;
}
private void SaveData(BasePlayer player) => Interface.Oxide.DataFileSystem.WriteObject($"XDataSystem/XPrison/{player.userID}", StoredData[player.userID]);
[ChatCommand("zona")]
private void cmdInfoZona(BasePlayer player) {
if(StoredData.ContainsKey(player.userID)) {
var data = StoredData[player.userID];
if(data.Life) Player.Reply(player, lang.GetMessage("TERM_FORLIFE_INFO", this, player.UserIDString), config.Setting.SteamID);
else {
TimeSpan time = TimeSpan.FromSeconds(data.Sentence ? data.Time : data.Time - GetUnixTime());
Player.Reply(player, string.Format(lang.GetMessage("TERM_DURATION_INFO", this, player.UserIDString), time.Days, time.Hours, time.Minutes, time.Seconds), config.Setting.SteamID);
}
}
else Player.Reply(player, lang.GetMessage("NOT_PRISONER_INFO", this, player.UserIDString), config.Setting.SteamID);
}
private class Prisoner {
[JsonProperty(LanguageEnglish ? "Prefix in chat" : "Префикс в чате")]
public string PrefixChat;
[JsonProperty(LanguageEnglish ? "For life" : "Пожизненно")]
public bool Life;
[JsonProperty(LanguageEnglish ? "Prisoner" : "Заключенный")]
public bool IsPrisoner;
[JsonProperty(LanguageEnglish ? "Release date" : "Дата освобождения")]
public int Time;
[JsonProperty(LanguageEnglish ? "Serving the sentence - [ True - online | False - by date ]" : "Отбывание наказания - [ True - в онлайне | False - по дату ]")]
public bool Sentence;
[JsonProperty(LanguageEnglish ? "Reason" : "Причина")]
public string Reason;
public Prisoner(string prefixchat, bool life, bool isprisoner, int time, bool sentence, string reason) {
PrefixChat = prefixchat;
Life = life;
IsPrisoner = isprisoner;
Time = time;
Sentence = sentence;
Reason = reason;
}
}
protected override void LoadDefaultConfig() => config = PrisonConfig.GetNewConfiguration();
private void API_RemoveOnlinePrisoner(BasePlayer prisoner) {
if(!API_IsOnlinePrisoner(prisoner.userID)) {
PrintWarning(LanguageEnglish ? $"[ {prisoner} ] - is not a prisoner!" : $"[ {prisoner} ] - не является заключенным!");
return;
}
if(config.Prisoner.TpOfPrison) NextTick(() => {
if(config.Prisoner.TpOfPrisonInvClear) prisoner.inventory.Strip();
TP(prisoner, _safezonepoints.GetRandom());
}
);
else prisoner.Hurt(1000);
StoredData[prisoner.userID] = new Prisoner("", false, false, 0, false, "");
SaveData(prisoner);
StoredData.Remove(prisoner.userID);
StoredData_Time.Remove(prisoner.userID);
LockUnlockPrisonerInventory(prisoner, false);
foreach(BasePlayer player in BasePlayer.activePlayerList) Player.Reply(player, string.Format(lang.GetMessage("RELEASE_PRISON_BROADCAST", this, player.UserIDString), prisoner.displayName), config.Setting.SteamID);
PrintWarning(LanguageEnglish ? $"[ {prisoner} ] - released!" : $"[ {prisoner} ] - освобожден!");
if(config.Setting.UseDiscordLogs && DiscordMessages) DiscordMessages.Call("API_SendTextMessage", config.Setting.WebHook, LanguageEnglish ? $"``[ Online ] [ {prisoner} ] - released!``" : $"``[ Online ] [ {prisoner} ] - освобожден!``");
CuiHelper.DestroyUi(prisoner, ".GUI_BLOCK");
}
private void ZonaGUI(BasePlayer player) {
CuiElementContainer container = new CuiElementContainer();
container.Add(new CuiPanel {
CursorEnabled = true, RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-507.5 -260", OffsetMax = "507.5 290"
}
, Image = {
Color = "0.517 0.521 0.509 0.95031577", Material = "assets/icons/greyout.mat"
}
}
, "Overlay", ".GUI_ZONA", ".GUI_ZONA");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "5 5", OffsetMax = "-5 -5"
}
, Image = {
Color = "0.217 0.221 0.209 0.95031577"
}
}
, ".GUI_ZONA", ".ZONA_GUI");
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "470 237.5", OffsetMax = "497.5 265"
}
, Button = {
Color = "1 1 1 0.75031577", Sprite = "assets/icons/close.png", Close = ".GUI_ZONA"
}
, Text = {
Text = ""
}
}
, ".ZONA_GUI");
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-502.5 237.5", OffsetMax = "455 265"
}
, Text = {
Text = lang.GetMessage("TITLE", this, player.UserIDString), Align = TextAnchor.MiddleCenter, FontSize = 18, Color = "1 1 1 0.75"
}
}
, ".ZONA_GUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-507.5 227.5", OffsetMax = "507.5 232.5"
}
, Image = {
Color = "0.517 0.521 0.509 0.95031577", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_GUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-507.5 177.5", OffsetMax = "507.5 182.5"
}
, Image = {
Color = "0.517 0.521 0.509 0.95031577", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_GUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "460 227.5", OffsetMax = "465 275"
}
, Image = {
Color = "0.517 0.521 0.509 0.95031577", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_GUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 0", OffsetMin = "0 36.75", OffsetMax = "0 41.75"
}
, Image = {
Color = "0.517 0.521 0.509 0.95031577", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_GUI");
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "7.5 7.5", OffsetMax = "29.5 29.5"
}
, Button = {
Color = "1 1 1 0.75031577", Sprite = "assets/icons/add.png", Command = "zona_cmd add"
}
, Text = {
Text = ""
}
}
, ".ZONA_GUI");
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "39.5 7.5", OffsetMax = "61.5 29.5"
}
, Button = {
Color = "1 1 1 0.75031577", Sprite = "assets/icons/subtract.png", Command = "zona_cmd remove"
}
, Text = {
Text = ""
}
}
, ".ZONA_GUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "69 0", OffsetMax = "74 37"
}
, Image = {
Color = "0.517 0.521 0.509 0.95031577", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_GUI");
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "79 5", OffsetMax = "106 32"
}
, Button = {
Color = "1 1 1 0.75031577", Sprite = "assets/icons/home.png", Command = "chat.say /tpzona"
}
, Text = {
Text = ""
}
}
, ".ZONA_GUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "111 0", OffsetMax = "116 37"
}
, Image = {
Color = "0.517 0.521 0.509 0.95031577", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_GUI");
CuiHelper.AddUi(player, container);
CategoryGUI(player, -1);
}
[ChatCommand("zonamenu")]
private void cmdOpenGUIZona(BasePlayer player) {
if(player.IsAdmin || permission.UserHasPermission(player.UserIDString, "xprison.admin")) ZonaGUI(player);
}
private void OnPlayerConnected(BasePlayer player) {
if(player.IsReceivingSnapshot) {
NextTick(() => OnPlayerConnected(player));
return;
}
LoadData(player);
}
private void AddPrisonerGUI(BasePlayer player) {
CuiElementContainer container = new CuiElementContainer();
PrisonerCreate create = _adminsPrisonerCreate[player.userID];
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-275 -106.25", OffsetMax = "275 53.75"
}
, Image = {
Color = "0.517 0.521 0.509 1", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_GUI", ".GUI_ADD", ".GUI_ADD");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "5 5", OffsetMax = "-5 -5"
}
, Image = {
Color = "0.217 0.221 0.209 0.95"
}
}
, ".GUI_ADD", ".ADD_GUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-265 20", OffsetMax = "-95 45"
}
, Image = {
Color = "0.217 0.221 0.209 0.95"
}
}
, ".ADD_GUI", ".BUTTON_STEAMID");
container.Add(new CuiElement {
Parent = ".BUTTON_STEAMID", Components = {
new CuiInputFieldComponent {
Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 15, Command = $"zona_c prisoner_A add steamID", CharsLimit = 17, NeedsKeyboard = true, Text = $"{create.SteamID}"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
}
}
}
);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-265 0", OffsetMax = "-95 20"
}
, Text = {
Text = "SteamID:", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 12, Color = "1 1 1 0.75"
}
}
, ".ADD_GUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "95 20", OffsetMax = "265 45"
}
, Image = {
Color = "0.217 0.221 0.209 0.95"
}
}
, ".ADD_GUI", ".BUTTON_DURATION");
container.Add(new CuiElement {
Parent = ".BUTTON_DURATION", Components = {
new CuiInputFieldComponent {
Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 15, Command = $"zona_c prisoner_A add duration", CharsLimit = 10, NeedsKeyboard = true, Text = $"{create.Duration}"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
}
}
}
);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "95 0", OffsetMax = "265 20"
}
, Text = {
Text = lang.GetMessage("TERM", this, player.UserIDString), Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 12, Color = "1 1 1 0.75"
}
}
, ".ADD_GUI");
int count = config.Setting.TimeList.Count;
foreach(var time in config.Setting.TimeList) {
double offset = -(13 * count--) + -(1.35 * count--);
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = $"{offset} 15", OffsetMax = $"{offset + 26} 35"
}
, Button = {
Color = "0.35 0.35 0.35 1", Command = $"zona_c prisoner_A add duration {time.Value}"
}
, Text = {
Text = time.Key, Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 10
}
}
, ".BUTTON_DURATION");
}
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-70 20", OffsetMax = "-20 70"
}
, Button = {
Color = create.Life ? "0.53 0.77 0.35 0.8" : "1 0.4 0.35 0.8", Command = $"zona_c prisoner_A add life {!create.Life}"
}
, Text = {
Text = ""
}
}
, ".ADD_GUI");
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-80 0", OffsetMax = "-10 20"
}
, Text = {
Text = lang.GetMessage("FORLIFE", this, player.UserIDString), Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 12, Color = "1 1 1 0.75"
}
}
, ".ADD_GUI");
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "20 20", OffsetMax = "70 70"
}
, Button = {
Color = create.Sentence ? "0.53 0.77 0.35 0.8" : "1 0.4 0.35 0.8", Command = $"zona_c prisoner_A add sentence {!create.Sentence}"
}
, Text = {
Text = ""
}
}
, ".ADD_GUI");
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "10 0", OffsetMax = "80 20"
}
, Text = {
Text = lang.GetMessage("FORONLINE", this, player.UserIDString), Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 12, Color = "1 1 1 0.75"
}
}
, ".ADD_GUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0.5", AnchorMax = "1 0.5", OffsetMin = "5 -40", OffsetMax = "-5 0"
}
, Image = {
Color = "0.217 0.221 0.209 0.95"
}
}
, ".ADD_GUI", ".BUTTON_REASON");
container.Add(new CuiElement {
Parent = ".BUTTON_REASON", Components = {
new CuiInputFieldComponent {
Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 15, Command = $"zona_c prisoner_A add reason", NeedsKeyboard = true, Text = create.Reason
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
}
}
}
);
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-75 -70", OffsetMax = "75 -45"
}
, Button = {
Color = "0.53 0.77 0.35 0.8", Command = $"cmd_prisoner add {create.SteamID} {create.Life} {create.Duration} {create.Sentence} {create.Reason}", Close = ".GUI_ADD"
}
, Text = {
Text = lang.GetMessage("TO_PRISON", this, player.UserIDString), Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 12
}
}
, ".ADD_GUI");
CuiHelper.AddUi(player, container);
}
private void API_AddOfflinePrisoner(ulong userID, bool life = false, int duration = 0, bool sentence = false, string reason = "") {
if(API_IsOfflinePrisoner(userID)) {
PrintWarning(LanguageEnglish ? $"[ {userID} ] - is already a prisoner!" : $"[ {userID} ] - уже является заключенным!");
return;
}
Prisoner Data = new Prisoner(config.Prisoner.NamePrisoner.GetRandom(), life, true, life ? 0 : sentence ? duration : duration + GetUnixTime(), sentence, reason);
PrintWarning(LanguageEnglish ? $"[ {userID} ] - went to prison!" : $"[ {userID} ] - отправился на зону!");
Interface.Oxide.DataFileSystem.WriteObject($"XDataSystem/XPrison/{userID}", Data);
if(config.Setting.UseDiscordLogs && DiscordMessages) DiscordMessages.Call("API_SendTextMessage", config.Setting.WebHook, LanguageEnglish ? $"``[ Offline ] [ {userID} ] - went to prison!``" : $"``[ Offline ] [ {userID} ] - отправился на зону!``");
BasePlayer prisonerSleep = BasePlayer.FindSleeping(userID);
if(prisonerSleep != null) LockUnlockPrisonerInventory(prisonerSleep, true);
}
private void Unload() {
foreach(BasePlayer player in BasePlayer.activePlayerList) {
CuiHelper.DestroyUi(player, ".GUI_ZONA");
CuiHelper.DestroyUi(player, ".GUI_BLOCK");
if(API_IsOnlinePrisoner(player.userID)) LockUnlockPrisonerInventory(player, false);
}
foreach(BasePlayer player in BasePlayer.sleepingPlayerList) if(API_IsOfflinePrisoner(player.userID)) LockUnlockPrisonerInventory(player, false);
config = null;
}
[ConsoleCommand("zona_cmd")]
private void ccmdCMD(ConsoleSystem.Arg args) {
BasePlayer player = args.Player();
if(player != null && (player.IsAdmin || permission.UserHasPermission(player.UserIDString, "xprison.admin"))) {
Effect x = new Effect("assets/bundled/prefabs/fx/notice/loot.drag.grab.fx.prefab", player, 0, new Vector3(), new Vector3());
switch(args.Args[0]) {
case "add" : {
_adminsPrisonerCreate[player.userID] = new PrisonerCreate {
SteamID = 76561100000000000, Life = false, Duration = 3600, Sentence = false, Reason = "Text reason"
}
;
AddPrisonerGUI(player);
break;
}
case "remove" : {
RemovePrisonerGUI(player);
break;
}
}
EffectNetwork.Send(x, player.Connection);
}
}
[ChatCommand("zonaloc")]
private void cmgZonaLoc(BasePlayer player) {
if(player.IsAdmin || permission.UserHasPermission(player.UserIDString, "xprison.admin")) Player.Reply(player, string.Format(lang.GetMessage("ZONA_LOC", this, player.UserIDString), config.Zona.PositionZona, player.transform.position), config.Setting.SteamID);
}
private void RemovePrisonerGUI(BasePlayer player, ulong steamID = 76561100000000000) {
CuiElementContainer container = new CuiElementContainer();
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-275 -91.25", OffsetMax = "275 38.75"
}
, Image = {
Color = "0.517 0.521 0.509 1", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_GUI", ".GUI_REMOVE", ".GUI_REMOVE");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "5 5", OffsetMax = "-5 -5"
}
, Image = {
Color = "0.217 0.221 0.209 0.95"
}
}
, ".GUI_REMOVE", ".REMOVE_GUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-85 5", OffsetMax = "85 30"
}
, Image = {
Color = "0.217 0.221 0.209 0.95"
}
}
, ".REMOVE_GUI", ".BUTTON_STEAMID");
container.Add(new CuiElement {
Parent = ".BUTTON_STEAMID", Components = {
new CuiInputFieldComponent {
Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 15, Command = $"zona_c prisoner_A remove STEAMID:", CharsLimit = 17, NeedsKeyboard = true, Text = $"{steamID}"
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
}
}
}
);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-85 -15", OffsetMax = "85 5"
}
, Text = {
Text = "SteamID:", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 12, Color = "1 1 1 0.75"
}
}
, ".REMOVE_GUI");
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-75 -55", OffsetMax = "75 -30"
}
, Button = {
Color = "0.53 0.77 0.35 0.8", Command = $"cmd_prisoner remove {steamID} false 0 false", Close = ".GUI_REMOVE"
}
, Text = {
Text = lang.GetMessage("RELEASE_PRISON", this, player.UserIDString), Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 12
}
}
, ".REMOVE_GUI");
CuiHelper.AddUi(player, container);
}
private void OnPluginUnloaded(Plugin name) {
if(name.Title == "Better Chat" || name.Title == "IQChat") Subscribe(nameof(OnPlayerChat));
}
private List<Vector3> _safezonepoints = new List<Vector3>();
private void LockUnlockPrisonerInventory(BasePlayer prisoner, bool locked) {
if(config.Prisoner.BlockWear) prisoner.inventory.containerWear.SetLocked(locked);
if(config.Prisoner.BlockBelt) prisoner.inventory.containerBelt.SetLocked(locked);
if(config.Prisoner.BlockMain) prisoner.inventory.containerMain.SetLocked(locked);
}
private object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info) => entity.OwnerID == 100001 ? true : null;
private void CategoryGUI(BasePlayer player, int page = 0) {
CuiElementContainer container = new CuiElementContainer();
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-497.5 187.5", OffsetMax = "497.5 222.5"
}
, Image = {
Color = "0 0 0 0"
}
}
, ".ZONA_GUI", ".ZonaBUTTON", ".ZonaBUTTON");
int x = 0, count = _command.Count;
foreach(var category in _command) {
string color = page == x ? "0.53 0.77 0.35 0.8" : "0 0 0 0";
double offset = -(164 * count--) + -(2.5 * count--);
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = $"{offset} -17.5", OffsetMax = $"{offset + 328} 17.5"
}
, Button = {
Color = "0.517 0.521 0.509 0.5", Material = "assets/icons/greyout.mat", Command = category.Value + $" {x}"
}
, Text = {
Text = lang.GetMessage(category.Key, this, player.UserIDString), Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 18, Color = "0.75 0.75 0.75 1"
}
}
, ".ZonaBUTTON", ".BUTTON");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 0", OffsetMax = "0 1.5"
}
, Image = {
Color = color, Material = "assets/icons/greyout.mat"
}
}
, ".BUTTON");
x++;
}
CuiHelper.AddUi(player, container);
}
private PrisonConfig config;
private void OfflineGUI(BasePlayer player, int Page = 0) {
CuiElementContainer container = new CuiElementContainer();
List<BasePlayer> offline_players = BasePlayer.sleepingPlayerList.Where(xx => !xx.IsConnected).ToList();
int x = 0, y = 0;
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-502.5 -228.5", OffsetMax = "502.5 177.5"
}
, Image = {
Color = "0 0 0 0"
}
}
, ".ZONA_GUI", ".ZONA_OFFLINE");
foreach(BasePlayer p in offline_players.Skip(Page * 32)) {
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = $"{-497.5 + (x * 250)} {153 - (y * 50)}", OffsetMax = $"{-252.5 + (x * 250)} {198 - (y * 50)}"
}
, Image = {
Color = "0.517 0.521 0.509 0.5", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_OFFLINE", ".PlayerGUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "45 0", OffsetMax = "-195 0"
}
, Image = {
Color = "0.9 0.25 0.25 1", Material = "assets/icons/greyout.mat"
}
}
, ".PlayerGUI");
container.Add(new CuiElement {
Parent = ".PlayerGUI", Components = {
new CuiRawImageComponent {
Png = (string) ImageLibrary.Call("GetImage", p.UserIDString)
}
, new CuiRectTransformComponent {
AnchorMin = "0 0.5", AnchorMax = "0 0.5", OffsetMin = "2.5 -20", OffsetMax = "42.5 20"
}
}
}
);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "52.5 30", OffsetMax = "-22.5 0"
}
, Text = {
Text = $"NAME: {p.displayName}", Align = TextAnchor.MiddleLeft, Font = "robotocondensed-regular.ttf", FontSize = 10
}
}
, ".PlayerGUI");
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "52.5 17", OffsetMax = "-22.5 -13"
}
, Text = {
Text = $"ID: {p.userID}", Align = TextAnchor.MiddleLeft, Font = "robotocondensed-regular.ttf", FontSize = 10
}
}
, ".PlayerGUI");
x++;
if(x == 4) {
x = 0;
y++;
if(y == 8) break;
}
}
bool back = Page != 0;
bool next = offline_players.Count > ((Page + 1) * 32);
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-190 -36.75", OffsetMax = "-100 -10"
}
, Button = {
Color = back ? "0.65 0.29 0.24 1" : "0.65 0.29 0.24 0.4", Command = back ? $"page.xprison offline back {Page}" : ""
}
, Text = {
Text = lang.GetMessage("BACK", this, player.UserIDString), Align = TextAnchor.MiddleCenter, FontSize = 16, Font = "robotocondensed-regular.ttf", Color = back ? "0.92 0.79 0.76 1" : "0.92 0.79 0.76 0.4"
}
}
, ".ZONA_OFFLINE");
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-95 -36.75", OffsetMax = "-5 -10"
}
, Button = {
Color = next ? "0.35 0.45 0.25 1" : "0.35 0.45 0.25 0.4", Command = next ? $"page.xprison offline next {Page}" : ""
}
, Text = {
Text = lang.GetMessage("NEXT", this, player.UserIDString), Align = TextAnchor.MiddleCenter, FontSize = 16, Font = "robotocondensed-regular.ttf", Color = next ? "0.75 0.95 0.41 1" : "0.75 0.95 0.41 0.4"
}
}
, ".ZONA_OFFLINE");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-200 -46.75", OffsetMax = "-195 0"
}
, Image = {
Color = "0.517 0.521 0.509 0.95", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_OFFLINE");
CuiHelper.AddUi(player, container);
}
private void PrisonerGUI(BasePlayer player, int Page = 0) {
CuiElementContainer container = new CuiElementContainer();
int x = 0, y = 0, unixtime = GetUnixTime();
bool multifighting = MultiFighting;
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-502.5 -228.5", OffsetMax = "502.5 177.5"
}
, Image = {
Color = "0 0 0 0"
}
}
, ".ZONA_GUI", ".ZONA_PRISONER");
foreach(var p in StoredData.Skip(Page * 32)) {
BasePlayer prisoner = BasePlayer.FindByID(p.Key);
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = $"{-497.5 + (x * 250)} {153 - (y * 50)}", OffsetMax = $"{-252.5 + (x * 250)} {198 - (y * 50)}"
}
, Image = {
Color = "0.517 0.521 0.509 0.5", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_PRISONER", ".PlayerGUI");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "45 0", OffsetMax = "-195 0"
}
, Image = {
Color = "0.9 0.53 0 1", Material = "assets/icons/greyout.mat"
}
}
, ".PlayerGUI");
container.Add(new CuiElement {
Parent = ".PlayerGUI", Components = {
new CuiRawImageComponent {
Png = (string) ImageLibrary.Call("GetImage", prisoner.UserIDString)
}
, new CuiRectTransformComponent {
AnchorMin = "0 0.5", AnchorMax = "0 0.5", OffsetMin = "2.5 -20", OffsetMax = "42.5 20"
}
}
}
);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "52.5 30", OffsetMax = "0 0"
}
, Text = {
Text = $"NAME: {prisoner.displayName}", Align = TextAnchor.MiddleLeft, Font = "robotocondensed-regular.ttf", FontSize = 10
}
}
, ".PlayerGUI");
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "52.5 21.5", OffsetMax = "0 -9"
}
, Text = {
Text = $"ID: {prisoner.userID}", Align = TextAnchor.MiddleLeft, Font = "robotocondensed-regular.ttf", FontSize = 9
}
}
, ".PlayerGUI");
if(!string.IsNullOrEmpty(p.Value.Reason)) container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 0", OffsetMin = "52.5 12.5", OffsetMax = "0 24"
}
, Text = {
Text = $"- {p.Value.Reason}", Align = TextAnchor.MiddleLeft, Font = "robotocondensed-regular.ttf", FontSize = 9, Color = "1 0.8 0.8 1"
}
}
, ".PlayerGUI");
TimeSpan time = TimeSpan.FromSeconds(p.Value.Sentence ? p.Value.Time : p.Value.Time - unixtime);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 0", OffsetMin = "52.5 0", OffsetMax = "-22.5 15"
}
, Text = {
Text = p.Value.Life ? lang.GetMessage("TERM_FORLIFE_UI", this, player.UserIDString) : string.Format(lang.GetMessage("TERM_DURATION_UI", this, player.UserIDString), time.Days, time.Hours, time.Minutes, time.Seconds), Align = TextAnchor.MiddleLeft, Font = "robotocondensed-regular.ttf", FontSize = 9
}
}
, ".PlayerGUI");
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-20 25", OffsetMax = "-2.5 42.5"
}
, Button = {
Color = "1 1 1 0.75", Sprite = "assets/icons/subtract.png", Command = $"zona_c prisoner remove {p.Key}"
}
, Text = {
Text = ""
}
}
, ".PlayerGUI");
if(multifighting) container.Add(new CuiButton {
RectTransform = {
AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-20 2.5", OffsetMax = "-2.5 20"
}
, Button = {
Color = "1 1 1 0.75", Sprite = (bool)MultiFighting?.CallHook("IsSteam", player.Connection) ? "assets/icons/steam.png" : "assets/icons/warning_2.png"
}
, Text = {
Text = ""
}
}
, ".PlayerGUI");
x++;
if(x == 4) {
x = 0;
y++;
if(y == 8) break;
}
}
bool back = Page != 0;
bool next = StoredData.Count > ((Page + 1) * 32);
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-190 -36.75", OffsetMax = "-100 -10"
}
, Button = {
Color = back ? "0.65 0.29 0.24 1" : "0.65 0.29 0.24 0.4", Command = back ? $"page.xprison prisoner back {Page}" : ""
}
, Text = {
Text = lang.GetMessage("BACK", this, player.UserIDString), Align = TextAnchor.MiddleCenter, FontSize = 16, Font = "robotocondensed-regular.ttf", Color = back ? "0.92 0.79 0.76 1" : "0.92 0.79 0.76 0.4"
}
}
, ".ZONA_PRISONER");
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-95 -36.75", OffsetMax = "-5 -10"
}
, Button = {
Color = next ? "0.35 0.45 0.25 1" : "0.35 0.45 0.25 0.4", Command = next ? $"page.xprison prisoner next {Page}" : ""
}
, Text = {
Text = lang.GetMessage("NEXT", this, player.UserIDString), Align = TextAnchor.MiddleCenter, FontSize = 16, Font = "robotocondensed-regular.ttf", Color = next ? "0.75 0.95 0.41 1" : "0.75 0.95 0.41 0.4"
}
}
, ".ZONA_PRISONER");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-200 -46.75", OffsetMax = "-195 0"
}
, Image = {
Color = "0.517 0.521 0.509 0.95", Material = "assets/icons/greyout.mat"
}
}
, ".ZONA_PRISONER");
CuiHelper.AddUi(player, container);
}
private bool API_IsOnlinePrisoner(ulong userID) => StoredData.ContainsKey(userID);
private Dictionary<ulong, int> StoredData_Time = new Dictionary<ulong, int>();
private readonly List<ulong> _netIDsPrefabs = new List<ulong>
// ... [Code preview truncated due to length. Full source in attached file] ...