C#:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Facepunch.Extend;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Libraries;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
using UnityEngine.UI;
namespace Oxide.Plugins;
[Info("LSkins", "Scrooge", "2.2.11")]
public class LSkins : RustPlugin
{
#region Cfg
private const bool En = false;
private class DataPlayer
{
[JsonProperty(En ? "List of favorite skins" : "Список избранных скинов")]
public Dictionary<string, Dictionary<long, ItemData.SkinInfo>> _izvSkins = new();
[JsonProperty(En ? "List of default skins supplied" : "Список поставленных скинов по дефолту")]
public Dictionary<string, DefaultSkins> _defaultSkins = new();
public int? SelectedSet = null;
public Dictionary<int, Sets> PlayerSets = new();
internal class Sets
{
[JsonProperty(En ? "List of skins" : "Список скинов")]
public Dictionary<string, SetSkins> _skins = new();
}
}
private class SetSkins
{
[JsonProperty(En ? "SkinID" : "СкинАйди")]
public long skinId;
[JsonProperty(En ? "Information about the skin" : "Информация о скине")]
public ItemData.SkinInfo SkinInfo;
}
private class DefaultSkins
{
[JsonProperty(En ? "SkinID" : "СкинАйди")]
public long skinId;
[JsonProperty(En ? "Information about the skin" : "Информация о скине")]
public ItemData.SkinInfo SkinInfo;
}
private Dictionary<ulong, DataPlayer> _playerData = new();
private static ConfigData Cfg { get; set; }
private class ConfigData
{
internal class MarketSystem
{
[JsonProperty(En ? "Enabled(true = yes)" : "Включить?(true = да)")]
public bool IsEnabled = false;
[JsonProperty(En
? "How to pay?(Scrap, ServerRewards, Economics)"
: "Чем платить?(Scrap, ServerRewards, Economics)")]
public string WhoMarket = "Scrap";
[JsonProperty(En
? "The price for opening the interface (If 0, then free)"
: "Цена за открытие интерфейса(Если 0, то бесплатно)")]
public int costOpen = 10;
[JsonProperty(En
? "Price per change of one skin (If 0, then free)"
: "Цена за смену одного скина(Если 0, то бесплатно)")]
public int costChange = 10;
}
internal class InterfaceSetting
{
[JsonProperty(En ? "Background color of favorite skins" : "Цвет фона фаворитных скинов")]
public string favcolor = "#535150";
[JsonProperty(En ? "Background color of the main panel" : "Цвет фона основной панели")]
public string mainColor = "#535151";
[JsonProperty(En ? "The color of the forward arrow" : "Цвет стрелочки вперед")]
public string pageup = "#5c80ba";
[JsonProperty(En ? "The color of the back arrow" : "Цвет стрелочки назад")]
public string pagedown = "#5c80ba";
}
[JsonProperty(En
? "Add a skin to the cfg automatically?(true = yes)"
: "Добавить в кфг автоматически скин?(true = да)")]
public bool IsApproved = false;
[JsonProperty(En
? "Automatically remove approved skins?(true = yes)"
: "Автоматически удалять апрувнутые скины?(true = да)")]
public bool AutoDelete = false;
[JsonProperty(En ? "Enabled sets(true = yes)" : "Включить сеты?(true = да)")]
public bool IsEnabledSets = false;
[JsonProperty(En ? "Rights to use the skins system" : "Права для использование системы скинов.")]
public string canuse = "lskins.use";
[JsonProperty(En ? "Rights to use the skins approve" : "Права для использование подтвержденных скинов.")]
public string canuseapprove = "lskins.useapprove";
[JsonProperty(En ? "Rights to use the skins sets" : "Права для использование сетов скинов.")]
public string canusesets = "lskins.canusesets";
[JsonProperty(En ? "Max create sets" : "Сколько максимум можно содать сетов скинов")]
public int maxSets = 3;
[JsonProperty(En ? "List of available commands" : "Список доступных команд")]
public List<string> Commands = new();
[JsonProperty(En
? "List of available commands for skins entity"
: "Список доступных команд для изменения скина ентити")]
public List<string> EntCommands = new();
[JsonProperty(En
? "Install the skin automatically on items where there is already a skin?(true = yes)"
: "Устанавилвать скин автоматически на предметы где уже есть скин?(true = да)")]
public bool SkinAuto = false;
[JsonProperty(En ? "Rights to use default skins" : "Права для использование скинов по дефолту")]
public string canusedefault = "lskins.usedefault";
[JsonProperty(En ? "Setting up payment for opening" : "Настройка оплаты за открытие")]
public MarketSystem Market = new();
[JsonProperty(En ? "Setting interface" : "Настройка интерфейса")]
public InterfaceSetting Interface = new();
[JsonProperty(En
? "Items with these skins cannot be exchanged."
: "Предметы с этими скинами нельзя будет поменять.")]
public List<long> blackList = new();
[JsonProperty(En ? "Rights to use unique skins" : "Права для использование уникальных скинов")]
public Dictionary<string, List<long>> useSkins = new();
public static ConfigData GetNewConf()
{
var newConfig = new ConfigData
{
Commands = new List<string>()
{
"skins",
"skin",
"s"
},
EntCommands = new List<string>()
{
"se"
},
useSkins = new Dictionary<string, List<long>>()
{
["lskins.prem"] = new()
{
2668297561,
2649480126,
2599664731
}
},
blackList = new List<long>()
{
12341234
}
};
return newConfig;
}
}
private class ItemData
{
public class SkinInfo
{
[JsonProperty(En ? "Enabled skin?(true = yes)" : "Включить скин?(true = да)")]
public bool IsEnabled = true;
[JsonProperty(En
? "Is this skin from the developers of rust or take it in a workshop?"
: "Этот скин есть от разработчиков раста или принять в воркшопе??(true = да)")]
public bool IsApproved = true;
[JsonProperty(En
? "Is item"
: "Это предмет?")]
public bool IsItem = false;
[JsonProperty(En
? "Shortname, если предмет"
: "Шортнейм, если предмет")]
public string ShortName = null;
[JsonProperty(En ? "Name skin" : "Название скина")]
public string MarketName = "Warhead LR300";
}
public Dictionary<long, SkinInfo> _skinInfos = new();
}
protected override void LoadDefaultConfig()
{
Cfg = ConfigData.GetNewConf();
}
protected override void SaveConfig()
{
Config.WriteObject(Cfg);
}
protected override void LoadConfig()
{
base.LoadConfig();
try
{
Cfg = Config.ReadObject<ConfigData>();
}
catch
{
LoadDefaultConfig();
}
NextTick(SaveConfig);
}
#endregion
#region Interface
private static string Layer = "UiLSkins";
private static string Hud = "Hud";
private static string Overlay = "Overlay";
private static string _regular = "robotocondensed-regular.ttf";
private static string _blur = "assets/content/ui/uibackgroundblur.mat";
private static string _sharp = "assets/content/ui/ui.background.tile.psd";
private static string _radial = "assets/content/ui/ui.background.transparent.radial.psd";
private void LoadSets(BasePlayer player)
{
if (!Cfg.IsEnabledSets || !permission.UserHasPermission(player.UserIDString, Cfg.canusesets)) return;
if (!_playerData.TryGetValue(player.userID, out DataPlayer data)) return;
var container = new CuiElementContainer();
container.Add(new CuiElement
{
Name = Layer + "-Sets",
Parent = "Overlay",
DestroyUi = Layer + "-Sets",
Components =
{
new CuiNeedsCursorComponent(),
new CuiImageComponent { Color = "1 1 1 0" },
new CuiRectTransformComponent
{
AnchorMin = "1 1", AnchorMax = "1 1", OffsetMin = "-429.971 0",
OffsetMax = "-45.375 -200"
}
}
});
container.Add(new CuiElement
{
Name = "Panel_1671",
Parent = Layer + "-Sets",
DestroyUi = "Panel_1671",
Components =
{
new CuiNeedsCursorComponent(),
new CuiImageComponent
{
Color = HexToRustFormat(Cfg.Interface.mainColor),
Material = "assets/content/ui/ui.background.tile.psd",
ImageType = Image.Type.Tiled
},
new CuiRectTransformComponent
{
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-192.3 52",
OffsetMax = "192.3 102.927"
}
}
});
container.Add(new CuiElement
{
Name = "Label_9524",
Parent = "Panel_1671",
Components =
{
new CuiTextComponent
{
Text = lang.GetMessage("SKINSSET", this, player.UserIDString), Font = "robotocondensed-bold.ttf",
FontSize = 22,
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#beb5ac")
},
new CuiRectTransformComponent
{
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-192.3 -27.423",
OffsetMax = "192.3 27.424"
}
}
});
var offsetFirst = +55 - 55 * data.PlayerSets.Count;
container.Add(new CuiElement
{
Name = "Panel_6941",
Parent = Layer + "-Sets",
DestroyUi = "Panel_6941",
Components =
{
new CuiNeedsCursorComponent(), new CuiScrollViewComponent()
{
ContentTransform =
new CuiRectTransform
{
AnchorMin = "0.5 1",
AnchorMax = "0.5 1",
OffsetMin = $"0 {(offsetFirst < -400 ? offsetFirst : -400)}",
OffsetMax = "0 0",
},
Vertical = true,
Horizontal = false,
MovementType = ScrollRect.MovementType.Elastic,
Elasticity = 0.25f,
Inertia = true,
DecelerationRate = offsetFirst < -400 ? 0.3f : 100,
ScrollSensitivity = offsetFirst < -400 ? 10 : 0,
VerticalScrollbar = null,
},
new CuiRectTransformComponent
{
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-192.3 -192.929",
OffsetMax = "192.3 48.081"
}
}
});
container.Add(new CuiElement
{
Name = "Panel_7597Slider",
Parent = "Panel_6941",
DestroyUi = "Panel_7597Slider",
Components =
{
new CuiNeedsCursorComponent(),
new CuiImageComponent { Color = "1 1 1 0" },
new CuiRectTransformComponent
{
AnchorMin = "0 0", AnchorMax = "1 1"
}
}
});
int i = 1;
var getSelected = data.SelectedSet;
foreach (var valuePlayerSet in data.PlayerSets)
{
container.Add(new CuiElement
{
Name = "Panel_4437" + i,
Parent = "Panel_7597Slider",
DestroyUi = "Panel_4437" + i,
Components =
{
new CuiNeedsCursorComponent(),
new CuiImageComponent
{
Color = "0.35 0.35 0.35 0.65"
},
new CuiRectTransformComponent
{
AnchorMin = "0.5 0.9", AnchorMax = "0.5 0.9", OffsetMin = $"-184.424 {22.358 - i * 55}",
OffsetMax = $"183.699 {69.56 - i * 55}"
}
}
});
container.Add(new CuiElement
{
Name = "Label_1331",
Parent = "Panel_4437" + i,
Components =
{
new CuiTextComponent
{
Text = $"#{(i - 1) + 1}", Font = "robotocondensed-bold.ttf", FontSize = 18,
Align = TextAnchor.MiddleCenter,
Color = "0.9254902 0.9254902 0.9254902 1"
},
new CuiRectTransformComponent
{
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-184.064 -23.601",
OffsetMax = "-139.472 23.601"
}
}
});
if (getSelected == valuePlayerSet.Key)
{
container.Add(new CuiElement
{
Name = "Label_1331 (1)",
Parent = "Panel_4437" + i,
Components =
{
new CuiTextComponent
{
Text = lang.GetMessage("SELECTED", this, player.UserIDString),
Font = "robotocondensed-bold.ttf", FontSize = 15,
Align = TextAnchor.MiddleCenter, Color = "0.9254902 0.9254902 0.9254902 1"
},
new CuiRectTransformComponent
{
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-139.476 -23.601",
OffsetMax = "-70.305 23.601"
}
}
});
}
container.Add(new CuiButton()
{
Text = { Text = "" },
Button = { Color = "0 0 0 0", Command = $"uiskinmenu selectset {valuePlayerSet.Key}" }
}, "Panel_4437" + i);
var offset = 35 + 35 * valuePlayerSet.Value._skins.Count;
container.Add(new CuiElement
{
Name = "Panel_5534",
Parent = "Panel_4437" + i,
Components =
{
new CuiNeedsCursorComponent(), new CuiScrollViewComponent()
{
ContentTransform =
new CuiRectTransform
{
AnchorMin = "0 0.5",
AnchorMax = "0 0.5",
OffsetMin = $"0 0",
OffsetMax = $"{(offset < 235 ? offset : 235)} 0",
},
Vertical = false,
Horizontal = true,
MovementType = ScrollRect.MovementType.Elastic,
Elasticity = 0.25f,
Inertia = true,
DecelerationRate = offset < 235 ? 0.3f : 100,
ScrollSensitivity = offset < 235 ? 10 : 0,
HorizontalScrollbar = null,
},
new CuiRectTransformComponent
{
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-55.221 -23.601",
OffsetMax = "180 23.601"
}
}
});
container.Add(new CuiElement
{
Name = "Panel_1504",
Parent = "Panel_5534",
Components =
{
new CuiNeedsCursorComponent(),
new CuiImageComponent { Color = "1 1 1 0" },
new CuiRectTransformComponent
{
AnchorMin = "0 0", AnchorMax = "1 1",
}
}
});
int j = 4;
foreach (var keyValuePair in valuePlayerSet.Value._skins)
{
var item = ItemManager.FindItemDefinition(keyValuePair.Key);
container.Add(new CuiElement
{
Name = "Image_3558" + j,
Parent = "Panel_1504",
Components =
{
new CuiImageComponent
{
Color = "1 1 1 1",
ItemId = keyValuePair.Value.SkinInfo.IsItem
? keyValuePair.Value.skinId == 0 ? item.itemid : (int)keyValuePair.Value.skinId
: item.itemid,
SkinId = keyValuePair.Value.SkinInfo.IsItem ? 0 : (ulong)keyValuePair.Value.skinId
},
new CuiRectTransformComponent
{
AnchorMin = "0 0.5", AnchorMax = "0 0.5", OffsetMin = $"{-119.641 + j * 35} -17.27",
OffsetMax = $"{-83.8 + j * 35} 18.453"
}
}
});
j++;
}
i++;
}
if (data.PlayerSets.Count < Cfg.maxSets)
{
container.Add(new CuiElement
{
Name = "Panel_4437" + i,
Parent = "Panel_7597Slider",
DestroyUi = "Panel_4437" + i,
Components =
{
new CuiNeedsCursorComponent(),
new CuiImageComponent
{
Color = "0.35 0.35 0.35 0.65"
},
new CuiRectTransformComponent
{
AnchorMin = "0.5 0.9", AnchorMax = "0.5 0.9", OffsetMin = $"-184.424 {22.358 - i * 55}",
OffsetMax = $"183.699 {69.56 - i * 55}"
}
}
});
container.Add(new CuiElement
{
Name = "Label_1331 (1)",
Parent = "Panel_4437" + i,
Components =
{
new CuiTextComponent
{
Text = lang.GetMessage("CREATESET", this, player.UserIDString),
Font = "robotocondensed-bold.ttf", FontSize = 15,
Align = TextAnchor.MiddleCenter, Color = "0.9254902 0.9254902 0.9254902 1"
},
new CuiRectTransformComponent
{
AnchorMin = "0 0", AnchorMax = "1 1"
}
}
});
container.Add(new CuiButton()
{
Text = { Text = "" },
Button = { Color = "0 0 0 0", Command = "uiskinmenu createset" }
}, "Panel_4437" + i);
}
CuiHelper.AddUi(player, container);
}
private void LoadIzbranoeUI(BasePlayer player, string weapon, ulong itemId, int page, bool isentity = false,
int side = 0)
{
if (!_playerData.TryGetValue(player.userID, out var weapons)) return;
CuiHelper.DestroyUi(player, Layer + "-Izbranoe");
var cont = new CuiElementContainer();
cont.Add(new CuiPanel()
{
Image =
{
Color = "0 0 0 0"
},
RectTransform =
{
AnchorMin = "0.5 0",
AnchorMax = "0.5 0",
OffsetMin = $"{201} {111}",
OffsetMax = $"{571} {231}"
}
}, "Overlay", Layer + "-Izbranoe");
if (!weapons._izvSkins.TryGetValue(weapon, out var tSkinsList)) return;
foreach (var keyValuePair in Cfg.useSkins.Where(keyValuePair =>
!permission.UserHasPermission(player.UserIDString, keyValuePair.Key)))
keyValuePair.Value.ForEach(p =>
{
if (tSkinsList.ContainsKey(p)) tSkinsList.Remove(p);
});
for (var i = 0; i < 12; i++)
{
if (tSkinsList.Count - 1 < i) continue;
cont.Add(new CuiElement()
{
Parent = Layer + "-Izbranoe",
Components =
{
new CuiImageComponent()
{
ItemId = ItemManager.FindItemDefinition(tSkinsList.ToList()[i].Value.IsItem
? tSkinsList.ToList()[i].Value.ShortName
: weapon).itemid,
SkinId = tSkinsList.ToList()[i].Value.IsItem ? 0 : (ulong)tSkinsList.ToList()[i].Key
},
new CuiRectTransformComponent()
{
AnchorMin =
$"0 0.5",
AnchorMax =
$"0 0.5",
OffsetMin =
$"{2 + i * 62 - Math.Floor((double)i / 6) * 6 * 62} {5 - Math.Floor((double)i / 6) * 62}",
OffsetMax =
$"{52 + i * 62 - Math.Floor((double)i / 6) * 6 * 62} {55 - Math.Floor((double)i / 6) * 62}"
}
}
});
var type = isentity ? "setskinent" : "setskin";
cont.Add(new CuiButton()
{
Button =
{
Color = "1 1 1 0",
Command = $"uiskinmenu {type} {itemId} {tSkinsList.ToList()[i].Key} {page}"
},
Text =
{
Text = ""
},
RectTransform =
{
AnchorMin =
$"0 0.5",
AnchorMax =
$"0 0.5",
OffsetMin =
$"{2 + i * 62 - Math.Floor((double)i / 6) * 6 * 62} {5 - Math.Floor((double)i / 6) * 62}",
OffsetMax =
$"{52 + i * 62 - Math.Floor((double)i / 6) * 6 * 62} {55 - Math.Floor((double)i / 6) * 62}"
}
}, Layer + "-Izbranoe", Layer + "-Izbranoe" + i);
cont.Add(new CuiButton()
{
RectTransform =
{
AnchorMin = "0 1",
AnchorMax = "0 1",
OffsetMin = $"{-5} {-10}",
OffsetMax = $"{10} {5}"
},
Button =
{
Command = $"uiskinmenu setizbranoe {weapon} {tSkinsList.ToList()[i].Key} {page} {itemId}",
Color = HexToRustFormat("#dead39"),
Sprite = "assets/icons/favourite_servers.png"
},
Text = { Text = "" }
}, Layer + "-Izbranoe" + i);
if (!permission.UserHasPermission(player.UserIDString, Cfg.canusedefault)) continue;
if (_playerData.TryGetValue(player.userID, out weapons) && weapons._defaultSkins.ContainsKey(weapon) &&
weapons._defaultSkins[weapon].skinId == tSkinsList.ToList()[i].Key)
cont.Add(new CuiButton()
{
RectTransform =
{
AnchorMin = "1 1",
AnchorMax = "1 1",
OffsetMin = $"{-10} {-7}",
OffsetMax = $"{0} {3}"
},
Button =
{
Command = $"uiskinmenu setdefault {weapon} {tSkinsList.ToList()[i].Key} {page} {itemId}",
Color = HexToRustFormat("#369f47"),
Sprite = "assets/icons/power.png"
},
Text = { Text = "" }
}, Layer + "-Izbranoe" + i);
else
cont.Add(new CuiButton()
{
RectTransform =
{
AnchorMin = "1 1",
AnchorMax = "1 1",
OffsetMin = $"{-10} {-7}",
OffsetMax = $"{0} {3}"
},
Button =
{
Command = $"uiskinmenu setdefault {weapon} {tSkinsList.ToList()[i].Key} {page} {itemId}",
Color = HexToRustFormat("#fb4f3b"),
Sprite = "assets/icons/power.png"
},
Text = { Text = "" }
}, Layer + "-Izbranoe" + i);
}
CuiHelper.AddUi(player, cont);
}
private void LoadWearUI(BasePlayer player)
{
CuiHelper.DestroyUi(player, Layer + "-Wear");
var cont = new CuiElementContainer();
cont.Add(new CuiPanel()
{
Image =
{
Color = "0 0 0 0"
},
RectTransform =
{
AnchorMin = "0.5 0",
AnchorMax = "0.5 0",
OffsetMin = $"{-588} {115}",
OffsetMax = $"{-215} {169}"
}
}, "Overlay", Layer + "-Wear");
for (var i = 0; i < player.inventory.containerWear.capacity - 1; i++)
{
var item = player.inventory.containerWear.GetSlot(i);
if (item == null)
{
cont.Add(new CuiElement()
{
Parent = Layer + "-Wear",
Components =
{
new CuiRawImageComponent()
{
Png = GetImage($"LSKINGRID({Version})"),
Color = "1 1 1 0.05"
},
new CuiRectTransformComponent()
{
AnchorMin =
$"0 0",
AnchorMax =
$"0 0",
OffsetMin = $"{0 + i * 54 - Math.Floor((double)i / 7) * 7 * 54} {0}",
OffsetMax = $"{50 + i * 54 - Math.Floor((double)i / 7) * 7 * 54} {50}"
}
}
});
continue;
}
var onblacklist = Cfg.blackList.Contains((long)item.skin);
var shortname = item.info.isRedirectOf ? item.info.isRedirectOf.shortname : item.info.shortname;
var skinsExsist = Interface.Oxide.DataFileSystem.ExistsDatafile($"LSystem/LSkins/Skins/{shortname}");
if (!onblacklist && skinsExsist)
cont.Add(new CuiButton()
{
Button =
{
Color = "0.65 0.65 0.65 0",
Command = $"uiskinmenu weaponSelect {shortname} {item.uid}"
},
Text =
{
Text = ""
},
RectTransform =
{
AnchorMin =
$"0 0",
AnchorMax =
$"0 0",
OffsetMin = $"{0 + i * 54 - Math.Floor((double)i / 7) * 7 * 54} {0}",
OffsetMax = $"{50 + i * 54 - Math.Floor((double)i / 7) * 7 * 54} {50}"
}
}, Layer + "-Wear");
else
cont.Add(new CuiElement()
{
Parent = Layer + "-Wear",
Components =
{
new CuiRawImageComponent()
{
Png = GetImage($"LSKINGRID({Version})"),
Color = "1 1 1 0.05"
},
new CuiRectTransformComponent()
{
AnchorMin =
$"0 0",
AnchorMax =
$"0 0",
OffsetMin = $"{0 + i * 54 - Math.Floor((double)i / 7) * 7 * 54} {0}",
OffsetMax = $"{50 + i * 54 - Math.Floor((double)i / 7) * 7 * 54} {50}"
}
}
});
}
CuiHelper.AddUi(player, cont);
}
private void LoadMainUI(BasePlayer player)
{
CuiHelper.DestroyUi(player, Layer + "-Main");
var cont = new CuiElementContainer();
cont.Add(new CuiPanel()
{
Image =
{
Color = "0 0 0 0"
},
RectTransform =
{
AnchorMin = $"{0.5} {0}",
AnchorMax = $"{0.5} {0}",
OffsetMin = $"{-200} {85}",
OffsetMax = $"{180} {337}"
}
}, "Overlay", Layer + "-Main");
for (var i = 0; i < player.inventory.containerMain.capacity; i++)
{
var item = player.inventory.containerMain.GetSlot(i);
if (item == null)
{
cont.Add(new CuiElement()
{
Parent = Layer + "-Main",
Components =
{
new CuiRawImageComponent()
{
Png = GetImage($"LSKINGRID({Version})"),
Color = "1 1 1 0.05"
},
new CuiRectTransformComponent()
{
AnchorMin =
$"0 1",
AnchorMax =
$"0 1",
OffsetMin =
$"{0 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {-60 - Math.Floor((double)i / 6) * 63.5}",
OffsetMax =
$"{60 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {0 - Math.Floor((double)i / 6) * 63.5}"
}
}
});
continue;
}
var onblacklist = Cfg.blackList.Contains((long)item.skin);
var shortname = item.info.isRedirectOf ? item.info.isRedirectOf.shortname : item.info.shortname;
var skinsExsist = Interface.Oxide.DataFileSystem.ExistsDatafile($"LSystem/LSkins/Skins/{shortname}");
if (!onblacklist && skinsExsist)
cont.Add(new CuiButton()
{
Button =
{
Color = "0.65 0.65 0.65 0",
Command = $"uiskinmenu weaponSelect {shortname} {item.uid}"
},
Text =
{
Text = ""
},
RectTransform =
{
AnchorMin =
$"0 1",
AnchorMax =
$"0 1",
OffsetMin =
$"{0 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {-60 - Math.Floor((double)i / 6) * 63}",
OffsetMax =
$"{60 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {0 - Math.Floor((double)i / 6) * 63}"
}
}, Layer + "-Main");
else
cont.Add(new CuiElement()
{
Parent = Layer + "-Main",
Components =
{
new CuiRawImageComponent()
{
Png = GetImage($"LSKINGRID({Version})"),
Color = "1 1 1 0.05"
},
new CuiRectTransformComponent()
{
AnchorMin =
$"0 1",
AnchorMax =
$"0 1",
OffsetMin =
$"{0 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {-60 - Math.Floor((double)i / 6) * 63}",
OffsetMax =
$"{60 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {0 - Math.Floor((double)i / 6) * 63.5}"
}
}
});
}
CuiHelper.AddUi(player, cont);
}
private void LoadBeltUI(BasePlayer player)
{
CuiHelper.DestroyUi(player, Layer + "-Belt");
var cont = new CuiElementContainer();
cont.Add(new CuiPanel()
{
Image =
{
Color = "0 0 0 0"
},
RectTransform =
{
AnchorMin = "0.5 0",
AnchorMax = "0.5 0",
OffsetMin = $"{-200} {17}",
OffsetMax = $"{180} {79}"
}
}, "Overlay", Layer + "-Belt");
for (var i = 0; i < 6; i++)
{
var item = player.inventory.containerBelt.GetSlot(i);
if (item == null)
{
cont.Add(new CuiElement()
{
Parent = Layer + "-Belt",
Components =
{
new CuiRawImageComponent()
{
Png = GetImage($"LSKINGRID({Version})"),
Color = "1 1 1 0.05"
},
new CuiRectTransformComponent()
{
AnchorMin =
$"0 0",
AnchorMax =
$"0 0",
OffsetMin = $"{0 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {0}",
OffsetMax = $"{60 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {60}"
}
}
});
continue;
}
var onblacklist = Cfg.blackList.Contains((long)item.skin);
var shortname = item.info.isRedirectOf ? item.info.isRedirectOf.shortname : item.info.shortname;
var skinsExsist = Interface.Oxide.DataFileSystem.ExistsDatafile($"LSystem/LSkins/Skins/{shortname}");
if (!onblacklist && skinsExsist)
cont.Add(new CuiButton()
{
Button =
{
Color = "0.65 0.65 0.65 0",
Command = $"uiskinmenu weaponSelect {shortname} {item.uid}"
},
Text =
{
Text = ""
},
RectTransform =
{
AnchorMin =
$"0 0",
AnchorMax =
$"0 0",
OffsetMin = $"{0 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {0}",
OffsetMax = $"{60 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {60}"
}
}, Layer + "-Belt");
else
cont.Add(new CuiElement()
{
Parent = Layer + "-Belt",
Components =
{
new CuiRawImageComponent()
{
Png = GetImage($"LSKINGRID({Version})"),
Color = "1 1 1 0.05"
},
new CuiRectTransformComponent()
{
AnchorMin =
$"0 0",
AnchorMax =
$"0 0",
OffsetMin = $"{0 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {0}",
OffsetMax = $"{60 + i * 64 - Math.Floor((double)i / 6) * 6 * 64} {60}"
}
}
});
}
CuiHelper.AddUi(player, cont);
}
[ConsoleCommand("uiskinmenu")]
private void ConsoleCommand(ConsoleSystem.Arg arg)
{
if (arg.Args == null || arg.Args.Length < 1) return;
var player = arg.Player();
if (player == null) return;
var sound1 = new Effect("assets/bundled/prefabs/fx/notice/loot.drag.grab.fx.prefab", player, 0, new Vector3(),
new Vector3());
string weapon;
long skinId;
int page;
int itemId;
DataPlayer weapons;
string uid;
string search;
string shortName;
switch (arg.GetString(0))
{
case "addinset":
EffectNetwork.Send(sound1, player.Connection);
if (!_playerData.TryGetValue(player.userID, out weapons)) return;
weapon = arg.GetString(1);
skinId = arg.GetLong(2);
page = arg.GetInt(3);
itemId = arg.GetInt(4);
if (weapons.SelectedSet != null &&
weapons.PlayerSets.TryGetValue((int)weapons.SelectedSet, out var set))
{
if (set._skins.TryGetValue(weapon, out var skin) && skin.skinId == skinId)
set._skins.Remove(weapon);
else
set._skins[weapon] = new SetSkins()
{
skinId = skinId,
SkinInfo = _loadData[weapon][skinId]
};
}
LoadSkinsUI(player, weapon, page, (uint)itemId);
LoadIzbranoeUI(player, weapon, (uint)itemId, page);
LoadSets(player);
break;
case "selectset":
EffectNetwork.Send(sound1, player.Connection);
if (!_playerData.TryGetValue(player.userID, out weapons)) return;
var setId = int.Parse(arg.Args[1]);
if (!weapons.PlayerSets.TryGetValue(setId, out set))
return;
weapons.SelectedSet = setId;
LoadSets(player);
var getItems = Facepunch.Pool.Get<List<Item>>();
player.inventory.GetAllItems(getItems);
foreach (var item1 in getItems)
{
shortName = item1.info.isRedirectOf != null
? item1.info.isRedirectOf.shortname
: item1.info.shortname;
if (set._skins.TryGetValue(shortName, out var skin))
UpdateItemIsSet(player, item1.parent, shortName, item1, skin);
}
break;
case "createset":
EffectNetwork.Send(sound1, player.Connection);
if (!_playerData.TryGetValue(player.userID, out weapons)) return;
weapons.PlayerSets.Add(weapons.PlayerSets.Count + 1, new DataPlayer.Sets());
weapons.SelectedSet = weapons.PlayerSets.Count;
LoadSets(player);
break;
case "search":
if (arg.Args.Length < 5)
{
EffectNetwork.Send(sound1, player.Connection);
LoadSkinsUI(player, arg.GetString(1), 1, arg.GetUInt(2), arg.GetBool(3));
return;
}
EffectNetwork.Send(sound1, player.Connection);
LoadSkinsUI(player, arg.GetString(1), 1, arg.GetUInt(2), arg.GetBool(3), arg.GetString(4));
break;
case "page":
EffectNetwork.Send(sound1, player.Connection);
int side = 0;
if (arg.Args.Length > 5)
side = arg.GetInt(5);
LoadSkinsUI(player, arg.GetString(1), arg.Args[2].ToInt(), arg.GetUInt(3), arg.GetBool(4), side: side);
LoadIzbranoeUI(player, arg.GetString(1), arg.GetUInt(3), arg.Args[2].ToInt(),
arg.GetBool(4), side: side);
break;
case "weaponSelect":
EffectNetwork.Send(sound1, player.Connection);
LoadSkinsUI(player, arg.GetString(1), 1, arg.GetUInt(2));
LoadIzbranoeUI(player, arg.GetString(1), arg.GetUInt(2), 1);
break;
case "setizbranoe":
EffectNetwork.Send(sound1, player.Connection);
if (!_playerData.TryGetValue(player.userID, out weapons)) return;
weapon = arg.GetString(1);
skinId = arg.GetLong(2);
page = arg.Args[3].ToInt();
itemId = arg.Args[4].ToInt();
if (weapons._izvSkins.ContainsKey(weapon) && weapons._izvSkins[weapon].ContainsKey((long)skinId))
weapons._izvSkins[weapon].Remove((long)skinId);
else if (weapons._izvSkins.ContainsKey(weapon))
weapons._izvSkins[weapon].Add((long)skinId, _loadData[weapon][(long)skinId]);
else
weapons._izvSkins.Add(weapon, new Dictionary<long, ItemData.SkinInfo>()
{
[(long)skinId] = _loadData[weapon][(long)skinId]
});
LoadSkinsUI(player, weapon, page, (uint)itemId);
LoadIzbranoeUI(player, weapon, (uint)itemId, page);
break;
case "setdefault":
EffectNetwork.Send(sound1, player.Connection);
if (!_playerData.TryGetValue(player.userID, out weapons)) return;
weapon = arg.GetString(1);
skinId = long.Parse(arg.Args[2]);
page = arg.Args[3].ToInt();
itemId = arg.Args[4].ToInt();
if (weapons._defaultSkins.ContainsKey(weapon) && weapons._defaultSkins[weapon].skinId == (long)skinId)
{
weapons._defaultSkins.Remove(weapon);
}
else if (weapons._defaultSkins.ContainsKey(weapon))
{
weapons._defaultSkins[weapon].skinId = (long)skinId;
weapons._defaultSkins[weapon].SkinInfo = _loadData[weapon][(long)skinId];
}
else
{
weapons._defaultSkins.Add(weapon, new DefaultSkins()
{
skinId = (long)skinId,
SkinInfo = _loadData[weapon][(long)skinId]
});
}
LoadSkinsUI(player, weapon, page, (uint)itemId);
LoadIzbranoeUI(player, weapon, (uint)itemId, page);
break;
case "setskin":
EffectNetwork.Send(sound1, player.Connection);
if (Cfg.Market.IsEnabled && !permission.UserHasPermission(player.UserIDString, Cfg.canuse))
if (ChangeSkin(player) == false)
return;
uid = arg.GetString(1);
var item = player.inventory.FindItemByUID(new ItemId(ulong.Parse(uid)));
if (item == null)
{
StartInterface(player);
return;
}
var isRedirect = item.info.isRedirectOf != null;
shortName = isRedirect ? item.info.isRedirectOf.shortname : item.info.shortname;
var dataInfo = _loadData[shortName][long.Parse(arg.Args[2])];
search = arg.Args.Length >= 5 ? arg.GetString(4).Replace("\"", "")?.Replace("\"", "") : null;
if (dataInfo.IsItem)
{
var pos = item.position;
var container = item.GetRootContainer();
var amount = item.amount;
var condition = item.condition;
var ownerShip = item.ownershipShares ?? new List<ItemOwnershipShare>();
var ammo = 0;
ItemDefinition ammoType = null;
var itemHeld = item.GetHeldEntity();
if (itemHeld is BaseProjectile s1)
{
ammoType = s1.primaryMagazine.ammoType;
ammo = s1.primaryMagazine.contents;
}
var maxcondititon = item.maxCondition;
var contents = item.contents?.itemList.ToList() ?? new List<Item>();
var newitem = ItemManager.CreateByName(dataInfo.ShortName, 1);
newitem.amount = amount;
newitem.condition = condition;
newitem.maxConditio
// ... [Code preview truncated due to length. Full source in attached file] ...