C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System;
using System.Collections.Generic;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Game.Rust.Cui;
using Oxide.Core.Plugins;
using UnityEngine;
using System.Linq;
namespace Oxide.Plugins {
[Info("Event Manager Menu Interface", "k1lly0u", "1.0.5", ResourceId = 2258)]
class EMInterface : RustPlugin {
#region Fields
[PluginReference]
EventManager EventManager;
[PluginReference]
Plugin ZoneManager;
[PluginReference]
Plugin Spawns;
[PluginReference]
Plugin Kits;
[PluginReference]
Plugin GunGame;
[PluginReference]
Plugin LustyMap;
static EMInterface eminterface;
private EventVoting EventVotes = new EventVoting();
private Dictionary<string, string> ItemNames = new Dictionary<string, string>();
private Dictionary<string, string> ClassContents = new Dictionary<string, string>();
private Dictionary<ulong, Timer> PopupTimers = new Dictionary<ulong, Timer>();
private Dictionary<ulong, List<string>> UIEntries = new Dictionary<ulong, List<string>>();
private Dictionary<ulong, EventManager.Events> EventCreators = new Dictionary<ulong, EventManager.Events>();
private Dictionary<ulong, AEConfig> AutoCreators = new Dictionary<ulong, AEConfig>();
private string UIMain = "EMUI_Main";
private string UIAdmin = "EMUI_Admin";
private string UIPanel = "EMUI_Panel";
private string UIPopup = "EMUI_Popup";
private string UIEntry = "EMUI_Entry";
private Dictionary<string, string> UIColors = new Dictionary<string, string>();
private string Color1;
private string Color2;
public bool VotingOpen = false;
public Timer VoteTallyTimer;
private DynamicConfigFile E_Conf;
public EventConfig Event_Config;
#endregion
#region Classes
public class EventConfig {
public Dictionary<string, EventManager.Events> Event_List = new Dictionary<string, EventManager.Events>();
public List<string> Classes = new List<string>();
public AutoEvents AutoEvent_Config = new AutoEvents();
}
public class AutoEvents {
public int GameInterval;
public bool AutoCancel;
public int AutoCancel_Timer;
public List<AEConfig> AutoEvent_List = new List<AEConfig>();
}
public class AEConfig {
public string EventConfig;
public int TimeLimit = 15;
public int TimeToJoin = 120;
public int TimeToStart = 60;
}
public class EventVoting {
private static Dictionary<int, int> EventVotes = new Dictionary<int, int>();
private static Dictionary<ulong, int> PlayerVotes = new Dictionary<ulong, int>();
private static List<ulong> OpenVotes = new List<ulong>();
private int requiredVotesToOpen = 0;
private static void ClearVotes() {
EventVotes.Clear();
PlayerVotes.Clear();
OpenVotes.Clear();
}
public static void OpenEventVoting(bool enable) {
ClearVotes();
if (enable) {
int i = 0;
foreach (var autocfg in eminterface.Event_Config.AutoEvent_Config.AutoEvent_List) {
EventVotes.Add(i, 0);
i++;
}
if (eminterface.EventManager._Launched && eminterface.configData.Voting.Auto_AllowEventVoting) {
eminterface.VotingOpen = true;
eminterface.VoteTallyTimer = eminterface.timer.Once((eminterface.Event_Config.AutoEvent_Config.GameInterval * 60) - 30, () => eminterface.EventVotes.ProcessEventVotes());
}
}
else {
eminterface.VotingOpen = false;
}
}
public void ProcessEventVotes() {
eminterface.VotingOpen = false;
int eventIndex = -1;
int voteCount = 0;
foreach (var vote in EventVotes) {
if (vote.Value > voteCount) {
eventIndex = vote.Key;
voteCount = vote.Value;
}
}
if (eventIndex != -1) {
if (!eminterface.EventManager._Launched) {
eminterface.EventManager._Event = eminterface.Event_Config.Event_List[eminterface.EventManager.ValidAutoEvents[eventIndex].EventConfig];
eminterface.EventManager.OpenEvent();
}
else {
eminterface.EventManager._AutoEventNum = eventIndex;
eminterface.EventManager._NextConfigName = eminterface.EventManager.ValidAutoEvents[eventIndex].EventConfig;
eminterface.EventManager._ForceNextConfig = true;
eminterface.EventManager.BroadcastToChat(string.Format("Event votes have been tallied.The next event will be: {0}", eminterface.Event_Config.Event_List.ToList()[eventIndex].Key));
}
}
ClearVotes();
}
public void VoteOpenEvent(ulong playerid) {
if (!OpenVotes.Contains(playerid)) OpenVotes.Add(playerid);
if (OpenVotes.Count >= requiredVotesToOpen) {
eminterface.VotingOpen = true;
eminterface.StartEventVoteTimer();
OpenVotes.Clear();
}
}
public void AddPlayerVote(ulong playerid, int index) {
if (!PlayerVotes.ContainsKey(playerid)) {
PlayerVotes.Add(playerid, index);
EventVotes[index]++;
}
}
public void RemovePlayerVote(ulong playerid) {
if (PlayerVotes.ContainsKey(playerid)) {
EventVotes[PlayerVotes[playerid]]--;
PlayerVotes.Remove(playerid);
}
}
public void SetVotesToOpen(int amount) => requiredVotesToOpen = amount;
public object GetVotedEvent(ulong playerid) {
int voted = -1;
if (!PlayerVotes.TryGetValue(playerid, out voted)) return null;
return voted;
}
public int GetVoteCount(int index) => EventVotes[index];
public int GetVoteOpenCount() => OpenVotes.Count;
public int GetRequiredCount() => requiredVotesToOpen;
public bool HasVotedOpen(ulong playerid) => OpenVotes.Contains(playerid);
}
#endregion
#region Oxide Hooks
void Loaded() {
E_Conf = Interface.Oxide.DataFileSystem.GetFile("EventManager/EventsConfig");
permission.RegisterPermission("eminterface.admin", this);
lang.RegisterMessages(Messages, this);
}
void OnServerInitialized() {
LoadVariables();
LoadData();
eminterface = this;
SetUIColors();
CollectItemDetails();
CollectClassList();
GetRequiredVoteLoop();
timer.In(15, () => {
if (EventManager) EventVoting.OpenEventVoting(true);
}
);
}
void Unload() {
foreach (var player in BasePlayer.activePlayerList) DestroyAllUI(player);
}
#endregion
#region Other
string msg(string key, BasePlayer player = null) => lang.GetMessage(key, this, player?.UserIDString);
[ChatCommand("event")]
private void cmdEventMenu(BasePlayer player, string command, string[] args) {
if (args != null && args.Length == 1) {
switch (args[0].ToLower()) {
case "join" : {
var success = EventManager.JoinEvent(player);
if (success is string) SendReply(player, (string)success);
}
return;
case "leave" : {
var success = EventManager.LeaveEvent(player);
if (success is string) SendReply(player, (string)success);
}
return;
case "start" : if (HasPerm(player)) {
var success = EventManager.StartEvent();
if (success is string) SendReply(player, (string)success);
}
return;
case "end" : if (HasPerm(player)) {
var success = EventManager.EndEvent();
if (success is string) SendReply(player, (string)success);
SendReply(player, msg("endingEvent", player));
}
return;
default : break;
}
}
OpenMenu(player);
}
#endregion
#region UI
private void OpenMenu(BasePlayer player) {
CloseMap(player);
CreateMenuMain(player);
CreateHome(player);
}
public void CreateMenuMain(BasePlayer player) {
var Main = EventManager.UI.CreateElementContainer(UIMain, UIColors["dark"], "0 0.92", "1 1", true);
EventManager.UI.CreatePanel(ref Main, UIMain, UIColors["light"], "0.01 0.03", "0.99 0.97", true);
EventManager.UI.CreateLabel(ref Main, UIMain, "", $"{Color1}{msg("Event Manager", player)} v{EventManager.Version}</color>", 30, "0.05 0", "0.2 1");
int i = 0;
CreateMenuButton(ref Main, UIMain, msg("Home", player), "EMI_ChangeElement home", i);
i++;
if (configData.Voting.Auto_AllowEventVoting || configData.Voting.Standard_AllowVoteToOpen) {
CreateMenuButton(ref Main, UIMain, msg("Voting", player), "EMI_ChangeElement voting", i);
i++;
}
CreateMenuButton(ref Main, UIMain, msg("Statistics", player), "EMI_ChangeElement stats", i);
i++;
if (EventManager._Started && EventManager.isPlaying(player) && EventManager._Event.UseClassSelector) {
CreateMenuButton(ref Main, UIMain, msg("Change Class", player), "EMI_ChangeElement selectclass", i);
i++;
}
if (HasPerm(player)) {
CreateMenuButton(ref Main, UIMain, msg("Admin", player), "EMI_ChangeElement admin", i);
i++;
}
CreateMenuButton(ref Main, UIMain, msg("Close", player), "EMI_DestroyAll", i);
CuiHelper.DestroyUi(player, UIMain);
CuiHelper.AddUi(player, Main);
}
private void CreateHome(BasePlayer player) {
var MainCont = EventManager.UI.CreateElementContainer(UIPanel, UIColors["dark"], "0 0", "1 0.92", false);
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["light"], "0.01 0.01", "0.495 0.55");
if (EventManager.GameStatistics.Stats.ContainsKey(player.userID)) {
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Your Statistics", player), 20, "0.1 0.48", "0.4 0.54");
var Stats = EventManager.StatsCache[player.userID];
AddInfoEntry(ref MainCont, UIPanel, msg("Rank", player), Stats.Rank.ToString(), 0, 0.42f, 0.47f, 0.04f);
AddInfoEntry(ref MainCont, UIPanel, msg("K/D Ratio", player), GetRatio(Stats.Kills, Stats.Deaths), 1, 0.42f, 0.47f, 0.04f);
AddInfoEntry(ref MainCont, UIPanel, msg("Games Played", player), Stats.GamesPlayed.ToString(), 2, 0.42f, 0.47f, 0.04f);
AddInfoEntry(ref MainCont, UIPanel, msg("Games Won", player), Stats.GamesWon.ToString(), 3, 0.42f, 0.47f, 0.04f);
AddInfoEntry(ref MainCont, UIPanel, msg("Games Lost", player), Stats.GamesLost.ToString(), 4, 0.42f, 0.47f, 0.04f);
AddInfoEntry(ref MainCont, UIPanel, msg("Kills", player), Stats.Kills.ToString(), 5, 0.42f, 0.47f, 0.04f);
AddInfoEntry(ref MainCont, UIPanel, msg("Deaths", player), Stats.Deaths.ToString(), 6, 0.42f, 0.47f, 0.04f);
AddInfoEntry(ref MainCont, UIPanel, msg("Shots Fired", player), Stats.ShotsFired.ToString(), 7, 0.42f, 0.47f, 0.04f);
AddInfoEntry(ref MainCont, UIPanel, msg("Helicopters Killed", player), Stats.ChoppersKilled.ToString(), 8, 0.42f, 0.47f, 0.04f);
AddInfoEntry(ref MainCont, UIPanel, msg("Flags Captured", player), Stats.FlagsCaptured.ToString(), 9, 0.42f, 0.47f, 0.04f);
}
else EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("You do not have any saved data", player), 16, "0.1 0.2", "0.4 0.8");
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["light"], "0.01 0.56", "0.495 0.99");
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Event Status:", player), 18, "0.05 0.87", "0.25 0.93", TextAnchor.MiddleLeft);
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", GetEventStatus(), 18, "0.25 0.87", "0.5 0.93", TextAnchor.MiddleLeft);
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Autoevent Status:", player), 18, "0.05 0.81", "0.25 0.87", TextAnchor.MiddleLeft);
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", GetAutoEventStatus(), 18, "0.25 0.81", "0.5 0.87", TextAnchor.MiddleLeft);
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["light"], "0.5 0.01", "0.99 0.99");
if (EventManager._Open || EventManager._Started) {
GetEventInfo(ref MainCont, UIPanel);
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Current Game Scores", player), 18, "0.55 0.87", "0.95 0.93");
GetGameScores(ref MainCont, UIPanel, 0.6f, 0.82f);
if (EventManager._Open) {
if (EventManager.isPlaying(player)) EventManager.UI.CreateButton(ref MainCont, UIPanel, UIColors["buttonbg"], msg("Leave Event", player), 18, "0.38 0.87", "0.48 0.92", "EMI_LeaveEvent");
else if (EventManager._Open) EventManager.UI.CreateButton(ref MainCont, UIPanel, UIColors["buttonbg"], msg("Join Event", player), 18, "0.38 0.87", "0.48 0.92", "EMI_JoinEvent");
}
}
else if (!EventManager._Open && !EventManager._Started) {
if (EventManager.GameScores.Scores != null && EventManager.GameScores.Scores.Count > 0) {
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Previous Game Scores", player), 18, "0.55 0.87", "0.95 0.93", TextAnchor.UpperCenter);
GetGameScores(ref MainCont, UIPanel, 0.6f, 0.82f);
}
}
CuiHelper.DestroyUi(player, UIPanel);
CuiHelper.AddUi(player, MainCont);
}
private void CreateVoting(BasePlayer player, int page = 0) {
var MainCont = EventManager.UI.CreateElementContainer(UIPanel, UIColors["dark"], "0 0", "1 0.92", false);
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["light"], "0.01 0.01", "0.99 0.99", true);
if (((configData.Voting.Standard_AllowVoteToOpen && !EventManager._Launched) || (configData.Voting.Auto_AllowEventVoting && EventManager._Launched)) && VotingOpen && !EventManager._Open && !EventManager._Started) {
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", $"Vote for the next event to play!", 18, "0.2 0.92", "0.8 0.98");
if (Event_Config.AutoEvent_Config.AutoEvent_List.Count > 9) {
var maxpages = (Event_Config.AutoEvent_Config.AutoEvent_List.Count - 1) / 9 + 1;
if (page < maxpages - 1) EventManager.UI.CreateButton(ref MainCont, UIPanel, UIColors["buttonbg"], "Next", 18, "0.84 0.925", "0.97 0.98", $"EMI_ChangePage vote {page + 1}");
if (page > 0) EventManager.UI.CreateButton(ref MainCont, UIPanel, UIColors["buttonbg"], "Back", 18, "0.03 0.925", "0.16 0.98", $"EMI_ChangePage vote {page - 1}");
}
int maxentries = (9 * (page + 1));
if (maxentries > Event_Config.AutoEvent_Config.AutoEvent_List.Count) maxentries = Event_Config.AutoEvent_Config.AutoEvent_List.Count;
int eventcount = 9 * page;
if (Event_Config.AutoEvent_Config.AutoEvent_List.Count == 0) EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", $"There are no saved auto-events", 18, "0.2 0.92", "0.8 0.98");
CuiHelper.DestroyUi(player, UIPanel);
CuiHelper.AddUi(player, MainCont);
int votedEvent = -1;
var hasVoted = EventVotes.GetVotedEvent(player.userID);
if (hasVoted != null) votedEvent = (int)hasVoted;
int i = 0;
for (int n = eventcount; n < maxentries; n++) {
var voteCount = EventVotes.GetVoteCount(n);
if (n == votedEvent) CreateEventEntry(player, $"Event {n}", Event_Config.Event_List[Event_Config.AutoEvent_Config.AutoEvent_List[n].EventConfig], $"EMI_EventVote unvote", $"{Color1}Unvote</color>", i, 0.32f);
else if (votedEvent > -1) CreateEventEntry(player, $"Event {n}", Event_Config.Event_List[Event_Config.AutoEvent_Config.AutoEvent_List[n].EventConfig], $"", $"", i, 0.32f);
else CreateEventEntry(player, $"Event {n}", Event_Config.Event_List[Event_Config.AutoEvent_Config.AutoEvent_List[n].EventConfig], $"EMI_EventVote vote {n}", $"{Color1}Vote</color> ({voteCount})", i, 0.32f);
i++;
}
}
else if (!configData.Voting.Standard_AllowVoteToOpen) {
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Voting requires auto events to be launched", player), 18, "0.2 0.92", "0.8 0.98");
CuiHelper.DestroyUi(player, UIPanel);
CuiHelper.AddUi(player, MainCont);
}
else if (configData.Voting.Standard_AllowVoteToOpen && !VotingOpen && !EventManager._Launched && !EventManager._Open && !EventManager._Started) {
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Vote to open a new event", player), 18, "0.2 0.92", "0.8 0.98");
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", string.Format(msg("Total Votes : {0}{1}</color>", player), Color1, EventVotes.GetVoteOpenCount()), 18, "0.2 0.75", "0.8 0.8");
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", string.Format(msg("Required Votes : {0}{1}</color>", player), Color1, EventVotes.GetRequiredCount()), 18, "0.2 0.7", "0.8 0.75");
if (EventVotes.HasVotedOpen(player.userID)) EventManager.UI.CreateButton(ref MainCont, UIPanel, UIColors["buttonbg"], msg("Voted", player), 18, "0.45 0.4", "0.55 0.45", "");
else EventManager.UI.CreateButton(ref MainCont, UIPanel, UIColors["buttonbg"], msg("Vote", player), 18, "0.45 0.4", "0.55 0.45", "EMI_EventVote open");
CuiHelper.DestroyUi(player, UIPanel);
CuiHelper.AddUi(player, MainCont);
}
else {
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", "Voting is currently disabled", 18, "0.2 0.92", "0.8 0.98");
CuiHelper.DestroyUi(player, UIPanel);
CuiHelper.AddUi(player, MainCont);
}
}
private void CreateStatistics(BasePlayer player) {
var MainCont = EventManager.UI.CreateElementContainer(UIPanel, UIColors["dark"], "0 0", "1 0.92", true);
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["light"], "0.01 0.01", "0.495 0.99");
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Global Statistics", player), 20, "0.1 0.92", "0.4 0.98");
int i = 0;
AddInfoEntry(ref MainCont, UIPanel, msg("Total Games Played", player), EventManager.GameStatistics.GetTotalGamesPlayed(), i, 0.85f, 0.9f, 0.05f);
i++;
AddInfoEntry(ref MainCont, UIPanel, msg("Total Player Kills", player), EventManager.GameStatistics.GetTotalKills(), i, 0.85f, 0.9f, 0.05f);
i++;
AddInfoEntry(ref MainCont, UIPanel, msg("Total Player Deaths", player), EventManager.GameStatistics.GetTotalDeaths(), i, 0.85f, 0.9f, 0.05f);
i++;
AddInfoEntry(ref MainCont, UIPanel, msg("Total Event Players", player), EventManager.GameStatistics.GetTotalPlayers(), i, 0.85f, 0.9f, 0.05f);
i++;
AddInfoEntry(ref MainCont, UIPanel, msg("Total Shots Fired", player), EventManager.GameStatistics.GetTotalShotsFired(), i, 0.85f, 0.9f, 0.05f);
i++;
if (EventManager.EventGames.ContainsKey("CaptureTheFlag")) {
AddInfoEntry(ref MainCont, UIPanel, msg("Total Flags Captured", player), EventManager.GameStatistics.GetFlagsCaptured(), i, 0.85f, 0.9f, 0.05f);
i++;
}
if (EventManager.EventGames.ContainsKey("ChopperSurvival")) {
AddInfoEntry(ref MainCont, UIPanel, msg("Total Helicopters Killed", player), EventManager.GameStatistics.GetChoppersKilled(), i, 0.85f, 0.9f, 0.05f);
i++;
}
i++;
foreach (var entry in EventManager.GameStatistics.GamesPlayed.OrderByDescending(x => x.Value)) {
AddInfoEntry(ref MainCont, UIPanel, entry.Key, entry.Value.ToString(), i, 0.85f, 0.9f, 0.05f);
i++;
}
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["light"], "0.5 0.01", "0.99 0.99");
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Leader Board", player), 20, "0.6 0.92", "0.9 0.98");
GetLeaderBoard(ref MainCont, UIPanel);
CuiHelper.DestroyUi(player, UIPanel);
CuiHelper.AddUi(player, MainCont);
}
private void CreateAdminMenu(BasePlayer player) {
var MenuElement = EventManager.UI.CreateElementContainer(UIAdmin, UIColors["dark"], "0.88 0", "1 0.92", true);
EventManager.UI.CreatePanel(ref MenuElement, UIAdmin, UIColors["light"], "0.01 0.01", "0.91 0.99", true);
int i = 0;
CreateAdminButton(ref MenuElement, UIAdmin, "Control", "EMI_ChangeElement control", i);
i++;
CreateAdminButton(ref MenuElement, UIAdmin, "Kick", "EMI_ChangeElement kick", i);
i++;
CreateAdminButton(ref MenuElement, UIAdmin, "Join", "EMI_ChangeElement join", i);
i++;
i++;
CreateAdminButton(ref MenuElement, UIAdmin, "Classes", "EMI_ChangeElement class", i);
i++;
i++;
CreateAdminButton(ref MenuElement, UIAdmin, "Events", "EMI_ChangeElement events", i);
i++;
CreateAdminButton(ref MenuElement, UIAdmin, "Create", "EMI_ChangeElement createevent", i);
i++;
i++;
CreateAdminButton(ref MenuElement, UIAdmin, "Auto Events", "EMI_ChangeElement auto", i);
i++;
CuiHelper.DestroyUi(player, UIAdmin);
CuiHelper.AddUi(player, MenuElement);
EventControl(player);
}
private void EventControl(BasePlayer player) {
var MainCont = EventManager.UI.CreateElementContainer(UIPanel, UIColors["dark"], "0 0", "0.88 0.92");
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["light"], "0.011 0.01", "0.99 0.99", true);
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("ControlHelp", player), 18, "0.2 0.92", "0.8 0.98");
int i = 1;
int p = 0;
AddInfoEntry(ref MainCont, UIPanel, msg("Event Status", player), GetEventStatus(), i);
i++;
if (!string.IsNullOrEmpty(EventManager._Event.EventType)) {
if (!EventManager._Open) {
CreateControlButton(ref MainCont, UIPanel, msg("Open", player), "EMI_Control open", 0.83f, p);
p++;
}
if (EventManager._Open) {
CreateControlButton(ref MainCont, UIPanel, msg("Close", player), "EMI_Control close", 0.83f, p);
p++;
}
if (EventManager._Open && !EventManager._Started) {
CreateControlButton(ref MainCont, UIPanel, msg("Start", player), "EMI_Control start", 0.83f, p);
p++;
}
if (EventManager._Started) {
CreateControlButton(ref MainCont, UIPanel, msg("End", player), "EMI_Control end", 0.83f, p);
p++;
}
}
else EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Select a event config or event type to proceed", player), 18, "0.5 0.82", "0.9 0.88", TextAnchor.MiddleLeft);
AddInfoEntry(ref MainCont, UIPanel, msg("Event Config", player), EventManager._CurrentEventConfig, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Control config", 0.88f - (0.05f * i), 0);
i++;
AddInfoEntry(ref MainCont, UIPanel, msg("Event Type", player), EventManager._Event.EventType, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Control type", 0.88f - (0.05f * i), 0);
i++;
if (!string.IsNullOrEmpty(EventManager._Event.EventType)) {
if (EventManager.EventGames[EventManager._Event.EventType].CanPlayBattlefield) {
AddInfoEntry(ref MainCont, UIPanel, msg("Gamemode", player), EventManager._Event.GameMode.ToString(), i);
CreateControlButton(ref MainCont, UIPanel, msg("Normal", player), $"EMI_Control gamemode normal", 0.88f - (0.05f * i), 0);
CreateControlButton(ref MainCont, UIPanel, msg("Battlefield", player), $"EMI_Control gamemode battlefield", 0.88f - (0.05f * i), 1);
i++;
}
if (!string.IsNullOrEmpty(EventManager.EventGames[EventManager._Event.EventType].ScoreType) && EventManager._Event.GameMode != EventManager.GameMode.Battlefield) {
AddInfoEntry(ref MainCont, UIPanel, $"{msg("Score Limit", player)} ({EventManager.EventGames[EventManager._Event.EventType].ScoreType})", EventManager._Event.ScoreLimit.ToString(), i);
CreateControlButton(ref MainCont, UIPanel, "+", $"EMI_Control scorelimit {EventManager._Event.ScoreLimit + 1}", 0.88f - (0.05f * i), 0);
CreateControlButton(ref MainCont, UIPanel, "-", $"EMI_Control scorelimit {EventManager._Event.ScoreLimit - 1}", 0.88f - (0.05f * i), 1);
i++;
}
AddInfoEntry(ref MainCont, UIPanel, msg("Max Players", player), EventManager._Event.MaximumPlayers.ToString(), i);
CreateControlButton(ref MainCont, UIPanel, "+", $"EMI_Control maxplayers {EventManager._Event.MaximumPlayers + 1}", 0.88f - (0.05f * i), 0);
CreateControlButton(ref MainCont, UIPanel, "-", $"EMI_Control maxplayers {EventManager._Event.MaximumPlayers - 1}", 0.88f - (0.05f * i), 1);
i++;
if (EventManager._Event.EventType == "GunGame") {
AddInfoEntry(ref MainCont, UIPanel, msg("Weapon Set", player), EventManager._Event.WeaponSet, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Control ggconfig", 0.88f - (0.05f * i), 0);
i++;
}
else if (EventManager.EventGames[EventManager._Event.EventType].RequiresKit && !EventManager._Event.UseClassSelector) {
AddInfoEntry(ref MainCont, UIPanel, msg("Kit", player), EventManager._Event.Kit, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Control kit", 0.88f - (0.05f * i), 0);
i++;
}
if (EventManager.EventGames[EventManager._Event.EventType].RequiresSpawns) {
AddInfoEntry(ref MainCont, UIPanel, msg("Spawnfile", player), EventManager._Event.Spawnfile, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Control spawns", 0.88f - (0.05f * i), 0);
i++;
if (EventManager.EventGames[EventManager._Event.EventType].RequiresMultipleSpawns) {
AddInfoEntry(ref MainCont, UIPanel, msg("Second Spawnfile", player), EventManager._Event.Spawnfile2, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Control spawns2", 0.88f - (0.05f * i), 0);
i++;
}
AddInfoEntry(ref MainCont, UIPanel, msg("Spawn Type", player), EventManager._Event.SpawnType.ToString(), i);
CreateControlButton(ref MainCont, UIPanel, msg("Consecutive", player), "EMI_Control spawntype seq", 0.88f - (0.05f * i), 0);
CreateControlButton(ref MainCont, UIPanel, msg("Random", player), "EMI_Control spawntype rand", 0.88f - (0.05f * i), 1);
i++;
}
AddInfoEntry(ref MainCont, UIPanel, msg("Zone ID", player), EventManager._Event.ZoneID, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Control zone", 0.88f - (0.05f * i), 0);
i++;
if (EventManager.EventGames[EventManager._Event.EventType].SpawnsEnemies) {
AddInfoEntry(ref MainCont, UIPanel, msg("Enemies to spawn", player), EventManager._Event.EnemiesToSpawn.ToString(), i);
CreateControlButton(ref MainCont, UIPanel, "+", $"EMI_Control enemycount {EventManager._Event.EnemiesToSpawn + 1}", 0.88f - (0.05f * i), 0);
CreateControlButton(ref MainCont, UIPanel, "-", $"EMI_Control enemycount {EventManager._Event.EnemiesToSpawn - 1}", 0.88f - (0.05f * i), 1);
i++;
}
if (EventManager.EventGames[EventManager._Event.EventType].IsRoundBased) {
AddInfoEntry(ref MainCont, UIPanel, msg("Rounds to play", player), EventManager._Event.GameRounds.ToString(), i);
CreateControlButton(ref MainCont, UIPanel, "+", $"EMI_Control roundcount {EventManager._Event.GameRounds + 1}", 0.88f - (0.05f * i), 0);
CreateControlButton(ref MainCont, UIPanel, "-", $"EMI_Control roundcount {EventManager._Event.GameRounds - 1}", 0.88f - (0.05f * i), 1);
i++;
}
if (EventManager.EventGames[EventManager._Event.EventType].CanUseClassSelector) {
AddInfoEntry(ref MainCont, UIPanel, msg("Class Selector", player), EventManager._Event.UseClassSelector.ToString(), i);
if (!EventManager._Event.UseClassSelector) CreateControlButton(ref MainCont, UIPanel, msg("Enable", player), "EMI_Control classtoggle", 0.88f - (0.05f * i), 0);
else CreateControlButton(ref MainCont, UIPanel, msg("Disable", player), "EMI_Control classtoggle", 0.88f - (0.05f * i), 0);
i++;
}
AddInfoEntry(ref MainCont, UIPanel, msg("Disable Item Pickup", player), EventManager._Event.DisableItemPickup.ToString(), i);
if (!EventManager._Event.DisableItemPickup) CreateControlButton(ref MainCont, UIPanel, msg("Enable", player), "EMI_Control pickuptoggle", 0.88f - (0.05f * i), 0);
else CreateControlButton(ref MainCont, UIPanel, msg("Disable", player), "EMI_Control pickuptoggle", 0.88f - (0.05f * i), 0);
i++;
if (!EventManager.EventGames[EventManager._Event.EventType].ForceCloseOnStart) {
AddInfoEntry(ref MainCont, UIPanel, msg("Close On Start", player), EventManager._Event.CloseOnStart.ToString(), i);
if (!EventManager._Event.CloseOnStart) CreateControlButton(ref MainCont, UIPanel, msg("Enable", player), "EMI_Control costoggle", 0.88f - (0.05f * i), 0);
else CreateControlButton(ref MainCont, UIPanel, msg("Disable", player), "EMI_Control costoggle", 0.88f - (0.05f * i), 0);
i++;
i++;
}
if (EventManager.EventGames[EventManager._Event.EventType].CanChooseRespawn) {
AddInfoEntry(ref MainCont, UIPanel, msg("Respawn Type", player), EventManager._Event.RespawnType.ToString(), i);
CreateControlButton(ref MainCont, UIPanel, msg("None", player), "EMI_Control respawn none", 0.88f - (0.05f * i), 0);
CreateControlButton(ref MainCont, UIPanel, msg("Timer", player), "EMI_Control respawn timer", 0.88f - (0.05f * i), 1);
CreateControlButton(ref MainCont, UIPanel, msg("Waves", player), "EMI_Control respawn wave", 0.88f - (0.05f * i), 2);
i++;
if (EventManager._Event.RespawnType != EventManager.RespawnType.None) {
AddInfoEntry(ref MainCont, UIPanel, msg("Respawn Timer (seconds)", player), EventManager._Event.RespawnTimer.ToString(), i);
CreateControlButton(ref MainCont, UIPanel, "+", $"EMI_Control respawntime {EventManager._Event.RespawnTimer + 1}", 0.88f - (0.05f * i), 0);
CreateControlButton(ref MainCont, UIPanel, "-", $"EMI_Control respawntime {EventManager._Event.RespawnTimer - 1}", 0.88f - (0.05f * i), 1);
i++;
}
}
}
CuiHelper.DestroyUi(player, UIPanel);
CuiHelper.AddUi(player, MainCont);
}
private void EventClasses(BasePlayer player) {
var MainCont = EventManager.UI.CreateElementContainer(UIPanel, UIColors["dark"], "0 0", "0.88 0.92");
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["light"], "0.011 0.01", "0.99 0.99", true);
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Add or remove kits from the class selector", player), 18, "0.2 0.92", "0.8 0.98");
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Available Kits", player), 18, "0.05 0.86", "0.76 0.92");
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Available Classes", player), 18, "0.8 0.86", "0.95 0.92");
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["medium"], "0.05 0.05", "0.76 0.85", true);
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["medium"], "0.8 0.05", "0.95 0.85", true);
var classList = Event_Config.Classes;
var kitList = GetKits();
var Kits = GetKits();
if (Kits != null && Kits is string[]) {
int i = 0;
foreach (var kit in (string[])Kits) {
if (classList.Contains(kit)) continue;
CreateClassEditorButton(ref MainCont, UIPanel, kit, i, true);
i++;
}
if (i == 0) EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Unable to find any kits", player), 18, "0.1 0.5", "0.45 0.6");
}
if (classList != null) {
int i = 0;
foreach (var entry in classList) {
CreateClassEditorButton(ref MainCont, UIPanel, entry, i, false);
i++;
}
if (i == 0) EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("No classes have been added", player), 18, "0.6 0.5", "0.9 0.6");
}
CuiHelper.DestroyUi(player, UIPanel);
CuiHelper.AddUi(player, MainCont);
}
private void EventAutoEvent(BasePlayer player, int page = 0) {
if (!AutoCreators.ContainsKey(player.userID)) AutoCreators.Add(player.userID, new AEConfig());
var autocfg = AutoCreators[player.userID];
var MainCont = EventManager.UI.CreateElementContainer(UIPanel, UIColors["dark"], "0 0", "0.88 0.92");
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["light"], "0.011 0.01", "0.99 0.99", true);
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Manage the auto event roster and settings", player), 18, "0.2 0.92", "0.8 0.98");
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Auto-Event Settings", player), 18, "0.05 0.86", "0.45 0.92");
int info = 2;
AddInfoAuto(ref MainCont, UIPanel, msg("Auto-Event Status", player), GetAutoEventStatus(), info);
if (!EventManager._Launched) CreateControlButtonSmall(ref MainCont, UIPanel, msg("Enable", player), "EMI_Control aeenable", 0.88f - (0.06f * info), 0);
else CreateControlButtonSmall(ref MainCont, UIPanel, msg("Disable", player), "EMI_Control aedisable", 0.88f - (0.06f * info), 0);
info++;
AddInfoAuto(ref MainCont, UIPanel, msg("Next Event", player), EventManager._NextConfigName, info);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Change", player), "EMI_Control nextevent", 0.88f - (0.06f * info), 0);
info++;
AddInfoAuto(ref MainCont, UIPanel, msg("Auto Cancel", player), Event_Config.AutoEvent_Config.AutoCancel.ToString(), info);
if (Event_Config.AutoEvent_Config.AutoCancel) CreateControlButtonSmall(ref MainCont, UIPanel, msg("Disable", player), "EMI_AutoEditor cancel 1", 0.88f - (0.06f * info), 0);
else CreateControlButtonSmall(ref MainCont, UIPanel, msg("Enable", player), "EMI_AutoEditor cancel 1", 0.88f - (0.06f * info), 0);
info++;
AddInfoAuto(ref MainCont, UIPanel, msg("Game Interval (minutes)", player), Event_Config.AutoEvent_Config.GameInterval.ToString(), info);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Increase", player), $"EMI_AutoEditor gameinterval {Event_Config.AutoEvent_Config.GameInterval + 1}", 0.88f - (0.06f * info), 0);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Decrease", player), $"EMI_AutoEditor gameinterval {Event_Config.AutoEvent_Config.GameInterval - 1}", 0.88f - (0.06f * info), 1);
info++;
AddInfoAuto(ref MainCont, UIPanel, msg("Auto Cancel Timer (minutes)", player), Event_Config.AutoEvent_Config.AutoCancel_Timer.ToString(), info);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Increase", player), $"EMI_AutoEditor canceltimer {Event_Config.AutoEvent_Config.AutoCancel_Timer + 1}", 0.88f - (0.06f * info), 0);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Decrease", player), $"EMI_AutoEditor canceltimer {Event_Config.AutoEvent_Config.AutoCancel_Timer - 1}", 0.88f - (0.06f * info), 1);
info++;
AddInfoAuto(ref MainCont, UIPanel, msg("Randomize List", player), EventManager._RandomizeAuto.ToString(), info);
if (EventManager._RandomizeAuto) CreateControlButtonSmall(ref MainCont, UIPanel, msg("Disable", player), "EMI_AutoEditor randomize 1", 0.88f - (0.06f * info), 0);
else CreateControlButtonSmall(ref MainCont, UIPanel, msg("Enable", player), "EMI_AutoEditor randomize 1", 0.88f - (0.06f * info), 0);
info++;
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Auto-Event Creator", player), 18, "0.05 0.36", "0.45 0.42");
info = 10;
AddInfoAuto(ref MainCont, UIPanel, msg("Event Config", player), autocfg.EventConfig, info);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Change", player), "EMI_NewAutoConfig newconf", 0.88f - (0.06f * info), 0);
info++;
AddInfoAuto(ref MainCont, UIPanel, msg("Join Timer (seconds)", player), autocfg.TimeToJoin.ToString(), info);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Increase", player), $"EMI_NewAutoConfig jointimer {autocfg.TimeToJoin + 1}", 0.88f - (0.06f * info), 0);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Decrease", player), $"EMI_NewAutoConfig jointimer {autocfg.TimeToJoin - 1}", 0.88f - (0.06f * info), 1);
info++;
AddInfoAuto(ref MainCont, UIPanel, msg("Start Timer (seconds)", player), autocfg.TimeToStart.ToString(), info);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Increase", player), $"EMI_NewAutoConfig starttimer {autocfg.TimeToStart + 1}", 0.88f - (0.06f * info), 0);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Decrease", player), $"EMI_NewAutoConfig starttimer {autocfg.TimeToStart - 1}", 0.88f - (0.06f * info), 1);
info++;
AddInfoAuto(ref MainCont, UIPanel, msg("Time Limit (minutes)", player), autocfg.TimeLimit.ToString(), info);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Increase", player), $"EMI_NewAutoConfig timelimit {autocfg.TimeLimit + 1}", 0.88f - (0.06f * info), 0);
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Decrease", player), $"EMI_NewAutoConfig timelimit {autocfg.TimeLimit - 1}", 0.88f - (0.06f * info), 1);
info++;
CreateControlButtonSmall(ref MainCont, UIPanel, msg("Save Config", player), $"EMI_NewAutoConfig saveconfig {autocfg.TimeLimit + 1}", 0.88f - (0.06f * info), 0);
EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("Auto-Event Roster", player), 18, "0.45 0.86", "0.98 0.92");
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["medium"], "0.45 0.075", "0.98 0.85", true);
var autoList = Event_Config.AutoEvent_Config.AutoEvent_List;
if (autoList != null) {
if (autoList.Count > 12) {
var maxpages = (autoList.Count - 1) / 12 + 1;
if (page < maxpages - 1) EventManager.UI.CreateButton(ref MainCont, UIPanel, UIColors["buttonbg"], msg("Next", player), 18, "0.84 0.015", "0.97 0.07", $"EMI_ChangePage autoevent {page + 1}");
if (page > 0) EventManager.UI.CreateButton(ref MainCont, UIPanel, UIColors["buttonbg"], msg("Back", player), 18, "0.46 0.015", "0.59 0.07", $"EMI_ChangePage autoevent {page - 1}");
}
int maxentries = (12 * (page + 1));
if (maxentries > autoList.Count) maxentries = autoList.Count;
int autocount = 12 * page;
int i = 0;
for (int n = autocount; n < maxentries; n++) {
CreateAutoEventEditorButton(ref MainCont, UIPanel, autoList[n], i, n);
i++;
}
if (i == 0) EventManager.UI.CreateLabel(ref MainCont, UIPanel, "", msg("No auto events have been added", player), 18, "0.5 0.5", "0.9 0.6");
}
CuiHelper.DestroyUi(player, UIPanel);
CuiHelper.AddUi(player, MainCont);
}
private void EventCreator(BasePlayer player, int page = 0) {
var MainCont = EventManager.UI.CreateElementContainer(UIPanel, UIColors["dark"], "0 0", "0.88 0.92");
EventManager.UI.CreatePanel(ref MainCont, UIPanel, UIColors["light"], "0.011 0.01", "0.99 0.99", true);
var infoMessage = msg("CreateHelp", player);
int i = 1;
var newEvent = EventCreators[player.userID];
AddInfoEntry(ref MainCont, UIPanel, msg("Event Type", player), newEvent.EventType, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Creator type", 0.88f - (0.05f * i), 0);
i++;
if (!string.IsNullOrEmpty(newEvent.EventType)) {
infoMessage = msg("CreateHelp2", player);
if (newEvent.EventType == "GunGame") {
AddInfoEntry(ref MainCont, UIPanel, msg("Weapon Set", player), newEvent.WeaponSet, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Creator ggconfig", 0.88f - (0.05f * i), 0);
i++;
}
else if (EventManager.EventGames[newEvent.EventType].RequiresKit && !newEvent.UseClassSelector) {
AddInfoEntry(ref MainCont, UIPanel, msg("Kit", player), newEvent.Kit, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Creator kit", 0.88f - (0.05f * i), 0);
i++;
}
if (EventManager.EventGames[newEvent.EventType].RequiresSpawns) {
AddInfoEntry(ref MainCont, UIPanel, msg("Spawnfile", player), newEvent.Spawnfile, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Creator spawns", 0.88f - (0.05f * i), 0);
i++;
if (EventManager.EventGames[newEvent.EventType].RequiresMultipleSpawns) {
AddInfoEntry(ref MainCont, UIPanel, msg("Second Spawnfile", player), newEvent.Spawnfile2, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Creator spawns2", 0.88f - (0.05f * i), 0);
i++;
}
AddInfoEntry(ref MainCont, UIPanel, msg("Spawn Type", player), newEvent.SpawnType.ToString(), i);
CreateControlButton(ref MainCont, UIPanel, msg("Consecutive", player), "EMI_Creator spawntype seq", 0.88f - (0.05f * i), 0);
CreateControlButton(ref MainCont, UIPanel, msg("Random", player), "EMI_Creator spawntype rand", 0.88f - (0.05f * i), 1);
i++;
}
AddInfoEntry(ref MainCont, UIPanel, msg("Zone ID", player), newEvent.ZoneID, i);
CreateControlButton(ref MainCont, UIPanel, msg("Change", player), "EMI_Creator zone", 0.88f - (0.05f * i), 0);
i++;
if (EventManager.EventGames[newEvent.EventType].CanPlayBattlefield) {
AddInfoEntry(ref MainCont, UIPanel, msg("Gamemode", player), newEvent.GameMode.ToString(), i);
CreateControlButton(ref MainCont, UIPanel, msg("Normal", player), $"EMI_Creator gamemode normal", 0.88f - (0.05f * i), 0);
CreateControlButton(ref MainCont, UIPanel, msg("Battlefield", player), $"EMI_Creator gamemode battlefield", 0.88f - (0.05f * i), 1);
i++;
}
if (!string.IsNullOrEmpty(EventManager.EventGames[newEvent.EventType].ScoreType) && newEvent.GameMode != EventManager.GameMode.Battlefield) {
AddInfoEntry(ref MainCont, UIPanel, $"{msg("Score Limit", player)} ({EventManager.EventGames[newEvent.EventType].ScoreType})", newEvent.ScoreLimit.ToString(), i);
CreateControlButton(ref M
// ... [Code preview truncated due to length. Full source in attached file] ...