C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
// Requires: ImageLibrary
using System.Collections.Generic;
using System;
using System.Linq;
using UnityEngine;
using Oxide.Core.Plugins;
using Oxide.Core.Configuration;
using Oxide.Game.Rust.Cui;
using Oxide.Core;
using System.Collections;
using System.IO;
using System.Text;
using Oxide.Core.Libraries.Covalence;
using System.Reflection;
namespace Oxide.Plugins {
[Info("AbsolutCombat", "Absolut", "2.2.0", ResourceId = 2103)]
class AbsolutCombat : RustPlugin {
#region Fields
[PluginReference]
Plugin EventManager;
[PluginReference]
Plugin ServerRewards;
[PluginReference]
Plugin Economics;
[PluginReference]
Plugin BetterChat;
[PluginReference]
ImageLibrary ImageLibrary;
Gear_Weapon_Data gwData;
private DynamicConfigFile GWData;
SavedPlayers playerData;
private DynamicConfigFile PlayerData;
string TitleColor = "<color=orange>";
string MsgColor = "<color=#A9A9A9>";
private Dictionary<ulong, Timer> PlayerGearSetTimer = new Dictionary<ulong, Timer>();
private Dictionary<ulong, Timer> PlayerWeaponSetTimer = new Dictionary<ulong, Timer>();
private Dictionary<string, Timer> timers = new Dictionary<string, Timer>();
private Dictionary<ulong, PurchaseItem> PendingPurchase = new Dictionary<ulong, PurchaseItem>();
private Dictionary<ulong, PurchaseItem> SetSelection = new Dictionary<ulong, PurchaseItem>();
private Dictionary<ulong, Dictionary<string, Dictionary<string, List<string>>>> WeaponSelection = new Dictionary<ulong, Dictionary<string, Dictionary<string, List<string>>>>();
private List<ACPlayer> ACPlayers = new List<ACPlayer>();
private Dictionary<ulong, GearCollectionCreation> NewGearCollection = new Dictionary<ulong, GearCollectionCreation>();
private Dictionary<ulong, WeaponCollectionCreation> NewWeaponCollection = new Dictionary<ulong, WeaponCollectionCreation>();
private Dictionary<ulong, string> SavingCollection = new Dictionary<ulong, string>();
private Dictionary<ulong, screen> ACUIInfo = new Dictionary<ulong, screen>();
class screen {
public bool open;
public bool admin;
public string GearSet;
public string WeaponSet;
public int GearIndex;
public int WeaponIndex;
}
//corpses///
private readonly string corpsePrefab = "assets/prefabs/player/player_corpse.prefab";
private uint corpsePrefabId;
#endregion
#region Hooks
void Loaded() {
GWData = Interface.Oxide.DataFileSystem.GetFile("AbsolutCombat_GWData");
PlayerData = Interface.Oxide.DataFileSystem.GetFile("AbsolutCombat_PlayerData");
lang.RegisterMessages(messages, this);
}
void Unload() {
foreach (var player in BasePlayer.activePlayerList) {
if (GetACPlayer(player)) DestroyACPlayer(GetACPlayer(player));
}
foreach (var timer in timers) timer.Value.Destroy();
timers.Clear();
SaveData();
ACPlayers.Clear();
}
void OnServerInitialized() {
LoadVariables();
LoadData();
if (configData.UseServerRewards) {
try {
ServerRewards.Call("isLoaded", null);
}
catch (Exception) {
PrintWarning(GetMSG("NOSR", Name));
Interface.Oxide.UnloadPlugin(Name);
return;
}
}
if (configData.UseEconomics) {
try {
Economics.Call("isLoaded", null);
if (configData.UseServerRewards && configData.UseEconomics) {
PrintWarning(GetMSG("BOTHERROR", Name));
Interface.Oxide.UnloadPlugin(Name);
return;
}
}
catch (Exception) {
PrintWarning(GetMSG("NOECO", Name));
Interface.Oxide.UnloadPlugin(Name);
return;
}
}
foreach (BasePlayer p in BasePlayer.activePlayerList) {
OnPlayerInit(p);
}
timers.Add("info", timer.Once(900, () => InfoLoop()));
timers.Add("save", timer.Once(600, () => SaveLoop()));
timers.Add("cond", timer.Once(120, () => CondLoop()));
}
private void OnPlayerInit(BasePlayer player) {
if (player != null) {
player.Command($"bind {configData.MenuKeyBinding} \"OpenACUI\"");
InitializeACPlayer(player);
GetSendMSG(player, "ACInfo", configData.MenuKeyBinding.ToUpper());
}
}
private void OnPlayerRespawned(BasePlayer player) {
if (EventManager) {
object isPlaying = EventManager?.Call("isPlaying", new object[] {
player
}
);
if (isPlaying is bool) if ((bool)isPlaying) return;
}
DestroyUI(player);
if (GetACPlayer(player).PlayerGearSets.Count() < 1) {
//UnityEngine.Object.Destroy(player);
ACPlayers.Remove(GetACPlayer(player));
InitializeACPlayer(player);
}
player.inventory.Strip();
GiveSet(player);
GiveWeapon(player);
player.health = 100f;
PlayerHUD(player);
}
private void OnEntityDeath(BaseEntity entity, HitInfo hitInfo) {
try {
var attacker = hitInfo.Initiator.ToPlayer() as BasePlayer;
var victim = entity.ToPlayer();
if (entity is BasePlayer && hitInfo.Initiator is BasePlayer) {
if (entity as BasePlayer == null || hitInfo == null) return;
if (!GetACPlayer(attacker) || !GetACPlayer(victim)) return;
if (victim.userID != attacker.userID) {
if (EventManager) {
object isPlaying = EventManager?.Call("isPlaying", new object[] {
attacker
}
);
if (isPlaying is bool) if ((bool)isPlaying) return;
}
GetACPlayer(attacker).kills += 1;
GetACPlayer(victim).deaths += 1;
if (configData.UseServerRewards) SRAction(attacker.userID, configData.KillReward, "ADD");
else if (configData.UseEconomics) ECOAction(attacker.userID, configData.KillReward, "ADD");
else GetACPlayer(attacker).money += configData.KillReward;
GetACPlayer(attacker).GearSetKills[GetACPlayer(attacker).currentGearSet] += 1;
GetACPlayer(attacker).WeaponSetKills[GetACPlayer(attacker).currentWeaponSet] += 1;
SendDeathNote(attacker, victim);
PlayerHUD(attacker);
}
}
}
catch (Exception) {
}
}
private void SRAction(ulong ID, int amount, string action) {
if (action == "ADD") ServerRewards?.Call("AddPoints", new object[] {
ID, amount
}
);
if (action == "REMOVE") ServerRewards?.Call("TakePoints", new object[] {
ID, amount
}
);
}
private void ECOAction(ulong ID, int amount, string action) {
if (action == "ADD") Economics.Call("DepositS", ID.ToString(), amount);
if (action == "REMOVE") Economics.Call("WithdrawS", ID.ToString(), amount);
}
object OnBetterChat(IPlayer iplayer, string message) {
var player = iplayer.Object as BasePlayer;
if (player == null) return message;
if (SavingCollection.ContainsKey(player.userID)) {
CollectionCreationChat(player, message.Split(' '));
return true;
}
return message;
}
private object OnPlayerChat(ConsoleSystem.Arg arg) {
if (BetterChat) return null;
var player = arg.connection.player as BasePlayer;
if (player == null) return null;
if (SavingCollection.ContainsKey(player.userID)) {
CollectionCreationChat(player, arg.Args);
return true;
}
return null;
}
private void CollectionCreationChat(BasePlayer player, string[] Args) {
if (Args.Contains("quit")) {
ExitSetCreation(player);
return;
}
var args = string.Join(" ", Args);
var name = args;
if (SavingCollection[player.userID] == "gear") NewGearCollection[player.userID].setname = name;
else if (SavingCollection[player.userID] == "weapon") NewWeaponCollection[player.userID].setname = name;
SaveCollect(player);
}
void OnEntitySpawned(BaseNetworkable entity) {
if (entity != null) {
corpsePrefabId = StringPool.Get(corpsePrefab);
if (configData.UseEnviroControl) {
if (entity.prefabID == corpsePrefabId) {
entity.Kill();
}
var collectible = entity as CollectibleEntity;
if (collectible != null) {
collectible.itemList = null;
}
var worldItem = entity as WorldItem;
if (worldItem != null) {
worldItem.allowPickup = false;
}
var Heli = entity as BaseHelicopter;
if (Heli != null) {
Heli.Kill();
}
var Plane = entity as CargoPlane;
if (Plane != null) {
Plane.Kill();
}
}
}
}
private void OnLootEntity(BasePlayer looter, BaseEntity target) {
if (configData.UseEnviroControl && !isAuth(looter)) {
if ((target as StorageContainer)?.transform.position == Vector3.zero) return;
timer.Once(0.01f, looter.EndLooting);
}
}
void OnPlantGather(PlantEntity Plant, Item item, BasePlayer player) {
if (configData.UseEnviroControl && !isAuth(player)) {
item.amount = 0;
}
}
void OnCollectiblePickup(Item item, BasePlayer player) {
if (configData.UseEnviroControl && !isAuth(player)) {
item.amount = 0;
}
}
void OnDispenserGather(ResourceDispenser Dispenser, BaseEntity entity, Item item) {
BasePlayer player = entity.ToPlayer();
if (configData.UseEnviroControl && !isAuth(player)) {
item.amount = 0;
}
}
object OnItemCraft(ItemCraftTask task, BasePlayer crafter) {
if (configData.UseEnviroControl && !isAuth(crafter)) {
task.cancelled = true;
}
return null;
}
#endregion
#region Functions
public string GetImage(string shortname, ulong skin = 0) {
var img = ImageLibrary.GetImage(shortname, skin);
return img;
}
private void InitializeACPlayer(BasePlayer player) {
if (!player.GetComponent<ACPlayer>()) {
if (playerData.players.ContainsKey(player.userID)) {
//if (playerData.priorSave.ContainsKey(player.userID))
//{
// if (playerData.players[player.userID].PlayerGearSets.Count() < 1 && playerData.priorSave[player.userID].PlayerGearSets.Count() > 0)
// {
// playerData.players[player.userID] = playerData.priorSave[player.userID];
// }
//}
//if (playerData.players[player.userID].PlayerGearSets.Count() < 1 && playerData.priorSave[player.userID].PlayerGearSets.Count() < 1)
//{
// playerData.players.Remove(player.userID);
// playerData.priorSave.Remove(player.userID);
// InitializeACPlayer(player);
// return;
//}
ACPlayers.Add(player.gameObject.AddComponent<ACPlayer>());
ACPlayer ac = GetACPlayer(player);
var d = playerData.players[player.userID];
ac.deaths = d.deaths;
ac.kills = d.kills;
ac.money = d.money;
ac.PlayerGearSets = d.PlayerGearSets;
ac.PlayerWeaponSets = d.PlayerWeaponSets;
ac.GearSetKills = d.GearSetKills;
ac.WeaponSetKills = d.WeaponSetKills;
ac.currentGearSet = d.lastgearSet;
ac.currentWeaponSet = d.lastweaponSet;
ac.CurrentWeapons = d.lastWeapons;
}
else {
ACPlayers.Add(player.gameObject.AddComponent<ACPlayer>());
ACPlayer ac = GetACPlayer(player);
ac.currentGearSet = null;
ac.kills = 0;
ac.deaths = 0;
ac.money = 0;
}
}
CheckSets(GetACPlayer(player));
}
void CheckSets(ACPlayer player) {
foreach (var entry in gwData.GearSets.Where(kvp => kvp.Value.cost == 0)) if (!player.PlayerGearSets.ContainsKey(entry.Key)) {
player.PlayerGearSets.Add(entry.Key, new List<string>());
player.GearSetKills.Add(entry.Key, 0);
foreach (var gear in gwData.GearSets[entry.Key].set.Where(kvp => kvp.free == true)) player.PlayerGearSets[entry.Key].Add(gear.shortname);
}
foreach (var entry in gwData.WeaponSets.Where(kvp => kvp.Value.cost == 0)) if (!player.PlayerWeaponSets.ContainsKey(entry.Key)) {
player.PlayerWeaponSets.Add(entry.Key, new Dictionary<string, List<string>>());
player.WeaponSetKills.Add(entry.Key, 0);
foreach (var weapons in gwData.WeaponSets[entry.Key].set.Where(kvp => kvp.free == true)) player.PlayerWeaponSets[entry.Key].Add(weapons.shortname, new List<string>());
}
List<string> gearset = new List<string>();
List<string> weaponset = new List<string>();
foreach (var entry in player.PlayerGearSets) if (!gwData.GearSets.ContainsKey(entry.Key)) {
gearset.Add(entry.Key);
if (player.currentGearSet == entry.Key) {
player.currentGearSet = null;
}
}
foreach (var entry in player.PlayerWeaponSets) if (!gwData.WeaponSets.ContainsKey(entry.Key)) {
weaponset.Add(entry.Key);
if (GetACPlayer(player.player).currentWeaponSet == entry.Key) {
player.CurrentWeapons.Clear();
player.currentWeaponSet = null;
}
}
if (gearset != null) foreach (var entry in gearset) {
player.PlayerGearSets.Remove(entry);
player.GearSetKills.Remove(entry);
}
if (weaponset != null) foreach (var entry in weaponset) {
player.PlayerWeaponSets.Remove(entry);
player.WeaponSetKills.Remove(entry);
}
if (!gwData.GearSets.ContainsKey(player.currentGearSet)) player.currentGearSet = null;
if (!gwData.WeaponSets.ContainsKey(player.currentWeaponSet)) player.currentWeaponSet = null;
if (string.IsNullOrEmpty(player.currentGearSet) && player.PlayerGearSets.Count() > 0) player.currentGearSet = player.PlayerGearSets.First().Key;
if (string.IsNullOrEmpty(player.currentWeaponSet) && player.PlayerWeaponSets.Count() > 0 || player.CurrentWeapons == null && player.PlayerWeaponSets.Count() > 0) {
Puts("TRYING");
player.currentWeaponSet = player.PlayerWeaponSets.First().Key;
if (player.CurrentWeapons == null) player.CurrentWeapons = new Dictionary<string, List<string>>();
else player.CurrentWeapons.Clear();
foreach (var wp in player.PlayerWeaponSets[player.currentWeaponSet]) {
Puts($"ADDING:{wp.Key}");
player.CurrentWeapons.Add(wp.Key, new List<string>());
Puts("Items done");
}
}
player.player.inventory.Strip();
GiveSet(player.player);
GiveWeapon(player.player);
PlayerHUD(player.player);
}
private object CheckPoints(ulong ID) => ServerRewards?.Call("CheckPoints", ID);
void DestroyACPlayer(ACPlayer player) {
if (player.player == null) return;
{
SaveACPlayer(player);
DestroyUI(player.player);
player.player.Command($"bind {configData.MenuKeyBinding} \"\"");
player.player.Command($"bind tab \"inventory.toggle\"");
if (ACPlayers.Contains(player)) {
UnityEngine.Object.Destroy(player);
ACPlayers.Remove(player);
}
ACUIInfo.Remove(player.player.userID);
}
}
ACPlayer GetACPlayer(BasePlayer player) {
if (!player.GetComponent<ACPlayer>()) return null;
else return player.GetComponent<ACPlayer>();
}
private string GetLang(string msg) {
if (messages.ContainsKey(msg)) return lang.GetMessage(msg, this);
else return msg;
}
private void GetSendMSG(BasePlayer player, string message, string arg1 = "", string arg2 = "", string arg3 = "") {
string msg = string.Format(GetLang(message), arg1, arg2, arg3);
SendReply(player, TitleColor + lang.GetMessage("title", this, player.UserIDString) + "</color>" + MsgColor + msg + "</color>");
}
private string GetMSG(string message, string arg1 = "", string arg2 = "", string arg3 = "") {
string msg = string.Format(lang.GetMessage(message, this), arg1, arg2, arg3);
return msg;
}
static void TPPlayer(BasePlayer player, Vector3 destination) {
if (player.net?.connection != null) player.ClientRPCPlayer(null, player, "StartLoading", null, null, null, null, null);
StartSleeping(player);
player.MovePosition(destination);
if (player.net?.connection != null) player.ClientRPCPlayer(null, player, "ForcePositionTo", destination);
player.TransformChanged();
if (player.net?.connection != null) player.SetPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot, true);
player.UpdateNetworkGroup();
player.SendNetworkUpdateImmediate(false);
if (player.net?.connection == null) return;
try {
player.ClearEntityQueue(null);
}
catch {
}
player.SendFullSnapshot();
}
static void StartSleeping(BasePlayer player) {
if (player.IsSleeping()) return;
player.SetPlayerFlag(BasePlayer.PlayerFlags.Sleeping, true);
if (!BasePlayer.sleepingPlayerList.Contains(player)) BasePlayer.sleepingPlayerList.Add(player);
player.CancelInvoke("InventoryUpdate");
}
[ConsoleCommand("OpenACUI")]
private void cmdOpenACUI(ConsoleSystem.Arg arg) {
var player = arg.connection.player as BasePlayer;
if (player == null) return;
if (ACUIInfo.ContainsKey(player.userID)) if (!ACUIInfo[player.userID].open) {
ACUIInfo[player.userID].open = true;
OpenACUI(player);
}
else DestroyACPanel(player);
else OpenACUI(player);
}
private void OpenACUI(BasePlayer player) {
if (!ACUIInfo.ContainsKey(player.userID)) ACUIInfo.Add(player.userID, new screen {
admin = false, open = true, GearIndex = 0, GearSet = "", WeaponIndex = 0, WeaponSet = ""
}
);
ACPanel(player);
GearListPanel(player);
WeaponListPanel(player);
GearPanel(player);
WeaponPanel(player);
}
public void DestroyUI(BasePlayer player) {
DestroyACPanel(player);
CuiHelper.DestroyUi(player, PanelOnScreen);
CuiHelper.DestroyUi(player, PanelPurchaseConfirmation);
CuiHelper.DestroyUi(player, PanelStats);
}
public void DestroyACPanel(BasePlayer player) {
if (ACUIInfo.ContainsKey(player.userID)) ACUIInfo[player.userID].open = false;
CuiHelper.DestroyUi(player, PanelAC);
CuiHelper.DestroyUi(player, GPanel);
CuiHelper.DestroyUi(player, WPanel);
CuiHelper.DestroyUi(player, GLPanel);
CuiHelper.DestroyUi(player, WLPanel);
CuiHelper.DestroyUi(player, APanel);
}
public void Broadcast(string message, string userid = "0") => PrintToChat(message);
private void SendDeathNote(BasePlayer player, BasePlayer victim) {
string colorAttacker = "";
string colorVictim = "";
colorAttacker = "<color=#e60000>";
colorVictim = "<color=#3366ff>";
if (configData.BroadcastDeath) {
string formatMsg = colorAttacker + player.displayName + "</color>" + GetLang("DeathMessage") + colorVictim + victim.displayName + "</color>";
Broadcast(formatMsg);
}
}
private void SaveCollect(BasePlayer player) {
if (!SavingCollection.ContainsKey(player.userID)) return;
var index = 0;
var name = "";
var type = SavingCollection[player.userID];
if (type == "gear") {
if (gwData.GearSets.Count == 0) index = 0;
else index = gwData.GearSets.Max(kvp => kvp.Value.index) + 1;
List<Gear> gearlist = new List<Gear>();
foreach (var entry in NewGearCollection[player.userID].collection.set) gearlist.Add(entry.Value);
name = NewGearCollection[player.userID].setname;
var newset = new GearSet {
cost = NewGearCollection[player.userID].collection.cost, killsrequired = NewGearCollection[player.userID].collection.killsrequired, set = gearlist, index = index
}
;
gwData.GearSets.Add(name, newset);
NewGearCollection.Remove(player.userID);
}
else if(type == "weapon") {
if (gwData.WeaponSets.Count == 0) index = 0;
else index = gwData.WeaponSets.Max(kvp => kvp.Value.index) + 1;
List<Weapon> gearlist = new List<Weapon>();
foreach (var entry in NewWeaponCollection[player.userID].collection.set) gearlist.Add(entry.Value);
name = NewWeaponCollection[player.userID].setname;
var newset = new WeaponSet {
cost = NewWeaponCollection[player.userID].collection.cost, killsrequired = NewWeaponCollection[player.userID].collection.killsrequired, set = gearlist, index = index
}
;
gwData.WeaponSets.Add(name, newset);
NewWeaponCollection.Remove(player.userID);
}
SavingCollection.Remove(player.userID);
GetSendMSG(player, "NewCollectionCreated", type.ToUpper(), name);
DestroyACPanel(player);
SaveData();
}
private void ExitSetCreation(BasePlayer player) {
if (!SavingCollection.ContainsKey(player.userID)) return;
SavingCollection.Remove(player.userID);
DestroyACPanel(player);
}
bool isAuth(BasePlayer player) {
if (player.net.connection != null) if (player.net.connection.authLevel < 1) return false;
return true;
}
private List<BasePlayer> FindPlayer(string arg) {
var foundPlayers = new List<BasePlayer>();
ulong steamid;
ulong.TryParse(arg, out steamid);
string lowerarg = arg.ToLower();
foreach (var p in BasePlayer.activePlayerList) if (p != null) {
if (steamid != 0L) if (p.userID == steamid) {
foundPlayers.Add(p);
return foundPlayers;
}
string lowername = p.displayName.ToLower();
if (lowername.Contains(lowerarg)) foundPlayers.Add(p);
}
return foundPlayers;
}
[ConsoleCommand("addmoney")]
private void cmdaddmoney(ConsoleSystem.Arg arg) {
if (arg.connection != null) if (arg.connection.authLevel < 1) {
if (arg.connection.player != null) {
var player = arg.connection.player as BasePlayer;
GetSendMSG(player, "NotAuthorized");
}
return;
}
chatAddMoney(null, "addmoney", arg.Args);
}
[ConsoleCommand("takemoney")]
private void cmdtakemoney(ConsoleSystem.Arg arg) {
if (arg.connection != null) if (arg.connection.authLevel < 1) {
if (arg.connection.player != null) {
var player = arg.connection.player as BasePlayer;
GetSendMSG(player, "NotAuthorized");
}
return;
}
chattakemoney(null, "takemoney", arg.Args);
}
[ConsoleCommand("addkills")]
private void cmdaddkills(ConsoleSystem.Arg arg) {
if (arg.connection != null) if (arg.connection.authLevel < 1) {
if (arg.connection.player != null) {
var player = arg.connection.player as BasePlayer;
GetSendMSG(player, "NotAuthorized");
}
return;
}
chatAddKills(null, "addkills", arg.Args);
}
[ConsoleCommand("takekills")]
private void cmdtakekills(ConsoleSystem.Arg arg) {
if (arg.connection != null) if (arg.connection.authLevel < 1) {
if (arg.connection.player != null) {
var player = arg.connection.player as BasePlayer;
GetSendMSG(player, "NotAuthorized");
}
return;
}
chatTakeKills(null, "takekills", arg.Args);
}
[ChatCommand("addmoney")]
private void chatAddMoney(BasePlayer player, string command, string[] args) {
if (player != null) {
if (!isAuth(player)) {
GetSendMSG(player, "NotAuthorized");
return;
}
}
if (args.Length == 2) {
int amount;
if (!int.TryParse(args[1], out amount)) {
if (player == null) Puts(GetMSG("INVALIDENTRY", args[1]));
else GetSendMSG(player, "INVALIDENTRY", args[1]);
return;
}
var partialPlayerName = args[0];
var foundPlayers = FindPlayer(partialPlayerName);
if (foundPlayers.Count() == 0) {
if (player == null) Puts(GetMSG("NoPlayers", args[0]));
else GetSendMSG(player, "NoPlayers", args[0]);
return;
}
if (foundPlayers.Count() > 1) {
if (player == null) Puts(GetMSG("MultiplePlayers", args[0]));
else GetSendMSG(player, "MultiplePlayers", args[0]);
return;
}
if (foundPlayers[0] != null) {
ulong requestor = 0;
if (player != null) requestor = player.userID;
AddMoney(foundPlayers[0].userID, amount, true, requestor);
PlayerHUD(foundPlayers[0]);
}
}
else {
if (player == null) Puts(GetMSG("ArgumentsIncorrect", "/addmoney PLAYERNAME AMOUNT", "/addmoney Absolut 20"));
else GetSendMSG(player, "ArgumentsIncorrect", "/addmoney PLAYERNAME AMOUNT", "/addmoney Absolut 20");
}
}
[ChatCommand("addkills")]
private void chatAddKills(BasePlayer player, string command, string[] args) {
if (player != null) {
if (!isAuth(player)) {
GetSendMSG(player, "NotAuthorized");
return;
}
}
if (args.Length == 4) {
int amount;
if (!int.TryParse(args[3], out amount)) {
if (player == null) Puts(GetMSG("INVALIDENTRY", args[1]));
else GetSendMSG(player, "INVALIDENTRY", args[1]);
return;
}
var partialPlayerName = args[0];
var type = args[1];
var collection = args[2];
var foundPlayers = FindPlayer(partialPlayerName);
if (foundPlayers.Count() == 0) {
if (player == null) Puts(GetMSG("NoPlayers", args[0]));
else GetSendMSG(player, "NoPlayers", args[0]);
return;
}
if (foundPlayers.Count() > 1) {
if (player == null) Puts(GetMSG("MultiplePlayers", args[0]));
else GetSendMSG(player, "MultiplePlayers", args[0]);
return;
}
if (foundPlayers[0] != null) {
ulong requestor = 0;
if (player != null) requestor = player.userID;
if (type == "weapon") {
if (gwData.WeaponSets.ContainsKey(collection) && playerData.players[foundPlayers[0].userID].PlayerWeaponSets.ContainsKey(collection)) AddKills(foundPlayers[0].userID, amount, type, collection, requestor);
}
else if (type == "gear") {
if (gwData.GearSets.ContainsKey(collection) && playerData.players[foundPlayers[0].userID].PlayerGearSets.ContainsKey(collection)) AddKills(foundPlayers[0].userID, amount, type, collection, requestor);
}
PlayerHUD(foundPlayers[0]);
}
}
else {
if (player == null) Puts(GetMSG("ArgumentsIncorrect", "/addkills PLAYERNAME TYPE COLLECTION AMOUNT", "/addkills Absolut weapon starter 20"));
else GetSendMSG(player, "ArgumentsIncorrect", "/addkills PLAYERNAME TYPE COLLECTION AMOUNT", "/addkills Absolut weapon starter 20");
}
}
[ChatCommand("takekills")]
private void chatTakeKills(BasePlayer player, string command, string[] args) {
if (player != null) {
if (!isAuth(player)) {
GetSendMSG(player, "NotAuthorized");
return;
}
}
if (args.Length == 4) {
int amount;
if (!int.TryParse(args[3], out amount)) {
if (player == null) Puts(GetMSG("INVALIDENTRY", args[1]));
else GetSendMSG(player, "INVALIDENTRY", args[1]);
return;
}
var partialPlayerName = args[0];
var type = args[1];
var collection = args[2];
var foundPlayers = FindPlayer(partialPlayerName);
if (foundPlayers.Count() == 0) {
if (player == null) Puts(GetMSG("NoPlayers", args[0]));
else GetSendMSG(player, "NoPlayers", args[0]);
return;
}
if (foundPlayers.Count() > 1) {
if (player == null) Puts(GetMSG("MultiplePlayers", args[0]));
else GetSendMSG(player, "MultiplePlayers", args[0]);
return;
}
if (foundPlayers[0] != null) {
ulong requestor = 0;
if (player != null) requestor = player.userID;
if (type == "weapon") {
if (gwData.WeaponSets.ContainsKey(collection) && playerData.players[foundPlayers[0].userID].PlayerWeaponSets.ContainsKey(collection)) TakeKills(foundPlayers[0].userID, amount, type, collection, requestor);
}
else if (type == "gear") {
if (gwData.GearSets.ContainsKey(collection) && playerData.players[foundPlayers[0].userID].PlayerGearSets.ContainsKey(collection)) TakeKills(foundPlayers[0].userID, amount, type, collection, requestor);
}
PlayerHUD(foundPlayers[0]);
}
}
else {
if (player == null) Puts(GetMSG("ArgumentsIncorrect", "/takekills PLAYERNAME TYPE COLLECTION AMOUNT", "/takekills Absolut weapon starter 20"));
else GetSendMSG(player, "ArgumentsIncorrect", "/takekills PLAYERNAME TYPE COLLECTION AMOUNT", "/takekills Absolut weapon starter 20");
}
}
[ChatCommand("takemoney")]
private void chattakemoney(BasePlayer player, string command, string[] args) {
if (player != null) {
if (!isAuth(player)) {
GetSendMSG(player, "NotAuthorized");
return;
}
}
if (args.Length == 2) {
int amount;
if (!int.TryParse(args[1], out amount)) {
if (player == null) Puts(GetMSG("INVALIDENTRY", args[1]));
else GetSendMSG(player, "INVALIDENTRY", args[1]);
return;
}
var partialPlayerName = args[0];
var foundPlayers = FindPlayer(partialPlayerName);
if (foundPlayers.Count() == 0) {
if (player == null) Puts(GetMSG("NoPlayers", args[0]));
else GetSendMSG(player, "NoPlayers", args[0]);
return;
}
if (foundPlayers.Count() > 1) {
if (player == null) Puts(GetMSG("MultiplePlayers", args[0]));
else GetSendMSG(player, "MultiplePlayers", args[0]);
return;
}
if (foundPlayers[0] != null) {
ulong requestor = 0;
if (player != null) requestor = player.userID;
TakeMoney(foundPlayers[0].userID, amount, true, requestor);
PlayerHUD(foundPlayers[0]);
}
}
else {
if (player == null) Puts(GetMSG("ArgumentsIncorrect", "/takemoney PLAYERNAME AMOUNT", "/takemoney Absolut 20"));
else GetSendMSG(player, "ArgumentsIncorrect", "/takemoney PLAYERNAME AMOUNT", "/takemoney Absolut 20");
}
}
#endregion
#region UI Creation
private string PanelAC = "PanelAC";
private string GLPanel = "GLPanel";
private string WLPanel = "WLPanel";
private string GPanel = "GPanel";
private string WPanel = "WPanel";
private string APanel = "APanel";
private string PanelOnScreen = "OnScreen";
private string PanelPurchaseConfirmation = "PurchaseConfirmation";
private string PanelStats = "StatsPanel";
public class UI {
static public CuiElementContainer CreateElementContainer(string panelName, string color, string aMin, string aMax, bool cursor = false) {
var NewElement = new CuiElementContainer() {
{
new CuiPanel {
Image = {
Color = color
}
, RectTransform = {
AnchorMin = aMin, AnchorMax = aMax
}
, CursorEnabled = cursor
}
, new CuiElement().Parent, panelName
}
}
;
return NewElement;
}
static public void CreatePanel(ref CuiElementContainer container, string panel, string color, string aMin, string aMax, bool cursor = false) {
container.Add(new CuiPanel {
Image = {
Color = color
}
, RectTransform = {
AnchorMin = aMin, AnchorMax = aMax
}
, CursorEnabled = cursor
}
, panel);
}
static public void CreateLabel(ref CuiElementContainer container, string panel, string color, string text, int size, string aMin, string aMax, TextAnchor align = TextAnchor.MiddleCenter) {
container.Add(new CuiLabel {
Text = {
Color = color, FontSize = size, Align = align, FadeIn = 1.0f, Text = text
}
, RectTransform = {
AnchorMin = aMin, AnchorMax = aMax
}
}
, panel);
}
static public void CreateButton(ref CuiElementContainer container, string panel, string color, string text, int size, string aMin, string aMax, string command, TextAnchor align = TextAnchor.MiddleCenter) {
container.Add(new CuiButton {
Button = {
Color = color, Command = command, FadeIn = 1.0f
}
, RectTransform = {
AnchorMin = aMin, AnchorMax = aMax
}
, Text = {
Text = text, FontSize = size, Align = align
}
}
, panel);
}
static public void LoadImage(ref CuiElementContainer container, string panel, string png, string aMin, string aMax) {
container.Add(new CuiElement {
Parent = panel, Components = {
new CuiRawImageComponent {
Png = png
}
, new CuiRectTransformComponent {
AnchorMin = aMin, AnchorMax = aMax
}
}
}
);
}
static public void CreateTextOverlay(ref CuiElementContainer container, string panel, string text, string color, int size, string aMin, string aMax, TextAnchor align = TextAnchor.MiddleCenter, float fadein = 1.0f) {
//if (configdata.DisableUI_FadeIn)
// fadein = 0;
container.Add(new CuiLabel {
Text = {
Color = color, FontSize = size, Align = align, FadeIn = fadein, Text = text
}
, RectTransform = {
AnchorMin = aMin, AnchorMax = aMax
}
}
, panel);
}
static public void CreateTextOutline(ref CuiElementContainer element, string panel, string colorText, string colorOutline, string text, int size, string DistanceA, string DistanceB, string aMin, string aMax, TextAnchor align = TextAnchor.MiddleCenter) {
element.Add(new CuiElement {
Parent = panel, Components = {
new CuiTextComponent {
Color = colorText, FontSize = size, Align = align, Text = text
}
, new CuiOutlineComponent {
Distance = DistanceA + " " + DistanceB, Color = colorOutline
}
, new CuiRectTransformComponent {
AnchorMax = aMax, AnchorMin = aMin
}
}
}
);
}
}
private Dictionary<string, string> UIColors = new Dictionary<string, string> {
{
"black", "0 0 0 1.0"
}
, {
"dark", "0.1 0.1 0.1 0.98"
}
, {
"header", "1 1 1 0.3"
}
, {
"light", ".564.564.564 1.0"
}
, {
"grey1", "0.6 0.6 0.6 1.0"
}
, {
"brown", "0.3 0.16 0.0 1.0"
}
, {
"yellow", "0.9 0.9 0.0 1.0"
}
, {
"orange", "1.0 0.65 0.0 1.0"
}
, {
"blue", "0.2 0.6 1.0 1.0"
}
, {
"red", "1.0 0.1 0.1 1.0"
}
, {
"white", "1 1 1 1"
}
, {
"limegreen", "0.42 1.0 0 1.0"
}
, {
"green", "0.28 0.82 0.28 1.0"
}
, {
"grey", "0.85 0.85 0.85 1.0"
}
, {
"lightblue", "0.6 0.86 1.0 1.0"
}
, {
"buttonbg", "0.2 0.2 0.2 0.7"
}
, {
"buttongreen", "0.133 0.965 0.133 0.9"
}
, {
"buttonred", "0.964 0.133 0.133 0.9"
}
, {
"buttongrey", "0.8 0.8 0.8 0.9"
}
, {
"customblue", "0.454 0.77 1.0 1.0"
}
, {
"CSorange", "1.0 0.64 0.10 1.0"
}
}
;
private Dictionary<string, string> TextColors = new Dictionary<string, string> {
{
"limegreen", "<color=#6fff00>"
}
}
;
private Dictionary<Slot, Vector2> LeftGearSlotPos = new Dictionary<Slot, Vector2> {
{
Slot.head, new Vector2(.4f, .65f)
}
, {
Slot.chest, new Vector2(.27f, .45f)
}
, {
Slot.legs, new Vector2(.27f, .25f)
}
, {
Slot.hands, new Vector2(.27f, .05f)
}
,
}
;
private Dictionary<Slot, Vector2> RightGearSlotPos = new Dictionary<Slot, Vector2> {
{
Slot.chest2, new Vector2(.49f, .45f)
}
, {
Slot.legs2, new Vector2(.49f, .25f)
}
, {
Slot.feet, new Vector2(.49f, .05f)
}
,
}
;
private Dictionary<Slot, Vector2> GearSlotPos = new Dictionary<Slot, Vector2> {
{
Slot.head, new Vector2(.4f, .65f)
}
, {
Slot.chest, new Vector2(.27f, .45f)
}
, {
Slot.chest2, new Vector2(.49f, .45f)
}
, {
Slot.legs, new Vector2(.27f, .25f)
}
, {
Slot.legs2, new Vector2(.49f, .25f)
}
, {
Slot.feet, new Vector2(.49f, .05f)
}
, {
Slot.hands, new Vector2(.27f, .05f)
}
,
}
;
private Dictionary<Slot, Vector2> WeaponSlotPos = new Dictionary<Slot, Vector2> {
{
Slot.main, new Vector2(.27f, .45f)
}
, {
Slot.secondary, new Vector2(.49f, .45f)
}
,
}
;
private Dictionary<Slot, Vector2> MainAttachmentSlotsPos = new Dictionary<Slot, Vector2> {
{
Slot.attachment1, new Vector2(.29f, .75f)
}
, {
Slot.attachment2, new Vector2(.29f, .45f)
}
, {
Slot.attachment3, new Vector2(.29f, .15f)
}
,
}
;
private Dictionary<Slot, Vector2> SecondaryAttachmentSlotsPos = new Dictionary<Slot, Vector2> {
{
Slot.attachment1, new Vector2(.53f, .75f)
}
, {
Slot.attachment2, new Vector2(.53f, .45f)
}
, {
Slot.attachment3, new Vector2(.53f, .15f)
}
,
}
;
private Dictionary<Slot, Vector2> AccessoriesSlotsPos = new Dictionary<Slot, Vector2> {
{
Slot.accessories1, new Vector2(.7f, .85f)
}
, {
Slot.accessories2, new Vector2(.7f, .7f)
}
,
}
;
private Dictionary<Slot, Vector2> AmmunitionSlotsPos = new Dictionary<Slot, Vector2> {
{
Slot.ammunitionMain, new Vector2(.13f, 1.2f)
}
, {
Slot.ammunitionSecondary, new Vector2(.7f, 1.2f)
}
,
}
;
#endregion
#region UI Panels
void ACPanel(BasePlayer player) {
//CuiHelper.DestroyUi(player, PanelAC);
//var element = UI.CreateElementContainer(PanelAC, UIColors["dark"], "0.15 0.2", "0.87 0.8", true);
//UI.CreatePanel(ref element, PanelAC, UIColors["header"], "0.01 0.02", "0.97 0.98");
//RENDER IMAGE FROM TNT OR WHATEVER I USE...//CuiHelper.AddUi(player, element);
}
void GearListPanel(BasePlayer player) {
CuiHelper.DestroyUi(player, GLPanel);
var element = UI.CreateElementContainer(GLPanel, UIColors["dark"],
// ... [Code preview truncated due to length. Full source in attached file] ...