public static void ChangeRole(Player p, CustomRole newRole) { if (p == null) { return; } if (newRole == null || !roles.ContainsKey(newRole.id)) { if (users.ContainsKey(p.UserId)) { users.Remove(p.UserId); } return; } AdvancedSubclassing.RemovePlayer(p); if (!users.ContainsKey(p.UserId)) { users[p.UserId] = newRole.id; roles[newRole.id].members.Add(p.UserId); } else { roles[users[p.UserId]].members.Remove(p.UserId); users[p.UserId] = newRole.id; roles[newRole.id].members.Add(p.UserId); } if (newRole.isSubclass) { AdvancedSubclassing.SetClass(p, newRole.id.Substring(2)); } }
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 List <Player> GetMembers() { return(this.id == "all" ? Player.List.ToList() : this.isSubclass ? AdvancedSubclassing.GetPlayers(id.Substring(2)) : Player.List.Where(p => members.Contains(p.UserId)).ToList()); }