C#:
using Facepunch;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using ProtoBuf;
using Rust;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static BuildingManager;
using static Steamworks.InventoryItem;
using Random = UnityEngine.Random;
using ru = Oxide.Game.Rust;
namespace Oxide.Plugins {
[Info("ArenaTournament", "discord: fermens#8767", "1.1.9")]
[Description("Турнир на выбывание | Knockout tournament")]
public class ArenaTournament : RustPlugin {
const bool fermensEN = false;
const bool debug = false;
#region Config
private PluginConfig config;
protected override void LoadDefaultConfig() {
config = new PluginConfig();
}
protected override void LoadConfig() {
base.LoadConfig();
config = Config.ReadObject<PluginConfig>();
}
protected override void SaveConfig() {
Config.WriteObject(config);
}
class IITEM {
[JsonProperty(PropertyName = fermensEN ? "Name" : "Название")]
public string name;
[JsonProperty(PropertyName = "Shortname")]
public string shortname;
[JsonProperty(PropertyName = fermensEN ? "SkinID" : "СкинID")]
public ulong skin;
[JsonProperty(PropertyName = fermensEN ? "Amount" : "Количество")]
public int amount;
[JsonProperty(PropertyName = fermensEN ? "Blueprint [true/false]" : "Рецепт [true/false]")]
public bool blueprintTarget;
}
class SkinTeam {
[JsonProperty(PropertyName = fermensEN ? "SkinId for team #1" : "Скин для команды #1")]
public ulong skinteam1;
[JsonProperty(PropertyName = fermensEN ? "SkinId for team #2" : "Скин для команды #2")]
public ulong skinteam2;
}
class GUNITEM {
[JsonProperty(PropertyName = fermensEN ? "Shortname <weapon>" : "Shortname <оружия>")]
public string shortname;
[JsonProperty(PropertyName = fermensEN ? "SkinID <weapon>" : "СкинID <оружия>")]
public ulong skin;
[JsonProperty(PropertyName = fermensEN ? "Wear [shortname|skinID]" : "Одежда [shortname|cкинID]")]
public Dictionary<string, SkinTeam> wear = new Dictionary<string, SkinTeam>();
[JsonProperty(PropertyName = fermensEN ? "Modules for weapons [shortname]" : "Модули на оружия [shortname]")]
public List<string> moduls = new List<string>();
[JsonProperty(PropertyName = fermensEN ? "Additional Items [shortname|amount]" : "Дополнительные предметы [shortname|количество]")]
public Dictionary<string, int> additional = new Dictionary<string, int>();
}
class Reward {
[JsonProperty(PropertyName = fermensEN ? "Command sent | message to player" : "Отправляемая команда | сообщение игроку")]
public Dictionary<string, string> commands = new Dictionary<string, string>();
[JsonProperty(PropertyName = fermensEN ? "Items" : "Предметы")]
public List<IITEM> iTEMs = new List<IITEM>();
}
class SPEC {
[JsonProperty(PropertyName = fermensEN ? "Wear [shortname|cкинID]" : "Одежда [shortname|скин]")]
public Dictionary<string, ulong> wears = new Dictionary<string, ulong>();
[JsonProperty(PropertyName = fermensEN ? "Additional Items [shortname|amount]" : "Дополнительные предметы [shortname|количество]")]
public Dictionary<string, int> additional = new Dictionary<string, int>();
}
private class CurrentEvent {
[JsonProperty(PropertyName = fermensEN ? "Position [coordinates]" : "Позиция [координаты]")]
public Vector3 position;
[JsonProperty(PropertyName = fermensEN ? "Arena radius" : "Радиус арены")]
public float radius;
[JsonProperty(PropertyName = fermensEN ? "Weapons" : "Оружия")]
public List<GUNITEM> weapons = new List<GUNITEM>();
[JsonProperty(PropertyName = fermensEN ? "Spectators" : "Зрители")]
public SPEC sPEC;
[JsonProperty(PropertyName = fermensEN ? "Awards [place|award]" : "Награды [место|награда]")]
public Dictionary<int, Reward> reward;
[JsonProperty(PropertyName = fermensEN ? "<xVSx> Tournament Modes" : "Режимы турниров <xVSx>")]
public List<int> vs = new List<int>();
//[JsonProperty(PropertyName = "")]
//public bool wound;
}
private class ArenaSetting {
public List<Vector3> spectators = new List<Vector3>();
public List<Vector3> duelers1 = new List<Vector3>();
public List<Vector3> duelers2 = new List<Vector3>();
}
class UIRegistration {
public string anchormin {
get;
set;
}
= "0.5 0";
public string anchormax {
get;
set;
}
= "0.5 0";
public string offsetmin {
get;
set;
}
= "-440 48";
public string offsetmax {
get;
set;
}
= "-267 130";
public string background_color {
get;
set;
}
= "0.2313726 0.2313726 0.2313726 0.3882353";
public string button_color {
get;
set;
}
= "0 0 0 0.7058824";
public string text_color {
get;
set;
}
= "0 0 0 0.7058824";
}
private class PluginConfig {
#region ARENAS
[JsonProperty(fermensEN ? "Tournament arenas" : "Турнирные арены")]
public Dictionary<string, CurrentEvent> currentEvent = new Dictionary<string, CurrentEvent>();
#endregion
[JsonProperty(PropertyName = fermensEN ? "Run events every <x> minutes" : "Запуск ивентов через каждый <x> минут")]
public float eventstart {
get;
set;
}
= 60f;
[JsonProperty(PropertyName = fermensEN ? "Chat icon SteamID" : "SteamId чата иконки")]
public ulong chaticon {
get;
set;
}
= 1;
[JsonProperty(PropertyName = fermensEN ? "How much time to register for the tournament? [seconds]" : "Сколько давать времени на регистрацию в турнире? [секунд]")]
public int regatime {
get;
set;
}
= 120;
[JsonProperty(PropertyName = fermensEN ? "Available commands in the arena [lower case]" : "Доступные команды на арене [нижний регистр]")]
public string[] allowcommands {
get;
set;
}
= new string[] {
"report", "mreport", "ban", "mute", "pm", "r", "qq.arena", "report", "setinfo", "sleep", "kill", "respawn", "recover", "qg", "qw", "inventory.endloot", "inventory.lighttoggle", "ff"
}
;
[JsonProperty(PropertyName = fermensEN ? "Chat command to enter/exit the arena" : "Чат команда для входа/выхода с арены")]
public string chatcommand {
get;
set;
}
= "qq";
[JsonProperty(PropertyName = fermensEN ? "UI - Tournament registration" : "UI - Регистрация на турнир")]
public UIRegistration UIRegistration {
get;
set;
}
= new UIRegistration();
[JsonProperty(PropertyName = fermensEN ? "Prevent players from using sound chat" : "Запретить игрокам использовать звуковой чат")]
public bool blockvoice {
get;
set;
}
[JsonProperty(PropertyName = fermensEN ? "Do not give a prize to a player if he has won more than one tournament in a row" : "Не давать приз игроку если он выиграл больше одного турнира в ряд")]
public bool noprizeinarow {
get;
set;
}
[JsonProperty(PropertyName = fermensEN ? "Disable notifications in Notify plugin if you have it" : "Отключить уведомления в плагин Notify, если он у вас имеется")]
public bool disablenotify {
get;
set;
}
[JsonProperty(PropertyName = fermensEN ? "How many victories do the teams duel to get to the next stage?" : "До скольки побед дуэлятся между собой команды, что бы пройти в следующий этап?")]
public int needwinds {
get;
set;
}
= 2;
}
#endregion
#region Oxide - Hooks
static ArenaTournament fermens;
[PluginReference]
Plugin CopyPaste, AimTrain, Notify, ZoneManager, SkillTree;
private void Init() {
Unsubscribe(nameof(OnPlayerVoice));
fermens = this;
}
private string token = "090620220734fermens";
private string namer = "ArenaTournament";
private void OnServerInitialized() {
if (config.currentEvent.Count == 0) {
config.currentEvent = new Dictionary<string, CurrentEvent> {
{
"ater", new CurrentEvent {
weapons = new List<GUNITEM> {
{
new GUNITEM {
shortname = "rifle.ak", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.holosight", 1
}
, {
"weapon.mod.simplesight", 1
}
, {
"weapon.mod.muzzlebrake", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
"roadsign.gloves", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"pants", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"metal.plate.torso", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"shoes.boots", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
}
}
}
, {
new GUNITEM {
shortname = "rifle.ak.ice", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.holosight", 1
}
, {
"weapon.mod.simplesight", 1
}
, {
"weapon.mod.muzzlebrake", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
"roadsign.gloves", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"pants", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"metal.plate.torso", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"shoes.boots", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
}
}
}
, {
new GUNITEM {
shortname = "lmg.m249", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.holosight", 1
}
, {
"weapon.mod.simplesight", 1
}
, {
"weapon.mod.muzzlebrake", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
"roadsign.gloves", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"pants", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"metal.plate.torso", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"shoes.boots", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
}
}
}
, {
new GUNITEM {
shortname = "rifle.semiauto", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.holosight", 1
}
, {
"weapon.mod.simplesight", 1
}
, {
"weapon.mod.muzzlebrake", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
"roadsign.gloves", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"pants", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"metal.plate.torso", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"shoes.boots", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
}
}
}
, {
new GUNITEM {
shortname = "rifle.bolt", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.small.scope", 1
}
, {
"weapon.mod.8x.scope", 1
}
, {
"weapon.mod.silencer", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
"roadsign.gloves", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"pants", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"metal.plate.torso", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"shoes.boots", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
}
}
}
, {
new GUNITEM {
shortname = "rifle.l96", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.small.scope", 1
}
, {
"weapon.mod.8x.scope", 1
}
, {
"weapon.mod.silencer", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
"roadsign.gloves", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"pants", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"metal.plate.torso", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"shoes.boots", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
}
}
}
, {
new GUNITEM {
shortname = "rifle.m39", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.small.scope", 1
}
, {
"weapon.mod.8x.scope", 1
}
, {
"weapon.mod.silencer", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
"roadsign.gloves", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"pants", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"metal.plate.torso", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"shoes.boots", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
}
}
}
, {
new GUNITEM {
shortname = "rifle.lr300", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.holosight", 1
}
, {
"weapon.mod.simplesight", 1
}
, {
"weapon.mod.silencer", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
"roadsign.gloves", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"pants", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"metal.plate.torso", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"shoes.boots", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
}
}
}
, {
new GUNITEM {
shortname = "smg.mp5", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.holosight", 1
}
, {
"weapon.mod.simplesight", 1
}
, {
"weapon.mod.muzzleboost", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
"roadsign.gloves", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"pants", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"metal.plate.torso", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"shoes.boots", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
}
}
}
, {
new GUNITEM {
shortname = "pistol.m92", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.holosight", 1
}
, {
"weapon.mod.simplesight", 1
}
, {
"weapon.mod.silencer", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
"roadsign.gloves", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"pants", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"metal.plate.torso", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"shoes.boots", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
}
}
}
, {
new GUNITEM {
shortname = "shotgun.spas12", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.holosight", 1
}
, {
"weapon.mod.simplesight", 1
}
, {
"weapon.mod.silencer", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
"roadsign.gloves", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"pants", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"metal.plate.torso", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"shoes.boots", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
}
}
}
, {
new GUNITEM {
shortname = "smg.thompson", moduls = new List<string> {
}
, skin = 0, additional = new Dictionary<string, int> {
{
"syringe.medical", 5
}
, {
"weapon.mod.holosight", 1
}
, {
"weapon.mod.simplesight", 1
}
, {
"weapon.mod.muzzleboost", 1
}
, {
"weapon.mod.lasersight", 1
}
}
, wear = new Dictionary<string, SkinTeam> {
{
"metal.facemask", new SkinTeam {
skinteam1 = 0, skinteam2 = 0
}
}
, {
"hoodie", new SkinTeam {
skinteam1 = 954947279, skinteam2 = 971807764
}
}
, {
// ... [Code preview truncated due to length. Full source in attached file] ...