public static void Reset() { foreach (var coroutine in coroutines) { Timing.KillCoroutines(coroutine); } CustomRoles.roles = new Dictionary <string, CustomRole>(); CustomRoles.users = new Dictionary <string, string>(); CustomRoles.roles.Add("all", new CustomRole("all", 2)); scriptData = new ScriptActionsStore(); delays = new Dictionary <int, ScriptActionsStore>(); Timing.CallDelayed(10f, () => { try { AdvancedSubclassing.PopulateCustomRoles(); if (EasyEvents.Singleton.Config.Events.Count > 0) { var selected = EasyEvents.Singleton.Config.Events.PickRandom().Trim().ToLower().Replace(" ", ""); if (selected == "none") { return; } if (!ScriptStore.Scripts.ContainsKey(selected)) { throw new EventNotFoundException("The event \"" + selected + "\" was not found while attempting to automatically run an event."); } ScriptHandler.RunScript(ScriptStore.Scripts[selected]); } } catch (Exception e) { Log.Error(e); } }); }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { var permission = false; var perPermission = false; if (arguments.Array == null || arguments.Array.Length < 2) { response = "Usage: event <event name>"; return(true); } var command = arguments.Array[1].Trim().ToLower().Replace(" ", ""); if (sender is PlayerCommandSender player) { permission = player.CheckPermission("easyevents.use"); perPermission = player.CheckPermission("easyevents.event." + command); } else { permission = true; perPermission = true; } if (EasyEvents.Singleton.Config.PerEventPermissions && !perPermission) { response = "You do not have permission to run this event."; return(true); } if (!permission) { response = "You do not have permission to run this command."; return(true); } if (!ScriptStore.Scripts.ContainsKey(command)) { response = "Event \"" + command + "\" does not exist!"; return(true); } if (!ScriptStore.Scripts.TryGetValue(command, out var text)) { response = "Event \"" + command + "\" does not exist!"; return(true); } if (Exiled.API.Features.Round.IsStarted) { response = "Events can only be ran before the round is started."; return(true); } if (ScriptActions.scriptData.eventRan) { response = "Only one event can be ran per round. Restart the round to run this event."; return(true); } try { ScriptHandler.RunScript(text); response = "Event \"" + command + "\" started successfully"; ScriptActions.scriptData.eventRan = true; return(true); } catch (Exception e) { response = e.ToString(); return(true); } }