public void MemberDeleted(string name, PlayerObject formermember, bool kickself) { PlayerObject player = null; 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 != formermember)) { player = (PlayerObject)Ranks[i].Members[j].Player; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = name, Status = (byte)(kickself ? 4:3) }); player.GuildMembersChanged = true; } } } if (formermember != null) { formermember.Info.GuildIndex = -1; formermember.MyGuild = null; formermember.MyGuildRank = null; formermember.ReceiveChat(kickself ? "你已经离开了行会。" : "你被请出行会。", ChatType.Guild); formermember.RefreshStats(); formermember.Enqueue(new ServerPackets.GuildStatus() { GuildName = "", GuildRankName = "", MyOptions = (RankOptions)0 }); formermember.BroadcastInfo(); } }
public bool ChangeRankName(PlayerObject Self, string RankName, byte RankIndex) { int SelfRankIndex = -1; for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if (Ranks[i].Members[j].Player == Self) { SelfRankIndex = i; break; } } } if (SelfRankIndex > RankIndex) { Self.ReceiveChat("Your rank is not adequate.", ChatType.System); return(false); } if (RankIndex >= Ranks.Count) { return(false); } Ranks[RankIndex].Name = RankName; List <GuildRank> NewRankList = new List <GuildRank> { Ranks[RankIndex] }; for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { PlayerObject player = (PlayerObject)Ranks[i].Members[j].Player; if (player != null) { player.Enqueue(new ServerPackets.GuildMemberChange() { Name = Self.Info.Name, Status = (byte)7, Ranks = NewRankList }); player.GuildMembersChanged = true; if (i == RankIndex) { player.BroadcastInfo(); } } } } NeedSave = true; return(true); }
public void UpdatePlayersColours() { for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { //in a way this is a horrible spam situation, it should only broadcast to your own guild or enemy or allies guild but not sure i wanna code yet another broadcast for that PlayerObject player = (PlayerObject)Ranks[i].Members[j].Player; if (player != null) { //player.Enqueue(player.GetInfoEx(player)); player.Enqueue(new ServerPackets.ColourChanged { NameColour = player.GetNameColour(player) }); player.BroadcastInfo(); } } } }
public void MemberDeleted(string name, PlayerObject formermember, bool kickself) { PlayerObject player = null; 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 != formermember)) { player = (PlayerObject)Ranks[i].Members[j].Player; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = name, Status = (byte)(kickself ? 4:3) }); player.GuildMembersChanged = true; } } } if (formermember != null) { formermember.Info.GuildIndex = -1; string UpdateGuild = "UPDATE " + Settings.DBAccount + ".characterinfo SET GuildIndex = '" + formermember.Info.GuildIndex + "' WHERE IndexID = '" + formermember.Info.Index + "'"; Envir.ConnectADB.Update(UpdateGuild); formermember.MyGuild = null; formermember.MyGuildRank = null; formermember.ReceiveChat(kickself ? "You have left your guild." : "You have been removed from your guild.", ChatType.Guild); formermember.RefreshStats(); formermember.Enqueue(new ServerPackets.GuildStatus() { GuildName = "", GuildRankName = "", MyOptions = (RankOptions)0 }); formermember.BroadcastInfo(); } }
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("行会领导者至少需要{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.ReceiveChat("行会至少需要2名领导。", 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.ReceiveChat("需要至少1个领导在线。", 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); }
public void MemberDeleted(string name, PlayerObject formermember, bool kickself) { PlayerObject player = null; 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 != formermember)) { player = (PlayerObject)Ranks[i].Members[j].Player; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = name, Status = (byte)(kickself ? 4:3) }); player.GuildMembersChanged = true; } } if (formermember != null) { formermember.Info.GuildIndex = -1; formermember.MyGuild = null; formermember.MyGuildRank = null; formermember.ReceiveChat(kickself ? "You have left your guild." : "You have been removed from your guild.", ChatType.Guild); formermember.Enqueue(new ServerPackets.GuildStatus() { GuildName = "", GuildRankName = "", MyOptions = (RankOptions)0 }); formermember.BroadcastInfo(); } }
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; GuildRank 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.ReceiveChat("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.ReceiveChat("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 <GuildRank> NewRankList = new List <GuildRank> { 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); }