public bool ChangeRankOption(PlayerObject Self, byte RankIndex, int Option, string Enabled) { if ((RankIndex >= Ranks.Count) || (Option > 7)) { Self.ReceiveChatTr("Rank not found!", ChatType.System); return(false); } if (Self.MyGuildRank.Index >= RankIndex) { Self.ReceiveChatTr("You cannot change the options of your own rank!", ChatType.System); return(false); } if ((Enabled != "true") && (Enabled != "false")) { return(false); } Ranks[RankIndex].Options = Enabled == "true" ? Ranks[RankIndex].Options |= (RankOptions)(1 << Option) : Ranks[RankIndex].Options ^= (RankOptions)(1 << Option); List <Rank> NewRankList = new List <Rank>(); NewRankList.Add(Ranks[RankIndex]); SendServerPacket(new ServerPackets.GuildMemberChange() { Name = Self.Name, Status = (byte)7, Ranks = NewRankList }); NeedSave = true; return(true); }
public bool NewRank(PlayerObject Self) { if (Ranks.Count >= byte.MaxValue) { Self.ReceiveChatTr("You cannot have anymore ranks.", ChatType.System); return(false); } int NewIndex = Ranks.Count > 1? Ranks.Count - 1: 1; Rank NewRank = new Rank() { Index = NewIndex, Name = String.Format("Rank-{0}", NewIndex), Options = (RankOptions)0 }; Ranks.Insert(NewIndex, NewRank); Ranks[Ranks.Count - 1].Index = Ranks.Count - 1; List <Rank> NewRankList = new List <Rank>(); NewRankList.Add(NewRank); SendServerPacket(new ServerPackets.GuildMemberChange() { Name = Self.Name, Status = (byte)6, Ranks = NewRankList }); NeedSave = true; return(true); }
public bool DeleteMember(PlayerObject Kicker, string membername) {//carefull this can lead to guild with no ranks or members(or no leader) GuildMember Member = null; Rank MemberRank = null; if ((Kicker.MyGuild != this) || (Kicker.MyGuildRank == null)) { return(false); } for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if (Ranks[i].Members[j].name == membername) { Member = Ranks[i].Members[j]; MemberRank = Ranks[i]; goto Found; } } } Found: if (Member == null) { return(false); } if (((Kicker.MyGuildRank.Index >= MemberRank.Index) && (Kicker.MyGuildRank.Index != 0)) && (Kicker.Info.Name != membername)) { Kicker.ReceiveChatTr("Your rank is not adequate.", ChatType.System); return(false); } if (MemberRank.Index == 0) { if (MemberRank.Members.Count < 2) { Kicker.ReceiveChatTr("You cannot leave the guild when you're leader.", ChatType.System); return(false); } for (int i = 0; i < MemberRank.Members.Count; i++) { if ((MemberRank.Members[i].Online) && (MemberRank.Members[i] != Member)) { goto AllOk; } } Kicker.ReceiveChatTr("You need at least 1 leader online.", ChatType.System); return(false); } AllOk: MemberDeleted(membername, (PlayerObject)Member.Player, Member.name == Kicker.Info.Name); if (Member.Player != null) { PlayerObject LeavingMember = (PlayerObject)Member.Player; LeavingMember.RefreshStats(); } MemberRank.Members.Remove(Member); NeedSave = true; Membercount--; return(true); }
public bool ChangeRank(PlayerObject Self, string membername, byte RankIndex, string RankName = "Members") { if ((Self.MyGuild != this) || (Self.MyGuildRank == null)) { return(false); } if (RankIndex >= Ranks.Count) { return(false); } GuildMember Member = null; Rank MemberRank = null; for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if (Ranks[i].Members[j].name == membername) { Member = Ranks[i].Members[j]; MemberRank = Ranks[i]; goto Found; } } } Found: if (Member == null) { return(false); } MirDatabase.CharacterInfo Character = Envir.GetCharacterInfo(membername); if (Character == null) { return(false); } if ((RankIndex == 0) && (Character.Level < Settings.Guild_RequiredLevel)) { Self.ReceiveChat(String.Format("A guild leader needs to be at least level {0}", Settings.Guild_RequiredLevel), ChatType.System); return(false); } if ((MemberRank.Index >= Self.MyGuildRank.Index) && (Self.MyGuildRank.Index != 0)) { return(false); } if (MemberRank.Index == 0) { if (MemberRank.Members.Count <= 2) { Self.ReceiveChatTr("A guild needs at least 2 leaders.", ChatType.System); return(false); } for (int i = 0; i < MemberRank.Members.Count; i++) { if ((MemberRank.Members[i].Player != null) && (MemberRank.Members[i] != Member)) { goto AllOk; } } Self.ReceiveChatTr("You need at least 1 leader online.", ChatType.System); return(false); } AllOk: Ranks[RankIndex].Members.Add(Member); MemberRank.Members.Remove(Member); MemberRank = Ranks[RankIndex]; List <Rank> NewRankList = new List <Rank>(); NewRankList.Add(Ranks[RankIndex]); NeedSave = true; PlayerObject player = (PlayerObject)Member.Player; if (player != null) { player.MyGuildRank = Ranks[RankIndex]; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = Self.Info.Name, Status = (byte)8, Ranks = NewRankList }); player.BroadcastInfo(); } for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if ((Ranks[i].Members[j].Player != null) && (Ranks[i].Members[j].Player != Member.Player)) { player = (PlayerObject)Ranks[i].Members[j].Player; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = Member.name, Status = (byte)5, RankIndex = (byte)MemberRank.Index }); player.GuildMembersChanged = true; } } } return(true); }