C#:
using Rust;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using UnityEngine;
#region Changelogs and ToDo
/*==============================================================================================================
*
* 2.0.1 : - Added the vehicle.1mod.taxi.
* 2.0.2 : - Added Support for HumanNPC.
* - garage or garage ui commands both can be used.
* - Added chatmessage and permissions to use npc shops.
* - Tab buttons now are outside main UI screen.
* 2.0.3 : - Added option to use a backgroundimage true/false
* - Added Camper Module
* - Cleanup and regions
* - Repositioned the Modules in the UI (needs more work)
* - Fixed Closing UI on Module/Parts tabs when plugin reloads
* - Fixed Closing UI on Module/Parts tabs when player dies
* - Fixed Closing UI on Module/Parts tabs when player disconnects
* - Fixed Free UI Bannertext position if having the Free permission assigned.
* 2.0.4 - Patched using offsets to keep screen ratios and scaling
*
==============================================================================================================*/
#endregion
namespace Oxide.Plugins {
[Info("Garage", "Krungh Crow", "2.0.4")]
[Description("Spawn Modular cars and all parts")]
class Garage : CovalencePlugin {
[PluginReference]
Plugin ServerRewards, Kits, Economics , HumanNPC;
#region Variables
Dictionary<string, Timer> CoolDowns = new Dictionary<string, Timer>();
const string GarageUse_Perm = "garage.use";
const string NoCooldown_Perm = "garage.nocooldown";
const string NoCost_Perm = "garage.nocost";
const string NPC_Perm = "garage.usenpc";
bool UseNPCBool;
//car and Chassis prefabs
const string Chas2 = "assets/content/vehicles/modularcar/car_chassis_2module.entity.prefab";
const string Chas3 = "assets/content/vehicles/modularcar/car_chassis_3module.entity.prefab";
const string Chas4 = "assets/content/vehicles/modularcar/car_chassis_4module.entity.prefab";
const string Car2 = "assets/content/vehicles/modularcar/2module_car_spawned.entity.prefab";
const string Car3 = "assets/content/vehicles/modularcar/3module_car_spawned.entity.prefab";
const string Car4 = "assets/content/vehicles/modularcar/4module_car_spawned.entity.prefab";
#endregion
#region Configuration
void Init() {
if (!LoadConfigVariables()) {
Puts("Config file issue detected. Please delete file, or check syntax and fix.");
return;
}
permission.RegisterPermission(GarageUse_Perm, this);
permission.RegisterPermission(NoCooldown_Perm, this);
permission.RegisterPermission(NoCost_Perm, this);
permission.RegisterPermission(NPC_Perm, this);
UseNPCBool = configData.Npcs.UseNPC;
}
private ConfigData configData;
class ConfigData {
//general settings
public int Cooldown = 300;
public bool BuildingSpawn = false;
//currency req settings
[JsonProperty(PropertyName = "NPC Vendor settings")]
public NPC Npcs = new NPC();
[JsonProperty(PropertyName = "Use ServerRewards")]
public bool UseServerRewards {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Use Economics")]
public bool UseEconomics {
get;
set;
}
= true;
/*
[JsonProperty(PropertyName = "Use Currency")]
public bool UseCurrency { get; set; } = true;
[JsonProperty(PropertyName = "Currency (ItemID)")]
public int CurrencyItemID { get; set; } = -932201673;
[JsonProperty(PropertyName = "Currency (Item Shortname)")]
public string CurrencyItemName { get; set; } = "scrap";
*/
// text and button colors
[JsonProperty(PropertyName = "Garage shop Title")]
public string GarageTitle {
get;
set;
}
= "Garage By Krungh Crow";
[JsonProperty(PropertyName = "Garage Text color (RGBA)")]
public string GarageTextClr {
get;
set;
}
= "1 1 1 0.90";
[JsonProperty(PropertyName = "Button color (RGBA)")]
public string BtnClr {
get;
set;
}
= "0.2 0.6 0.86 0.90";
[JsonProperty(PropertyName = "Button text color (RGBA)")]
public string BtnTextClr {
get;
set;
}
= "1 1 1 0.90";
[JsonProperty(PropertyName = "Menu Button color (RGBA)")]
public string MenuBtnClr {
get;
set;
}
= "0.0 0.0 0.0 0.0";
[JsonProperty(PropertyName = "Close Button color (RGBA)")]
public string BtnCloseClr {
get;
set;
}
= "0.0 0.0 0.0 0.0";
[JsonProperty(PropertyName = "Close Button Text color (RGBA)")]
public string BtnCloseTextClr {
get;
set;
}
= "1 1 1 0.90";
[JsonProperty(PropertyName = "Button Lift color (RGBA)")]
public string BtnLiftClr {
get;
set;
}
= "0.2 0.6 0.86 0.90";
[JsonProperty(PropertyName = "Button Lift Text color (RGBA)")]
public string BtnLiftTextClr {
get;
set;
}
= "1 1 1 0.90";
// main background image url
[JsonProperty(PropertyName = "Use Background Image")]
public bool UseBackgroundImage {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Garage shop Background Image Url")]
public string BackgroundImage {
get;
set;
}
= "https://i.ibb.co/zbg5271/garageuibackground.png";
[JsonProperty(PropertyName = "Garage shop Background Transparancy (0-1)")]
public double BckgrndAlpha {
get;
set;
}
= 0.9;
// page button image url
[JsonProperty(PropertyName = "Main page button icon Image Url")]
public string MainPageIcon {
get;
set;
}
= "https://i.ibb.co/jzDbx1r/main-page.png";
[JsonProperty(PropertyName = "Modules page button icon Image Url")]
public string ModulesPageIcon {
get;
set;
}
= "https://i.ibb.co/NK94JF8/modules-empty-icon.png";
[JsonProperty(PropertyName = "Parts page button icon Image Url")]
public string PartsPageIcon {
get;
set;
}
= "https://i.ibb.co/9HJZn18/car-parts-empty-icon.png";
[JsonProperty(PropertyName = "Close button icon Image Url")]
public string ClosePageIcon {
get;
set;
}
= "https://i.ibb.co/x8t0Lq4/close-button.png";
// kits image icon url prices and ID's
[JsonProperty(PropertyName = "Kits text color (RGBA)")]
public string BtnTextKitClr {
get;
set;
}
= "1 1 1 0.90";
[JsonProperty(PropertyName = "Kit 1 (kit Title)")]
public string CarKitTitle1 {
get;
set;
}
= "Carkit 1 description";
[JsonProperty(PropertyName = "Kit 1 (Icon Url)")]
public string Kit1Image {
get;
set;
}
= "https://i.ibb.co/y8HH02h/carkitblack.png";
[JsonProperty(PropertyName = "Kit 1 (kit name ID)")]
public string Kit1Command {
get;
set;
}
= "car1";
[JsonProperty(PropertyName = "Kit 1 (Price)")]
public int CostKit1 {
get;
set;
}
= 0;
[JsonProperty(PropertyName = "Kit 2 (kit Title)")]
public string CarKitTitle2 {
get;
set;
}
= "Carkit 2 description";
[JsonProperty(PropertyName = "Kit 2 (Icon Url)")]
public string Kit2Image {
get;
set;
}
= "https://i.ibb.co/znytJJg/carkitblue.png";
[JsonProperty(PropertyName = "Kit 2 (kit name ID)")]
public string Kit2Command {
get;
set;
}
= "car2";
[JsonProperty(PropertyName = "Kit 2 (Price)")]
public int CostKit2 {
get;
set;
}
= 0;
[JsonProperty(PropertyName = "Kit 3 (kit Title)")]
public string CarKitTitle3 {
get;
set;
}
= "Carkit 3 description";
[JsonProperty(PropertyName = "Kit 3 (Icon Url)")]
public string Kit3Image {
get;
set;
}
= "https://i.ibb.co/wcRWGfv/carkityellow.png";
[JsonProperty(PropertyName = "Kit 3 (kit name ID)")]
public string Kit3Command {
get;
set;
}
= "car3";
[JsonProperty(PropertyName = "Kit 3 (Price)")]
public int CostKit3 {
get;
set;
}
= 0;
[JsonProperty(PropertyName = "Kit 4 (kit Title)")]
public string CarKitTitle4 {
get;
set;
}
= "Carkit 4 description";
[JsonProperty(PropertyName = "Kit 4 (Icon Url)")]
public string Kit4Image {
get;
set;
}
= "https://i.ibb.co/JBmNcC0/carkitpink.png";
[JsonProperty(PropertyName = "Kit 4 (kit name ID)")]
public string Kit4Command {
get;
set;
}
= "car4";
[JsonProperty(PropertyName = "Kit 4 (Price)")]
public int CostKit4 {
get;
set;
}
= 0;
[JsonProperty(PropertyName = "Kit 5 (kit Title)")]
public string CarKitTitle5 {
get;
set;
}
= "Carkit 5 description";
[JsonProperty(PropertyName = "Kit 5 (Icon Url)")]
public string Kit5Image {
get;
set;
}
= "https://i.ibb.co/R3SXcvY/carkitred.png";
[JsonProperty(PropertyName = "Kit 5 (kit name ID)")]
public string Kit5Command {
get;
set;
}
= "car5";
[JsonProperty(PropertyName = "Kit 5 (Price)")]
public int CostKit5 {
get;
set;
}
= 0;
[JsonProperty(PropertyName = "Kit 6 (kit Title)")]
public string CarKitTitle6 {
get;
set;
}
= "Carkit 6 description";
[JsonProperty(PropertyName = "Kit 6 (Icon Url)")]
public string Kit6Image {
get;
set;
}
= "https://i.ibb.co/Fs0VqDQ/carkitgreen.png";
[JsonProperty(PropertyName = "Kit 6 (kit name ID)")]
public string Kit6Command {
get;
set;
}
= "car6";
[JsonProperty(PropertyName = "Kit 6 (Price)")]
public int CostKit6 {
get;
set;
}
= 0;
//item prices and image cfg
[JsonProperty(PropertyName = "Lift (Icon Url)")]
public string LiftImage {
get;
set;
}
= "https://i.ibb.co/Sfd2kxH/modularcarlift.png";
[JsonProperty(PropertyName = "Lift (Button Text)")]
public string LiftBttnTXT {
get;
set;
}
= "Get A lift";
[JsonProperty(PropertyName = "lift (Price)")]
public int CostLift {
get;
set;
}
= 2500;
[JsonProperty(PropertyName = "Simple Cockpit (Image Url)")]
public string SimpleCockpitLogo {
get;
set;
}
= "https://i.ibb.co/tcg16yg/vehicle-1mod-cockpit.png";
[JsonProperty(PropertyName = "Simple Cockpit (Price)")]
public int CostModCockpit {
get;
set;
}
= 1000;
[JsonProperty(PropertyName = "Armored Cockpit (Image Url)")]
public string ArmoredCockpitLogo {
get;
set;
}
= "https://i.ibb.co/SPvDV9c/vehicle-1mod-cockpit-armored.png";
[JsonProperty(PropertyName = "Armored Cockpit (Price)")]
public int CostModCockpitArmored {
get;
set;
}
= 1500;
[JsonProperty(PropertyName = "Cockpit+Engine (Image Url)")]
public string EngineCockpitLogo {
get;
set;
}
= "https://i.ibb.co/TtLNz4G/vehicle-1mod-cockpit-with-engine.png";
[JsonProperty(PropertyName = "Cockpit+Engine (Price)")]
public int CostModCockpitEngine {
get;
set;
}
= 1250;
[JsonProperty(PropertyName = "Large Fuell Tank (Image Url)")]
public string LargeFuellTankLogo {
get;
set;
}
= "https://i.ibb.co/2YSbbRD/vehicle-2mod-fuel-tank.png";
[JsonProperty(PropertyName = "Large Fuelltank (Price)")]
public int CostModFuelltank {
get;
set;
}
= 1000;
[JsonProperty(PropertyName = "Engine (Image Url)")]
public string EngineLogo {
get;
set;
}
= "https://i.ibb.co/1dzkVVV/vehicle-1mod-engine.png";
[JsonProperty(PropertyName = "Engine (Price)")]
public int CostModEngine {
get;
set;
}
= 1250;
[JsonProperty(PropertyName = "Short Flatbed (Image Url)")]
public string ShortFlatbedLogo {
get;
set;
}
= "https://i.ibb.co/s62zLrg/vehicle-1mod-flatbed.png";
[JsonProperty(PropertyName = "Short Flatbed (Price)")]
public int CostSingleFlatbed {
get;
set;
}
= 1000;
[JsonProperty(PropertyName = "Long Flatbed (Image Url)")]
public string LongFlatbedLogo {
get;
set;
}
= "https://i.ibb.co/VNMpXtp/vehicle-2mod-flatbed.png";
[JsonProperty(PropertyName = "Long Flatbed (Price)")]
public int CostDualFlatbed {
get;
set;
}
= 1250;
[JsonProperty(PropertyName = "Passenger Module (Image Url)")]
public string PassengersLogo {
get;
set;
}
= "https://i.ibb.co/3cBtXSL/vehicle-2mod-passengers.png";
[JsonProperty(PropertyName = "Passenger Module (Price)")]
public int CostPassengers {
get;
set;
}
= 1500;
[JsonProperty(PropertyName = "Rear Seat (Image Url)")]
public string RearseatLogo {
get;
set;
}
= "https://i.ibb.co/KLJsdXQ/vehicle-1mod-rear-seats.png";
[JsonProperty(PropertyName = "Rear Seat (Price)")]
public int CostRearSeat {
get;
set;
}
= 1250;
[JsonProperty(PropertyName = "Storage Module Image Url")]
public string StorageLogo {
get;
set;
}
= "https://i.ibb.co/BN2qFzp/vehicle-1mod-storage.png";
[JsonProperty(PropertyName = "Storage Module (Price RP")]
public int CostStorage {
get;
set;
}
= 1500;
[JsonProperty(PropertyName = "Armored Passenger Module (Image Url)")]
public string ArmoredPassModuleLogo {
get;
set;
}
= "https://rustlabs.com/img/items180/vehicle.1mod.passengers.armored.png";
[JsonProperty(PropertyName = "Armored Passenger Module (Price)")]
public int CostModPassModuleArmored {
get;
set;
}
= 1500;
[JsonProperty(PropertyName = "Taxi Module (Image Url)")]
public string TaxiModuleLogo {
get;
set;
}
= "https://i.ibb.co/HCLzx2S/vehicle-1mod-taxi.png";
[JsonProperty(PropertyName = "Taxi Module (Price)")]
public int CostModTaxi {
get;
set;
}
= 1500;
[JsonProperty(PropertyName = "Camper Module (Image Url)")]
public string CamperModuleLogo {
get;
set;
}
= "https://i.ibb.co/kQN6XQC/vehicle-2mod-camper.png";
[JsonProperty(PropertyName = "Camper Module (Price)")]
public int CostModCamper {
get;
set;
}
= 2000;
[JsonProperty(PropertyName = "Pistons Icon Url")]
public string PistonImage {
get;
set;
}
= "https://i.ibb.co/2qh1Q0G/pistons.png";
[JsonProperty(PropertyName = "LQ Piston (Price)")]
public int CostLowPiston {
get;
set;
}
= 500;
[JsonProperty(PropertyName = "MQ Piston (Price)")]
public int CostMedPiston {
get;
set;
}
= 750;
[JsonProperty(PropertyName = "HQ Piston (Price)")]
public int CostHighPiston {
get;
set;
}
= 1000;
[JsonProperty(PropertyName = "Crankshafts Icon Url")]
public string CrankshaftImage {
get;
set;
}
= "https://i.ibb.co/THY34QF/cranks.png";
[JsonProperty(PropertyName = "LQ Crankshaft (Price)")]
public int CostLowCrank {
get;
set;
}
= 500;
[JsonProperty(PropertyName = "MQ Crankshaft (Price)")]
public int CostMedCrank {
get;
set;
}
= 750;
[JsonProperty(PropertyName = "HQ Crankshaft (Price)")]
public int CostHighCrank {
get;
set;
}
= 1000;
[JsonProperty(PropertyName = "Sparkplugs Icon Url")]
public string SparkplugImage {
get;
set;
}
= "https://i.ibb.co/YQ3g4sf/plugs.png";
[JsonProperty(PropertyName = "LQ Sparkplug (Price)")]
public int CostLowPlug {
get;
set;
}
= 500;
[JsonProperty(PropertyName = "MQ Sparkplug (Price)")]
public int CostMedPlug {
get;
set;
}
= 750;
[JsonProperty(PropertyName = "HQ Sparkplug (Price)")]
public int CostHighPlug {
get;
set;
}
= 1000;
[JsonProperty(PropertyName = "Valves Icon Url")]
public string ValvesImage {
get;
set;
}
= "https://i.ibb.co/qkYPV9R/valves.png";
[JsonProperty(PropertyName = "LQ Valve (Price)")]
public int CostLowValve {
get;
set;
}
= 500;
[JsonProperty(PropertyName = "MQ Valve (Price)")]
public int CostMedValve {
get;
set;
}
= 750;
[JsonProperty(PropertyName = "HQ Valve (Price)")]
public int CostHighValve {
get;
set;
}
= 1000;
[JsonProperty(PropertyName = "Carburetor Icon Url")]
public string CarbsImage {
get;
set;
}
= "https://i.ibb.co/Wk9yQqz/carbs.png";
[JsonProperty(PropertyName = "LQ Carburetor (Price)")]
public int CostLowCarb {
get;
set;
}
= 500;
[JsonProperty(PropertyName = "MQ Carburetor (Price)")]
public int CostMedCarb {
get;
set;
}
= 750;
[JsonProperty(PropertyName = "HQ Carburetor (Price)")]
public int CostHighCarb {
get;
set;
}
= 1000;
// car and chasis Settings
[JsonProperty(PropertyName = "Small Chassis (image Url)")]
public string Chas2Image {
get;
set;
}
= "https://i.ibb.co/VMbLdzN/chas2.png";
[JsonProperty(PropertyName = "Small Chassis (Price)")]
public int CostChas2 {
get;
set;
}
= 2500;
[JsonProperty(PropertyName = "Medium Chassis (image Url)")]
public string Chas3Image {
get;
set;
}
= "https://i.ibb.co/q0QRcqn/chas3.png";
[JsonProperty(PropertyName = "Medium Chassis (Price)")]
public int CostChas3 {
get;
set;
}
= 3500;
[JsonProperty(PropertyName = "Large Chassis (image Url)")]
public string Chas4Image {
get;
set;
}
= "https://i.ibb.co/164Fxxs/chas4.png";
[JsonProperty(PropertyName = "Large Chassis (Price)")]
public int CostChas4 {
get;
set;
}
= 4500;
[JsonProperty(PropertyName = "Small Car (image Url)")]
public string Car2Image {
get;
set;
}
= "https://i.ibb.co/Tk38DWd/howard-schechtman-car1.jpg";
[JsonProperty(PropertyName = "Small Car (Price)")]
public int CostCar2 {
get;
set;
}
= 5000;
[JsonProperty(PropertyName = "Nedium Car (image Url)")]
public string Car3Image {
get;
set;
}
= "https://i.ibb.co/vJWGtcw/howard-schechtman-car2.jpg";
[JsonProperty(PropertyName = "Medium Car (Price)")]
public int CostCar3 {
get;
set;
}
= 7500;
[JsonProperty(PropertyName = "Large Car (image Url)")]
public string Car4Image {
get;
set;
}
= "https://i.ibb.co/zXpDRht/howard-schechtman-car3.jpg";
[JsonProperty(PropertyName = "Large Car (Price)")]
public int CostCar4 {
get;
set;
}
= 10000;
}
class NPC {
[JsonProperty(PropertyName = "Use NPC shop")]
public bool UseNPC = false;
[JsonProperty(PropertyName = "NPC Id's")]
public List<string> NPCID = new List<string>();
}
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> {
["OnlyNPC"]
= "The garage is only available at the Garage NPC in Town", ["NoPermission"] = "You do not have permission to use that command!", ["InvalidInput"] = "Please enter a valid command!", ["IndoorsBlocked"] = "You cannot spawn indoors only outside!", ["Info"] = "\n\n/garage ui : to open the Garage Shop.\n/givelift to buy a lift directly", ["Cooldown"] = "You are still on a cooldown!", ["Lift"] = "You just recieved a lift!", ["BoughtSmallCar"] = "You just Bought a Small Car, Have fun!", ["BoughtMediumCar"] = "You just Bought a Medium Car, Have fun!", ["BoughtlargeCar"] = "You just Bought a Large Car, Have fun!", ["BoughtSmallChas"] = "You just Bought a Small Chassis, Have fun!", ["BoughtMediumChas"] = "You just Bought a Medium Chassis, Have fun!", ["BoughtlargeChas"] = "You just Bought a Large Chassis, Have fun!", ["FreeCar"] = "You just Got a free Car, Have fun!", ["FreeChas"] = "You just Got a free Chassis, Have fun!", ["Nokit"] = "No kit has been assigned!", ["ReceivedCockpit"] = "You just recieved a simple cockpit!", ["ReceivedCockpitArmored"] = "You just recieved a Armored Cockpit!", ["ReceivedCockpitEngine"] = "You just recieved a Cockpit with a Engine attached!", ["ReceivedFuelltank"] = "You just recieved a empty Large Fuelltank!", ["ReceivedEngine"] = "You just recieved a Engine Module!", ["ReceivedSingleFlatbed"] = "You just recieved a short Flatbed Module!", ["ReceivedDualFlatbed"] = "You just recieved a Long Flatbed Module!", ["ReceivedPassengers"] = "You just recieved a Passenger Module!", ["ReceivedRearseat"] = "You just recieved a Rear Seat Module!", ["ReceivedStoragemodule"] = "You just recieved a Storage Module!", ["ReceivedArmoredPasmodule"] = "You just recieved a Passengers Armored Module!", ["ReceivedTaximodule"] = "You just recieved a Taxi Module!", ["ReceivedCamper"] = "You just recieved a Camper Module!", ["ReceivedLowPart"] = "You just recieved a Low quality engine part!", ["ReceivedMedPart"] = "You just recieved a Medium quality engine part!", ["ReceivedHighPart"] = "You just recieved a High quality engine part!", ["Spawned"] = "You spawned a {0}!", ["NoBallance"] = "You Dont have enough points!", ["NotSet"] = "This currency is not set to true or not installed on this server!", ["Prefix"] = "<color=yellow>[Garage]</color> ", ["UIFreeBanner"] = "<color=green>For having Permission ,You get Items for Free</color> "
}
, this);
}
#endregion
#region Commands Main
[Command("garage")]
private void Spawn(IPlayer player, string command, string[] args) {
if (player.IsServer) {
return;
}
string prefix = lang.GetMessage("Prefix", this, player.Id);
string infos = lang.GetMessage("Info", this, player.Id);
if (args.Length < 1) {
if (permission.UserHasPermission(player.Id, GarageUse_Perm)) {
GarageUI(player.Object as BasePlayer);
return;
}
else {
player.Message(prefix + lang.GetMessage("OnlyNPC", this, player.Id));
return;
}
}
switch (args[0]) {
case "ui" : {
if (permission.UserHasPermission(player.Id, GarageUse_Perm)) {
GarageUI(player.Object as BasePlayer);
break;
}
else {
player.Message(prefix + lang.GetMessage("OnlyNPC", this, player.Id));
break;
}
}
case "info" : {
player.Reply(prefix + lang.GetMessage("Version : V" + this.Version.ToString() + " By : " + this.Author.ToString(), this, player.Id) + infos);
break;
}
default : player.Reply(prefix + lang.GetMessage("InvalidInput", this, player.Id));
break;
}
}
#endregion
#region CUI
#region UI Close
void Unload() {
foreach (BasePlayer player in BasePlayer.activePlayerList) {
DestroyMenu(player);
DestroyMenu1(player);
DestroyMenu2(player);
}
}
void OnPlayerDisconnected(BasePlayer player) {
DestroyMenu(player);
DestroyMenu1(player);
DestroyMenu2(player);
}
void OnPlayerDeath(BasePlayer player, HitInfo info) {
DestroyMenu(player);
DestroyMenu1(player);
DestroyMenu2(player);
}
void DestroyMenu(BasePlayer player)=> CuiHelper.DestroyUi(player, "GarageUI");
void DestroyMenu1(BasePlayer player)=> CuiHelper.DestroyUi(player, "GarageUI1");
void DestroyMenu2(BasePlayer player)=> CuiHelper.DestroyUi(player, "GarageUI2");
#endregion
#region Main page
void GarageUI(BasePlayer player) {
DestroyMenu(player);
var elements = new CuiElementContainer();
var mainName = elements.Add(new CuiPanel {
Image = {
Color = $"0.1 0.1 0.1 0.2", Material = "assets/content/ui/uibackgroundblur.mat"
}
, RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = $"-450 -255", OffsetMax = $"450 275"
}
, CursorEnabled = true, FadeOut = 0.1f
}
, "Overlay", "GarageUI");
if (configData.UseBackgroundImage == true) {
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.BackgroundImage}", Color = string.Format($"1 1 1 {configData.BckgrndAlpha}"), FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = $"0 0", AnchorMax = $"1 1"
}
}
}
);
}
elements.Add(new CuiLabel {
Text = {
Text = $"{configData.GarageTitle}", Color = $"{configData.GarageTextClr}", FontSize = 18, Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0 0.95", AnchorMax = "1 1"
}
}
, mainName);
// cars and chasis Small
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Chas2Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.075 0.700", AnchorMax = "0.175 0.875"
}
}
}
);
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Car2Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.525 0.700", AnchorMax = "0.625 0.875"
}
}
}
);
elements.Add(new CuiButton {
Button = {
Command = "GiveChas2", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.075 0.600", AnchorMax = "0.175 0.675"
}
, Text = {
Text = $"Small Chassis\nOccasion for ${configData.CostChas2}", Color = $"{configData.BtnTextClr}", FontSize = 11, Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "Givecar2", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.525 0.600", AnchorMax = "0.625 0.675"
}
, Text = {
Text = $"Small Car\nOccasion for ${configData.CostCar2}", Color = $"{configData.BtnTextClr}", FontSize = 11, Align = TextAnchor.MiddleCenter
}
}
, mainName);
//cars and chassis Medium
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Chas3Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.225 0.700", AnchorMax = "0.325 0.875"
}
}
}
);
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Car3Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.675 0.700", AnchorMax = "0.775 0.875"
}
}
}
);
elements.Add(new CuiButton {
Button = {
Command = "GiveChas3", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.225 0.600", AnchorMax = "0.325 0.675"
}
, Text = {
Text = $"Medium Chassis\nOccasion for ${configData.CostChas3}", Color = $"{configData.BtnTextClr}", FontSize = 11, Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "Givecar3", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.675 0.600", AnchorMax = "0.775 0.675"
}
, Text = {
Text = $"Medium Car\nOccasion for ${configData.CostCar3}", Color = $"{configData.BtnTextClr}", FontSize = 11, Align = TextAnchor.MiddleCenter
}
}
, mainName);
//cars and chassis Large
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Chas4Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.375 0.700", AnchorMax = "0.475 0.875"
}
}
}
);
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Car4Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.825 0.700", AnchorMax = "0.925 0.875"
}
}
}
);
elements.Add(new CuiButton {
Button = {
Command = "GiveChas4", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.375 0.600", AnchorMax = "0.475 0.675"
}
, Text = {
Text = $"Large Chassis\nOccasion for ${configData.CostChas4}", Color = $"{configData.BtnTextClr}", FontSize = 11, Align = TextAnchor.MiddleCenter
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "Givecar4", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.825 0.600", AnchorMax = "0.925 0.675"
}
, Text = {
Text = $"Large Car\nOccasion for ${configData.CostCar4}", Color = $"{configData.BtnTextClr}", FontSize = 11, Align = TextAnchor.MiddleCenter
}
}
, mainName);
// kit 1
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Kit1Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.075 0.175", AnchorMax = "0.175 0.375"
}
}
}
);
elements.Add(new CuiLabel {
Text = {
Text = $"{configData.CarKitTitle1}", Color = "1 1 1 0.90", FontSize = 12, Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.075 0.175", AnchorMax = "0.175 0.225"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "CarKit1", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.075 0.125", AnchorMax = "0.175 0.175"
}
, Text = {
Text = $"Get for ${configData.CostKit1}", Color = $"{configData.BtnTextKitClr}", FontSize = 14, Align = TextAnchor.MiddleCenter
}
}
, mainName);
//kit 2
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Kit2Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.225 0.175", AnchorMax = "0.325 0.375"
}
}
}
);
elements.Add(new CuiLabel {
Text = {
Text = $"{configData.CarKitTitle2}", Color = "1 1 1 0.90", FontSize = 12, Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.225 0.175", AnchorMax = "0.325 0.225"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "CarKit2", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.225 0.125", AnchorMax = "0.325 0.175"
}
, Text = {
Text = $"Get for ${configData.CostKit2}", Color = $"{configData.BtnTextKitClr}", FontSize = 14, Align = TextAnchor.MiddleCenter
}
}
, mainName);
//kit 3
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Kit3Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.375 0.175", AnchorMax = "0.475 0.375"
}
}
}
);
elements.Add(new CuiLabel {
Text = {
Text = $"{configData.CarKitTitle3}", Color = "1 1 1 0.90", FontSize = 12, Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.375 0.175", AnchorMax = "0.475 0.225"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "CarKit3", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.375 0.125", AnchorMax = "0.475 0.175"
}
, Text = {
Text = $"Get for ${configData.CostKit3}", Color = $"{configData.BtnTextKitClr}", FontSize = 14, Align = TextAnchor.MiddleCenter
}
}
, mainName);
//kit 4
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Kit4Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.525 0.175", AnchorMax = "0.625 0.375"
}
}
}
);
elements.Add(new CuiLabel {
Text = {
Text = $"{configData.CarKitTitle4}", Color = "1 1 1 0.90", FontSize = 12, Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.525 0.175", AnchorMax = "0.625 0.225"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "CarKit4", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.525 0.125", AnchorMax = "0.625 0.175"
}
, Text = {
Text = $"Get for ${configData.CostKit4}", Color = $"{configData.BtnTextKitClr}", FontSize = 14, Align = TextAnchor.MiddleCenter
}
}
, mainName);
//kit 5
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Kit5Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.675 0.175", AnchorMax = "0.775 0.375"
}
}
}
);
elements.Add(new CuiLabel {
Text = {
Text = $"{configData.CarKitTitle5}", Color = "1 1 1 0.90", FontSize = 12, Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.675 0.175", AnchorMax = "0.775 0.225"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "CarKit5", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.675 0.125", AnchorMax = "0.775 0.175"
}
, Text = {
Text = $"Get for ${configData.CostKit5}", Color = $"{configData.BtnTextKitClr}", FontSize = 14, Align = TextAnchor.MiddleCenter
}
}
, mainName);
//kit 6
elements.Add(new CuiElement {
Parent = "GarageUI", Components = {
new CuiRawImageComponent {
Url = $"{configData.Kit6Image}", FadeIn = 0f
}
, new CuiRectTransformComponent {
AnchorMin = "0.825 0.175", AnchorMax = "0.925 0.375"
}
}
}
);
elements.Add(new CuiLabel {
Text = {
Text = $"{configData.CarKitTitle6}", Color = "1 1 1 0.90", FontSize = 12, Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0.825 0.175", AnchorMax = "0.925 0.225"
}
}
, mainName);
elements.Add(new CuiButton {
Button = {
Command = "CarKit6", Color = $"{configData.BtnClr}"
}
, RectTransform = {
AnchorMin = "0.825 0.125", AnchorMax = "0.925 0.175"
}
, Text = {
Text = $"Get for ${configData.CostKit6}", Color = $"{configData.BtnTextKitClr}", FontSize = 14, Align = TextAnchor.MiddleCenter
}
}
, mainName);
// Welcome player message
elements.Add(new CuiLabel {
Text = {
Text = $"welcome {player.displayName}", Color = $"{configData.GarageTextClr}", FontSize = 18 , Align = TextAnchor.MiddleCenter
}
, RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 0
// ... [Code preview truncated due to length. Full source in attached file] ...