C#:
using Newtonsoft.Json;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Configuration;
using Oxide.Core.Plugins;
using Rust;
using Facepunch;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Linq;
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;
using Oxide.Core;
#region Changelogs and Todo
/**********************************************************************
*
* 1.0.0 : - Initial release
* 1.0.1 : - Added HumanNPC support
* - Added perms for shop or npc useage
* - Added NPC responce message in language file
* 1.0.2 : - Added various text color options
* - Added Font type option
* 1.0.3 : - fix Item amount minimum check.
* - Added Internal Skin.ID check if custom bone name is removed.
* 1.1.0 : - Added check for server to be fully initialised to set values
* - Updated and added messages in the language file
* - When the players inventory is full the Tradeitem will drop on the floor
* - When the players inventory is full a warning is displayed in the UI
* - Code cleanup
* - Fixed handout amounts
* 1.1.1 - Fix for random serversave nre
* 1.2.0 - Fix for OnServerSave Patched by Mabel
* 1.2.1 - Patched for Rust oct update
* 1.3.0 - Adressed serversave issue
* - Added feline/snake/crocodile bones
* - Added SkinID to the cfg incase of custom skins
* - Rewrote the handout functions to be more universal
* - Rewrote the amounts from inv check
*
**********************************************************************/
#endregion
namespace Oxide.Plugins {
[Info("BoneMarket", "Krungh Crow", "1.3.0")]
[Description("Trade market for animal bones")]
class BoneMarket : CovalencePlugin {
[PluginReference("HumanNPC")]
Plugin HumanNPC, FishR, SkinAndBones;
#region Variables
const string Shop_Perm = "bonemarket.useshop";
const string NPC_Perm = "bonemarket.usenpc";
bool IsReady;
DynamicConfigFile _BonePrices = Interface.Oxide.DataFileSystem.GetDatafile("BoneMarket_Prices");
public float MarketRefreshTime = 7.0f;
Timer RefreshTimer;
int NeededAmount;
int BearBoneValue;
int BoarBoneValue;
int ChickenBoneValue;
int FishBoneValue;
int HorseBoneValue;
int StagBoneValue;
int WolfBoneValue;
int FelineBoneValue;
int CrocBoneValue;
int SnakeBoneValue;
string TIDName;
string TItem;
string prefix;
bool UseNPCBool;
string _Font;
string _BoneTXTColor;
#endregion
void OnServerInitialized(bool initial) {
if (initial) {
IsReady = false;
CheckInit();
return;
}
IsReady = true;
if (IsReady) {
SetPrices();
MarketRefreshTimer();
Puts("Server is Ready for Market values");
}
}
#region Configuration
void Init() {
if (!LoadConfigVariables()) {
Puts("Config file issue detected. Please delete file, or check syntax and fix.");
return;
}
MarketRefreshTime = configData.Refreshtime;
RefreshValues();
TIDName = configData.TradeItemName;
TItem = configData.TradeItem;
UseNPCBool = configData.Npcs.UseNPC;
permission.RegisterPermission(Shop_Perm, this);
permission.RegisterPermission(NPC_Perm, this);
prefix = configData.Prefix;
_Font = configData.UISettings.Font;
_BoneTXTColor = configData.UISettings.BoneItemColor;
}
private ConfigData configData;
class ConfigData {
[JsonProperty(PropertyName = "Chat Prefix")]
public string Prefix = "[<color=#4A95CC>Bone Market</color>] : ";
[JsonProperty(PropertyName = "NPC Vendor settings")]
public NPC Npcs = new NPC();
[JsonProperty(PropertyName = "Skin settings")]
public Skinsettings Skins = new Skinsettings();
[JsonProperty(PropertyName = "UI Settings")]
public UISettings UISettings = new UISettings();
[JsonProperty(PropertyName = "Market refresh time (gameday)")]
public float Refreshtime = 7.0f;
[JsonProperty(PropertyName = "Market Trade item (shortname)")]
public string TradeItem = "scrap";
[JsonProperty(PropertyName = "Market Trade item (View name in GUI)")]
public string TradeItemName = "Scrap";
[JsonProperty(PropertyName = "Market Unit Value")]
public Prices Prices = new Prices();
}
class NPC {
[JsonProperty(PropertyName = "Use NPC shop")]
public bool UseNPC = false;
[JsonProperty(PropertyName = "NPC Id's")]
public List<string> NPCID = new List<string>();
}
class Skinsettings {
[JsonProperty(PropertyName = "Bear SkinID")]
public ulong Bear = 2582006231;
[JsonProperty(PropertyName = "Boar SkinID")]
public ulong Boar = 2582018117;
[JsonProperty(PropertyName = "Chicken SkinID")]
public ulong Chicken = 2582002045;
[JsonProperty(PropertyName = "Crocodile SkinID")]
public ulong Croc = 3531046639;
[JsonProperty(PropertyName = "Feline SkinID")]
public ulong Feline = 3531044884;
[JsonProperty(PropertyName = "Fish SkinID")]
public ulong Fish = 2583801321;
[JsonProperty(PropertyName = "Horse SkinID")]
public ulong Horse = 2582022311;
[JsonProperty(PropertyName = "Snake SkinID")]
public ulong Snake = 3531103631;
[JsonProperty(PropertyName = "Stag SkinID")]
public ulong Stag = 2582020463;
[JsonProperty(PropertyName = "Wolf SkinID")]
public ulong wolf = 2582021640;
}
class UISettings {
[JsonProperty(PropertyName = "Font to use")]
public string Font = "permanentmarker.ttf";
[JsonProperty(PropertyName = "Market Title")]
public string Title = "Bone Market";
[JsonProperty(PropertyName = "Market Title Color (RGBA)")]
public string TitleColor = "0.5 1 1 0.90";
[JsonProperty(PropertyName = "Market Description")]
public string Description = "Trade market for hunters\nTrade your Bones right here !!!";
[JsonProperty(PropertyName = "Market Description Color (RGBA)")]
public string DescriptionColor = "1 1 1 0.90";
[JsonProperty(PropertyName = "Bone item text Color (RGBA)")]
public string BoneItemColor = "0.5 1 1 0.90";
[JsonProperty(PropertyName = "Use a background image")]
public bool UseBackgroundImage = true;
[JsonProperty(PropertyName = "Background Image link")]
public string BackgroundImageLink = "https://i.ibb.co/6NQmCgZ/Quail-Bird-Hunting-Silhouette-Free-Vector.jpg";
[JsonProperty(PropertyName = "Background Image transparency (0-1)")]
public float BackgroundImageAlpha = 0.2f;
}
class Prices {
[JsonProperty(PropertyName = "Bear bones Low value")]
public int BearBonePriceMin = 2;
[JsonProperty(PropertyName = "Bear bones High value")]
public int BearBonePrice = 6;
[JsonProperty(PropertyName = "Boar bones Low value")]
public int BoarBonePriceMin = 1;
[JsonProperty(PropertyName = "Boar bones High value")]
public int BoarBonePrice = 3;
[JsonProperty(PropertyName = "Chicken bones Low value")]
public int ChickenBonePriceMin = 1;
[JsonProperty(PropertyName = "Chicken bones High value")]
public int ChickenBonePrice = 3;
[JsonProperty(PropertyName = "Horse bones Low value")]
public int HorseBonePriceMin = 1;
[JsonProperty(PropertyName = "Horse bones High value")]
public int HorseBonePrice = 3;
[JsonProperty(PropertyName = "Fish bones Low value")]
public int FishBonePriceMin = 1;
[JsonProperty(PropertyName = "Fish bones High value")]
public int FishBonePrice = 3;
[JsonProperty(PropertyName = "Stag bones Low value")]
public int StagBonePriceMin = 1;
[JsonProperty(PropertyName = "Stag bones High value")]
public int StagBonePrice = 3;
[JsonProperty(PropertyName = "Wolf bones Low value")]
public int WolfBonePriceMin = 1;
[JsonProperty(PropertyName = "Wolf bones High value")]
public int WolfBonePrice = 4;
//new animals
[JsonProperty(PropertyName = "Crocodile bones Low value")]
public int CrocBonePriceMin = 1;
[JsonProperty(PropertyName = "Crocodile bones High value")]
public int CrocBonePrice = 5;
[JsonProperty(PropertyName = "Feline bones Low value")]
public int FelineBonePriceMin = 1;
[JsonProperty(PropertyName = "Feline bones High value")]
public int FelineBonePrice = 5;
[JsonProperty(PropertyName = "snake bones Low value")]
public int SnakeBonePriceMin = 1;
[JsonProperty(PropertyName = "snake bones High value")]
public int SnakeBonePrice = 5;
}
private bool LoadConfigVariables() {
try {
configData = Config.ReadObject<ConfigData>();
}
catch {
return false;
}
SaveConf();
return true;
}
protected override void LoadDefaultConfig() {
Puts("Creating new config file.");
configData = new ConfigData();
SaveConf();
}
void SaveConf() => Config.WriteObject(configData, true);
#endregion
#region LanguageAPI
protected override void LoadDefaultMessages() {
lang.RegisterMessages(new Dictionary<string, string> {
["FullInventory"]
= "Your inventory was full handout is dropped on the floor", ["FullInventoryUI"] = "Your Inventory is full handout will drop on the floor", ["Info"] = "\n\n<color=#4A95CC>Available Commands</color> :\n<color=#4A95CC>/bone info</color> : Shows info on version/author and commands\n<color=#4A95CC>/bone market</color> : Opens the market interface where prices change each gameday", ["InvalidInput"] = "Please enter a valid command!", ["OnlyNPC"] = "The Bone Market is only available at the Bone Trader NPC in Town", ["Succesfulltrade"] = "You traded your bones for {0} {1}", ["MarketReset"] = "Market started a new day with fresh trade prices.", ["NotFound"] = "You dont have any to trade", ["NotEnough"] = "You dont have enough bones for this trade",
}
, this);
}
#endregion
#region Commands
[Command("bone")]
private void Bone(IPlayer player, string command, string[] args) {
if (player.IsServer) {
return;
}
if (args.Length < 1) {
player.Message(msg("InvalidInput"));
return;
}
switch (args[0]) {
case "market" : {
if (permission.UserHasPermission(player.Id, Shop_Perm)) {
ASUI(player.Object as BasePlayer);
break;
}
else {
player.Message(msg("OnlyNPC"));
break;
}
}
case "info" : {
player.Reply(lang.GetMessage("Version : V" + this.Version.ToString() + " By : " + this.Author.ToString() + msginfo("Info") , this, player.Id));
break;
}
default : player.Reply(msg("InvalidInput"));
break;
}
}
[Command("BoneMarket")]
private void BoneUI(IPlayer player, string command, string[] args) {
if (permission.UserHasPermission(player.Id, Shop_Perm)) {
ASUI(player.Object as BasePlayer);
}
else {
player.Message(msg("OnlyNPC"));
}
}
#endregion
#region CUI
void Unload() {
foreach (BasePlayer player in BasePlayer.activePlayerList) DestroyMenu(player);
}
void OnPlayerDisconnected(BasePlayer player) => DestroyMenu(player);
void OnPlayerDeath(BasePlayer player, HitInfo info) => DestroyMenu(player);
void DestroyMenu(BasePlayer player) => CuiHelper.DestroyUi(player, "ASUI");
[Command("BMClose")]
private void BMClose(IPlayer player, string command, string[] args) {
if (player == null) return;
DestroyMenu(player.Object as BasePlayer);
}
void ASUI(BasePlayer player) {
DestroyMenu(player);
RefreshValues();
var elements = new CuiElementContainer();
var mainName = elements.Add(new CuiPanel {
Image = {
Color = $"0.1 0.1 0.1 0.4", Material = "assets/content/ui/uibackgroundblur.mat"
}
, RectTransform = {
AnchorMin = "0.3 0.2", AnchorMax = "0.7 0.8"
}
, CursorEnabled = true, FadeOut = 0.1f
}
, "Overlay", "ASUI");
var height = 0.7;
var heightlow = 0.66;
{
if (configData.UISettings.UseBackgroundImage == true) {
elements.Add(new CuiElement {
Parent = "ASUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.UISettings.BackgroundImageLink}", Color = string.Format($"1 1 1 {configData.UISettings.BackgroundImageAlpha}"), FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = $"0 0", AnchorMax = $"1 1"
}
}
}
);
}
elements.Add(new CuiLabel {
Text = {
Text = $"{configData.UISettings.Title}", Color = $"{configData.UISettings.TitleColor}", FontSize = 16, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0 0.90", AnchorMax = "1 1"
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"{configData.UISettings.Description}", Color = $"{configData.UISettings.DescriptionColor}", FontSize = 14, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0 0.75", AnchorMax = "1 1"
}
}
, mainName);
#region top titles
elements.Add(new CuiLabel {
Text = {
Text = $"Merchandise", Color = "1 1 1 0.90", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.0 0.66", AnchorMax = $"0.2 0.7"
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"Trade Units", Color = "1 1 1 0.90", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.205 0.66", AnchorMax = $"0.80 0.7"
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"Unit value (10)", Color = "1 1 1 0.90", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.805 0.66", AnchorMax = $"0.995 0.7"
}
}
, mainName);
#endregion
#region Bear Bones
height -= 00.05;
heightlow -= 0.05;
elements.Add(new CuiLabel {
Text = {
Text = $"Bear Bones", Color = $"{_BoneTXTColor}", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.0 {heightlow}", AnchorMax = $"0.2 {height}"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone bear 10", Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.205 {heightlow}", AnchorMax = $"0.40 {height}"
}
, Text = {
Text = "10", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone bear 100" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.405 {heightlow}", AnchorMax = $"0.60 {height}"
}
, Text = {
Text = "100", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone bear 1000" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.605 {heightlow}", AnchorMax = $"0.80 {height}"
}
, Text = {
Text = "1000", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"{_BonePrices["BearBonePrice"]} {TIDName}", Color = "1 1 1 0.90", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.805 {heightlow}", AnchorMax = $"0.995 {height}"
}
}
, mainName);
#endregion
#region Boar Bones
height -= 00.05;
heightlow -= 0.05;
elements.Add(new CuiLabel {
Text = {
Text = $"Boar Bones", Color = $"{_BoneTXTColor}", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.0 {heightlow}", AnchorMax = $"0.2 {height}"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone boar 10" + "", Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.205 {heightlow}", AnchorMax = $"0.40 {height}"
}
, Text = {
Text = "10", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone boar 100" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.405 {heightlow}", AnchorMax = $"0.60 {height}"
}
, Text = {
Text = "100", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone boar 1000" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.605 {heightlow}", AnchorMax = $"0.80 {height}"
}
, Text = {
Text = "1000", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"{_BonePrices["BoarBonePrice"]} {TIDName}", Color = "1 1 1 0.90", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.805 {heightlow}", AnchorMax = $"0.995 {height}"
}
}
, mainName);
#endregion
#region Chicken Bones
height -= 00.05;
heightlow -= 0.05;
elements.Add(new CuiLabel {
Text = {
Text = $"Chicken Bones", Color = $"{_BoneTXTColor}", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.0 {heightlow}", AnchorMax = $"0.2 {height}"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone chicken 10" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.205 {heightlow}", AnchorMax = $"0.40 {height}"
}
, Text = {
Text = "10", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone chicken 100" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.405 {heightlow}", AnchorMax = $"0.60 {height}"
}
, Text = {
Text = "100", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone chicken 1000" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.605 {heightlow}", AnchorMax = $"0.80 {height}"
}
, Text = {
Text = "1000", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"{_BonePrices["ChickenBonePrice"]} {TIDName}", Color = "1 1 1 0.90", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.805 {heightlow}", AnchorMax = $"0.995 {height}"
}
}
, mainName);
#endregion
#region Fish Bones
height -= 00.05;
heightlow -= 0.05;
elements.Add(new CuiLabel {
Text = {
Text = $"Fish Bones", Color = $"{_BoneTXTColor}", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.0 {heightlow}", AnchorMax = $"0.2 {height}"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone fish 10" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.205 {heightlow}", AnchorMax = $"0.40 {height}"
}
, Text = {
Text = "10", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone fish 100" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.405 {heightlow}", AnchorMax = $"0.60 {height}"
}
, Text = {
Text = "100", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone fish 1000" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.605 {heightlow}", AnchorMax = $"0.80 {height}"
}
, Text = {
Text = "1000", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"{_BonePrices["FishBonePrice"]} {TIDName}", Color = "1 1 1 0.90", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.805 {heightlow}", AnchorMax = $"0.995 {height}"
}
}
, mainName);
#endregion
#region Horse Bones
height -= 00.05;
heightlow -= 0.05;
elements.Add(new CuiLabel {
Text = {
Text = $"Horse Bones", Color = $"{_BoneTXTColor}", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.0 {heightlow}", AnchorMax = $"0.2 {height}"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone horse 10" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.205 {heightlow}", AnchorMax = $"0.40 {height}"
}
, Text = {
Text = "10", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone horse 100" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.405 {heightlow}", AnchorMax = $"0.60 {height}"
}
, Text = {
Text = "100", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone horse 1000" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.605 {heightlow}", AnchorMax = $"0.80 {height}"
}
, Text = {
Text = "1000", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"{_BonePrices["HorseBonePrice"]} {TIDName}", Color = "1 1 1 0.90", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.805 {heightlow}", AnchorMax = $"0.995 {height}"
}
}
, mainName);
#endregion
#region Stag Bones
height -= 00.05;
heightlow -= 0.05;
elements.Add(new CuiLabel {
Text = {
Text = $"Stag Bones", Color = $"{_BoneTXTColor}", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.0 {heightlow}", AnchorMax = $"0.2 {height}"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone stag 10" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.205 {heightlow}", AnchorMax = $"0.40 {height}"
}
, Text = {
Text = "10", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone stag 100" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.405 {heightlow}", AnchorMax = $"0.60 {height}"
}
, Text = {
Text = "100", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone stag 1000" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.605 {heightlow}", AnchorMax = $"0.80 {height}"
}
, Text = {
Text = "1000", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"{_BonePrices["StagBonePrice"]} {TIDName}", Color = "1 1 1 0.90", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.805 {heightlow}", AnchorMax = $"0.995 {height}"
}
}
, mainName);
#endregion
#region Wolf Bones
height -= 00.05;
heightlow -= 0.05;
elements.Add(new CuiLabel {
Text = {
Text = $"Wolf Bones", Color = $"{_BoneTXTColor}", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.0 {heightlow}", AnchorMax = $"0.2 {height}"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone wolf 10" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.205 {heightlow}", AnchorMax = $"0.40 {height}"
}
, Text = {
Text = "10", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone wolf 100" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.405 {heightlow}", AnchorMax = $"0.60 {height}"
}
, Text = {
Text = "100", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone wolf 1000" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.605 {heightlow}", AnchorMax = $"0.80 {height}"
}
, Text = {
Text = "1000", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"{_BonePrices["WolfBonePrice"]} {TIDName}", Color = "1 1 1 0.90", FontSize = 12, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.805 {heightlow}", AnchorMax = $"0.995 {height}"
}
}
, mainName);
#endregion
#region Crocodile Bones
height -= 00.05;
heightlow -= 0.05;
elements.Add(new CuiLabel {
Text = {
Text = $"Crocodile Bones" , Color = $"{_BoneTXTColor}" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.0 {heightlow}" , AnchorMax = $"0.2 {height}"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone croc 10" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.205 {heightlow}" , AnchorMax = $"0.40 {height}"
}
, Text = {
Text = "10" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone croc 100" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.405 {heightlow}" , AnchorMax = $"0.60 {height}"
}
, Text = {
Text = "100" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone croc 1000" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.605 {heightlow}" , AnchorMax = $"0.80 {height}"
}
, Text = {
Text = "1000" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"{_BonePrices["CrocBonePrice"]} {TIDName}" , Color = "1 1 1 0.90" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.805 {heightlow}" , AnchorMax = $"0.995 {height}"
}
}
, mainName);
#endregion
#region Feline Bones
height -= 00.05;
heightlow -= 0.05;
elements.Add(new CuiLabel {
Text = {
Text = $"Feline Bones" , Color = $"{_BoneTXTColor}" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.0 {heightlow}" , AnchorMax = $"0.2 {height}"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone feline 10" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.205 {heightlow}" , AnchorMax = $"0.40 {height}"
}
, Text = {
Text = "10" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone feline 100" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.405 {heightlow}" , AnchorMax = $"0.60 {height}"
}
, Text = {
Text = "100" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone feline 1000" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.605 {heightlow}" , AnchorMax = $"0.80 {height}"
}
, Text = {
Text = "1000" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"{_BonePrices["FelineBonePrice"]} {TIDName}" , Color = "1 1 1 0.90" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.805 {heightlow}" , AnchorMax = $"0.995 {height}"
}
}
, mainName);
#endregion
#region snake Bones
height -= 00.05;
heightlow -= 0.05;
elements.Add(new CuiLabel {
Text = {
Text = $"Snake Bones" , Color = $"{_BoneTXTColor}" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.0 {heightlow}" , AnchorMax = $"0.2 {height}"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone snake 10" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.205 {heightlow}" , AnchorMax = $"0.40 {height}"
}
, Text = {
Text = "10" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone snake 100" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.405 {heightlow}" , AnchorMax = $"0.60 {height}"
}
, Text = {
Text = "100" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "TradeBone snake 1000" , Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = $"0.605 {heightlow}" , AnchorMax = $"0.80 {height}"
}
, Text = {
Text = "1000" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiLabel {
Text = {
Text = $"{_BonePrices["SnakeBonePrice"]} {TIDName}" , Color = "1 1 1 0.90" , FontSize = 12 , Font = $"{_Font}" , Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = $"0.805 {heightlow}" , AnchorMax = $"0.995 {height}"
}
}
, mainName);
#endregion
#region Full Inventory
if (player.inventory.containerMain.IsFull()) {
elements.Add(new CuiLabel {
Text = {
Text = msg("FullInventoryUI"), Color = $"1 1 1 0.90", FontSize = 14, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.0 0.15", AnchorMax = "1.0 0.2"
}
}
, mainName);
}
#endregion
elements.Add(new CuiLabel {
Text = {
Text = $"{this.Name.ToString()} V{this.Version.ToString()} by Krungh Crow", Color = $"1 1 1 0.90", FontSize = 11, Font = $"{_Font}", Align = TextAnchor.MiddleRight
}
, RectTransform = {
AnchorMin = "0.60 0.0", AnchorMax = "0.99 0.05"
}
}
, mainName);
}
elements.Add(new CuiButton {
Button = {
Command = "BMClose", Color = "0 0 0 0.80"
}
, RectTransform = {
AnchorMin = "0.90 0.95", AnchorMax = "0.995 0.995"
}
, Text = {
Text = "close", FontSize = 15, Font = $"{_Font}", Align = TextAnchor.MiddleCenter
}
}
, mainName);
CuiHelper.AddUi(player, elements);
}
#endregion
#region Hooks
void CheckInit() //checks if server is fully initialised
{
timer.Once(10f, () => {
if (Rust.Application.isLoading) {
Puts($"[Debugging] Server still loading....");
CheckInit();
return;
}
IsReady = true;
Puts("Server is Ready for Market values.....");
}
);
}
void OnServerSave() {
if (server.Time != null && RefreshTimer != null && server.Time.TimeOfDay.Hours != MarketRefreshTime) {
RefreshTimer.Destroy();
MarketRefreshTimer();
Puts("Market refresh Check....");
return;
}
}
void OnUseNPC(BasePlayer npc, BasePlayer player, Vector3 destination) {
if (configData.Npcs.NPCID != null && configData.Npcs.NPCID.Contains(npc.UserIDString) && UseNPCBool) {
if (permission.UserHasPermission(player.UserIDString, NPC_Perm)) {
ASUI(player);
}
}
}
#endregion
#region Trades
private IEnumerable<Item> GetAllItems(BasePlayer player) {
return player.inventory.containerMain.itemList .Concat(player.inventory.containerBelt.itemList) .Concat(player.inventory.containerWear.itemList);
}
private void TradeTheItem(IPlayer player , int takeamount , Item item , int returnvalue) {
RefreshValues();
BasePlayer plyr = player.Object as BasePlayer;
var amount = returnvalue.ToString();
item.UseItem(takeamount);
Item TradeItem = ItemManager.CreateByName($"{TItem}" , returnvalue , 0);
if (plyr.inventory.containerMain.IsFull()) {
TradeItem.DropAndTossUpwards(plyr.transform.position);
Puts(amount);
player.Message(msg("FullInventory"));
return;
}
player.Message(msg("Succesfulltrade").Replace("{0}" , amount).Replace("{1}" , TItem));
plyr.inventory.GiveItem(TradeItem);
return;
}
[Command("TradeBone")]
private void TradeBone(IPlayer player , string command , string[] args) {
if (args.Length < 2 || !int.TryParse(args[1] , out int neededAmount) || neededAmount <= 0) {
player.Message("Usage: /TradeBone <snake|croc|feline|bear|boar|chicken|fish|horse|stag|wolf> <amount>");
return;
}
string boneType = args[0].ToLower();
BasePlayer plyr = player.Object as BasePlayer;
if (plyr =
// ... [Code preview truncated due to length. Full source in attached file] ...