public static bool IsDeserter(PlayerMobile pm) { return(pm != null && pm.Account != null && Deserters.GetValue(pm.Account) != null); }
public static void SetDeserter(PlayerMobile pm, bool state, bool message) { if (pm == null) { return; } var t = Deserters.GetValue(pm.Account); if (t != null && t.Running) { t.Stop(); } if (state && CMOptions.Advanced.Misc.DeserterLockout > TimeSpan.Zero) { Deserters[pm.Account] = t = Timer.DelayCall(CMOptions.Advanced.Misc.DeserterLockout, RemoveDeserter, pm); if (message) { pm.SendMessage(0x22, "You have deserted your team and must wait until you can join another battle."); } if (!CMOptions.Advanced.Misc.DeserterAssoc) { return; } foreach (var a in pm.Account.FindSharedAccounts().Where(a => a != pm.Account && !Deserters.ContainsKey(a))) { Deserters[a] = t; var p = a.GetOnlineMobile(); if (p != null) { p.SendMessage(0x22, "{0} has deserted a battle!", pm.RawName); p.SendMessage(0x22, "You must wait until you can join a battle because you have associated accounts."); } } } else { if (Deserters.Remove(pm.Account) && message) { pm.SendMessage(0x55, "You are no longer known as a deserter and may now join battles."); } if (t == null) { return; } Deserters.RemoveRange( o => { if (o.Value == null) { return(true); } if (o.Value == t) { var p = o.Key.GetOnlineMobile(); if (p != null) { p.SendMessage(0x55, "You are no longer associated with a deserter and may now join battles."); } return(true); } return(false); }); } }