public bool OnCheckUndead(Player killer, Player victim) { if (this.undead > 0 && this.Teamkillers[killer.UserId].Teamkills.Count >= this.undead && !this.isImmune(killer)) { Smod2.API.RoleType oldRole = victim.TeamRole.Role; //Vector oldPosition = victim.GetPosition(); this.Info("Player " + victim.Name + " " + victim.UserId + " " + victim.IpAddress + " has been respawned as " + oldRole + " after " + killer.Name + " " + killer.UserId + " " + killer.IpAddress + " teamkilled " + this.Teamkillers[killer.UserId].Teamkills.Count + " times."); killer.PersonalBroadcast(5, string.Format(this.GetTranslation("undead_killer_output"), victim.Name), false); victim.PersonalBroadcast(5, string.Format(this.GetTranslation("undead_victim_output"), killer.Name), false); Timer t = new Timer { Interval = 3000, Enabled = true }; t.Elapsed += delegate { this.Info("Respawning victim " + victim.Name + " " + victim.UserId + " " + victim.IpAddress + "as " + victim.TeamRole.Role + "..."); victim.ChangeRole(victim.TeamRole.Role, true, false, false, true); //victim.Teleport(oldPosition); t.Dispose(); }; return(true); } else { return(false); } }
/// <summary> /// Safely getting a <see cref="Smod2.API.Role"/> from an <see cref="int"/>. /// <returns>Returns <see cref="bool"/> based on success</returns> /// <para>Invalid <see cref="int"/> parameters returns <see cref="SMRoleType"/></para> /// </summary> public static bool TryParseRole(int roleID, out SMRoleType role) { try { role = (SMRoleType)roleID; } catch { role = SMRoleType.NONE; return(false); } return(true); }