public override async void Process(Level level) { try { ClientAvatar player = level.GetPlayerAvatar(); Alliance all = await ObjectManager.GetAlliance(ID); InvitationStreamEntry cm = new InvitationStreamEntry(); cm.SetId(all.GetChatMessages().Count + 1); cm.SetSenderId(player.GetId()); cm.SetHomeId(player.GetId()); cm.SetSenderLeagueId(player.GetLeagueId()); cm.SetSenderName(player.GetAvatarName()); cm.SetSenderRole(await player.GetAllianceRole()); cm.SetMessage(Message); cm.SetState(1); all.AddChatMessage(cm); foreach (AllianceMemberEntry op in all.GetAllianceMembers()) { Level playera = await ResourcesManager.GetPlayer(op.GetAvatarId()); if (playera.GetClient() != null) { AllianceStreamEntryMessage p = new AllianceStreamEntryMessage(playera.GetClient()); p.SetStreamEntry(cm); PacketProcessor.Send(p); } } } catch (Exception) { } }
public override void Process(Level level) { ClientAvatar player = level.GetPlayerAvatar(); Alliance all = ObjectManager.GetAlliance(ID); InvitationStreamEntry cm = new InvitationStreamEntry(); cm.SetId(all.GetChatMessages().Count + 1); cm.SetSenderId(player.GetId()); cm.SetHomeId(player.GetId()); cm.SetSenderLeagueId(player.GetLeagueId()); cm.SetSenderName(player.GetAvatarName()); cm.SetSenderRole(player.GetAllianceRole()); cm.SetMessage(Message); cm.SetState(1); all.AddChatMessage(cm); // New function for send a message foreach (AllianceMemberEntry op in all.GetAllianceMembers()) { Level playera = ResourcesManager.GetPlayer(op.GetAvatarId()); if (playera.GetClient() != null) { var p = new AllianceStreamEntryMessage(playera.GetClient()); p.SetStreamEntry(cm); p.Send(); } } }
public async void SetSender(ClientAvatar avatar) { m_vSenderId = avatar.GetId(); m_vHomeId = avatar.GetId(); m_vSenderName = avatar.GetAvatarName(); m_vSenderLeagueId = avatar.GetLeagueId(); m_vSenderLevel = avatar.GetAvatarLevel(); m_vSenderRole = await avatar.GetAllianceRole(); }
public override void Execute(Level level) { ChallangeCommand challangeCommand = this; try { ClientAvatar player = level.GetPlayerAvatar(); Alliance alliance = ObjectManager.GetAlliance(player.GetAllianceId()); ChallengeStreamEntry cm = new ChallengeStreamEntry(); cm.SetMessage(challangeCommand.Message); cm.SetSenderId(player.GetId()); cm.SetSenderName(player.GetAvatarName()); cm.SetSenderLevel(player.GetAvatarLevel()); ChallengeStreamEntry challengeStreamEntry = cm; int allianceRole = player.GetAllianceRole(); challengeStreamEntry.SetSenderRole(allianceRole); challengeStreamEntry = (ChallengeStreamEntry)null; cm.SetId(alliance.GetChatMessages().Count + 1); cm.SetSenderLeagueId(player.GetLeagueId()); alliance.AddChatMessage((UCS.Logic.StreamEntry.StreamEntry)cm); UCS.Logic.StreamEntry.StreamEntry s = alliance.GetChatMessages().Find((Predicate <UCS.Logic.StreamEntry.StreamEntry>)(c => c.GetStreamEntryType() == 12)); List <AllianceMemberEntry> .Enumerator enumerator; if (s != null) { alliance.GetChatMessages().RemoveAll((Predicate <UCS.Logic.StreamEntry.StreamEntry>)(t => t == s)); foreach (AllianceMemberEntry allianceMember in alliance.GetAllianceMembers()) { Level player1 = ResourcesManager.GetPlayer(allianceMember.GetAvatarId(), false); if (player1.GetClient() != null) { new AllianceStreamEntryRemovedMessage(player1.GetClient(), s.GetId()).Send(); } } enumerator = new List <AllianceMemberEntry> .Enumerator(); } foreach (AllianceMemberEntry allianceMember in alliance.GetAllianceMembers()) { Level player1 = ResourcesManager.GetPlayer(allianceMember.GetAvatarId(), false); if (player1.GetClient() != null) { AllianceStreamEntryMessage Message = new AllianceStreamEntryMessage(player1.GetClient()); ChallengeStreamEntry challengeStreamEntry1 = cm; Message.SetStreamEntry((UCS.Logic.StreamEntry.StreamEntry)challengeStreamEntry1); Message.Send(); } } enumerator = new List <AllianceMemberEntry> .Enumerator(); player = (ClientAvatar)null; alliance = (Alliance)null; cm = (ChallengeStreamEntry)null; } catch (Exception ex) { } }
internal async void SetSender(ClientAvatar avatar) { try { SenderID = avatar.UserId; m_vHomeId = avatar.UserId; m_vSenderName = avatar.AvatarName; m_vSenderLeagueId = avatar.m_vLeagueId; m_vSenderLevel = avatar.m_vAvatarLevel; m_vSenderRole = await avatar.GetAllianceRole(); } catch (Exception) {} }
public override async void Execute(Level level) { try { ClientAvatar player = level.GetPlayerAvatar(); long allianceID = player.GetAllianceId(); Alliance alliance = await ObjectManager.GetAlliance(allianceID); ChallangeStreamEntry cm = new ChallangeStreamEntry(); cm.SetMessage(Message); cm.SetSenderId(player.GetId()); cm.SetSenderName(player.GetAvatarName()); cm.SetSenderLevel(player.GetAvatarLevel()); cm.SetSenderRole(await player.GetAllianceRole()); cm.SetId(alliance.GetChatMessages().Count + 1); cm.SetSenderLeagueId(player.GetLeagueId()); StreamEntry s = alliance.GetChatMessages().Find(c => c.GetStreamEntryType() == 12); if (s != null) { alliance.GetChatMessages().RemoveAll(t => t == s); foreach (AllianceMemberEntry op in alliance.GetAllianceMembers()) { Level alliancemembers = await ResourcesManager.GetPlayer(op.GetAvatarId()); if (alliancemembers.GetClient() != null) { PacketProcessor.Send(new AllianceStreamEntryRemovedMessage(alliancemembers.GetClient(), s.GetId())); } } } alliance.AddChatMessage(cm); foreach (AllianceMemberEntry op in alliance.GetAllianceMembers()) { Level alliancemembers = await ResourcesManager.GetPlayer(op.GetAvatarId()); if (alliancemembers.GetClient() != null) { AllianceStreamEntryMessage p = new AllianceStreamEntryMessage(alliancemembers.GetClient()); p.SetStreamEntry(cm); PacketProcessor.Send(p); } } } catch (Exception) { } }
public override async void Execute(Level level) { try { ClientAvatar player = level.GetPlayerAvatar(); TroopRequestStreamEntry cm = new TroopRequestStreamEntry(); Alliance all = await ObjectManager.GetAlliance(player.GetAllianceId()); cm.SetId(all.GetChatMessages().Count + 1); cm.SetSenderId(player.GetId()); cm.SetHomeId(player.GetId()); cm.SetSenderLeagueId(player.GetLeagueId()); cm.SetSenderName(player.GetAvatarName()); cm.SetSenderRole(await player.GetAllianceRole()); cm.SetMessage(Message); cm.SetMaxTroop(player.GetAllianceCastleTotalCapacity()); all.AddChatMessage(cm); StreamEntry s = all.GetChatMessages().Find(c => c.GetSenderId() == level.GetPlayerAvatar().GetId() && c.GetStreamEntryType() == 1); if (s == null) { all.GetChatMessages().RemoveAll(t => t == s); } all.AddChatMessage(cm); foreach (AllianceMemberEntry op in all.GetAllianceMembers()) { Level aplayer = await ResourcesManager.GetPlayer(op.GetAvatarId()); if (aplayer.GetClient() != null) { if (s != null) { PacketProcessor.Send(new AllianceStreamEntryRemovedMessage(aplayer.GetClient(), s.GetId())); } AllianceStreamEntryMessage p = new AllianceStreamEntryMessage(aplayer.GetClient()); p.SetStreamEntry(cm); PacketProcessor.Send(p); } } } catch (Exception) { ResourcesManager.DropClient(level.GetClient().GetSocketHandle()); } }
public override async void Process(Level level) { try { ClientAvatar avatar = level.GetPlayerAvatar(); Alliance alliance = await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()); if (await avatar.GetAllianceRole() == 2 && alliance.GetAllianceMembers().Count > 1) { List<AllianceMemberEntry> members = alliance.GetAllianceMembers(); foreach (AllianceMemberEntry player in members.Where(player => player.GetRole() >= 3)) { player.SetRole(2); if (ResourcesManager.IsPlayerOnline(await ResourcesManager.GetPlayer(player.GetAvatarId()))) { AllianceRoleUpdateCommand c = new AllianceRoleUpdateCommand(); c.SetAlliance(alliance); c.SetRole(2); c.Tick(level); Level l = await ResourcesManager.GetPlayer(player.GetAvatarId()); AvailableServerCommandMessage d = new AvailableServerCommandMessage(l.GetClient()); d.SetCommandId(8); d.SetCommand(c); PacketProcessor.Send(d); } done = true; break; } if (!done) { int count = alliance.GetAllianceMembers().Count; Random rnd = new Random(); int id = rnd.Next(1, count); while (id != level.GetPlayerAvatar().GetId()) id = rnd.Next(1, count); int loop = 0; foreach (AllianceMemberEntry player in members) { loop++; if (loop == id) { player.SetRole(2); if (ResourcesManager.IsPlayerOnline(await ResourcesManager.GetPlayer(player.GetAvatarId()))) { AllianceRoleUpdateCommand e = new AllianceRoleUpdateCommand(); e.SetAlliance(alliance); e.SetRole(2); e.Tick(level); Level l2 = await ResourcesManager.GetPlayer(player.GetAvatarId()); AvailableServerCommandMessage f = new AvailableServerCommandMessage(l2.GetClient()); f.SetCommandId(8); f.SetCommand(e); PacketProcessor.Send(f); } break; } } } } LeavedAllianceCommand a = new LeavedAllianceCommand(); a.SetAlliance(alliance); a.SetReason(1); AvailableServerCommandMessage b = new AvailableServerCommandMessage(Client); b.SetCommandId(2); b.SetCommand(a); PacketProcessor.Send(b); alliance.RemoveMember(avatar.GetId()); avatar.SetAllianceId(0); if (alliance.GetAllianceMembers().Count > 0) { AllianceEventStreamEntry eventStreamEntry = new AllianceEventStreamEntry(); eventStreamEntry.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); eventStreamEntry.SetSender(avatar); eventStreamEntry.SetEventType(4); eventStreamEntry.SetAvatarId(avatar.GetId()); eventStreamEntry.SetAvatarName(avatar.GetAvatarName()); alliance.AddChatMessage(eventStreamEntry); foreach (Level onlinePlayer in ResourcesManager.GetOnlinePlayers()) if (onlinePlayer.GetPlayerAvatar().GetAllianceId() == alliance.GetAllianceId()) { AllianceStreamEntryMessage p = new AllianceStreamEntryMessage(onlinePlayer.GetClient()); p.SetStreamEntry(eventStreamEntry); PacketProcessor.Send(p); } } else { DatabaseManager.Single().RemoveAlliance(alliance); } PacketProcessor.Send(new LeaveAllianceOkMessage(Client, alliance)); } catch (Exception) { } }
public override async void Execute(Level level) { if (level.Avatar.AccountPrivileges >= GetRequiredAccountPrivileges()) { if (m_vArgs.Length >= 2) { try { long id = Convert.ToInt64(m_vArgs[1]); Level l = await ResourcesManager.GetPlayer(id); if (l != null) { ClientAvatar acc = l.Avatar; Message = "Player Info : \n\n" + "ID = " + id + "\nName = " + acc.AvatarName + "\nCreation Date : " + acc.m_vAccountCreationDate + "\nRegion : " + acc.Region + "\nIP Address : " + l.Avatar.IPAddress; if (acc.AllianceId != 0) { Alliance a = ObjectManager.GetAlliance(acc.AllianceId); Message = Message + "\nClan Name : " + a.m_vAllianceName; switch (await acc.GetAllianceRole()) { case 1: Message = Message + "\nClan Role : Member"; break; case 2: Message = Message + "\nClan Role : Leader"; break; case 3: Message = Message + "\nClan Role : Elder"; break; case 4: Message = Message + "\nClan Role : Co-Leader"; break; default: Message = Message + "\nClan Role : Unknown"; break; } } Message = Message + "\nLevel : " + acc.m_vAvatarLevel + "\nTrophies : " + acc.GetScore() + "\nTown Hall Level : " + (acc.m_vTownHallLevel + 1) + "\nAlliance Castle Level : " + (acc.GetAllianceCastleLevel() + 1); var avatar = level.Avatar; AllianceMailStreamEntry mail = new AllianceMailStreamEntry(); mail.SenderId = avatar.UserId; mail.m_vSenderName = avatar.AvatarName; mail.IsNew = 2; mail.AllianceId = 0; mail.AllianceBadgeData = 1526735450; mail.AllianceName = "UCS Server Information"; mail.Message = Message; mail.m_vSenderLevel = avatar.m_vAvatarLevel; mail.m_vSenderLeagueId = avatar.m_vLeagueId; AvatarStreamEntryMessage p = new AvatarStreamEntryMessage(level.Client); p.SetAvatarStreamEntry(mail); Processor.Send(p); } } catch (Exception) { GlobalChatLineMessage c = new GlobalChatLineMessage(level.Client) { Message = "Command Failed, Wrong Format Or User Doesn't Exist (/accinfo id).", HomeId = level.Avatar.UserId, CurrentHomeId = level.Avatar.UserId, LeagueId = 22, PlayerName = "Ultrapower Clash Server AI" }; Processor.Send(c); return; } } else { GlobalChatLineMessage b = new GlobalChatLineMessage(level.Client) { Message = "Command Failed, Wrong Format (/accinfo id).", HomeId = level.Avatar.UserId, CurrentHomeId = level.Avatar.UserId, LeagueId = 22, PlayerName = "Ultrapower Clash Server AI" }; Processor.Send(b); } } }
public override void Execute(Level level) { if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges()) { if (m_vArgs.Length >= 2) { try { long id = Convert.ToInt64(m_vArgs[1]); Level l = ResourcesManager.GetPlayer(id); if (l != null) { ClientAvatar acc = l.GetPlayerAvatar(); Message = "Player Info : \n\n" + "ID = " + id + "\nName = " + acc.GetAvatarName() + "\nCreation Date : " + acc.GetAccountCreationDate() + "\nRegion : " + acc.GetUserRegion() + "\nIP Address : " + l.GetIPAddress(); if (acc.GetAllianceId() != 0) { Message = Message + "\nClan Name : " + ObjectManager.GetAlliance(acc.GetAllianceId()).GetAllianceName(); switch (acc.GetAllianceRole()) { case 1: Message = Message + "\nClan Role : Member"; break; case 2: Message = Message + "\nClan Role : Leader"; break; case 3: Message = Message + "\nClan Role : Elder"; break; case 4: Message = Message + "\nClan Role : Co-Leader"; break; default: Message = Message + "\nClan Role : Unknown"; break; } } Message = Message + "\nLevel : " + acc.GetAvatarLevel() + "\nTrophy : " + acc.GetScore() + "\nTown Hall Level : " + (acc.GetTownHallLevel() + 1) + "\nAlliance Castle Level : " + (acc.GetAllianceCastleLevel() + 1); var avatar = level.GetPlayerAvatar(); AllianceMailStreamEntry mail = new AllianceMailStreamEntry(); mail.SetSenderId(avatar.GetId()); mail.SetSenderAvatarId(avatar.GetId()); mail.SetSenderName(avatar.GetAvatarName()); mail.SetIsNew(2); mail.SetAllianceId(0); mail.SetAllianceBadgeData(1526735450); mail.SetAllianceName("UCS Server Information"); mail.SetMessage(Message); mail.SetSenderLevel(avatar.GetAvatarLevel()); mail.SetSenderLeagueId(avatar.GetLeagueId()); AvatarStreamEntryMessage p = new AvatarStreamEntryMessage(level.GetClient()); p.SetAvatarStreamEntry(mail); p.Send(); } } catch (Exception) { GlobalChatLineMessage c = new GlobalChatLineMessage(level.GetClient()); c.SetChatMessage("Command Failed, Wrong Format Or User Doesn't Exist (/accinfo id)."); c.SetPlayerId(level.GetPlayerAvatar().GetId()); c.SetLeagueId(22); c.SetPlayerName("Ultrapowa Clash Server"); c.Send(); return; } } else { GlobalChatLineMessage b = new GlobalChatLineMessage(level.GetClient()); b.SetChatMessage("Command Failed, Wrong Format (/accinfo id)."); b.SetPlayerId(level.GetPlayerAvatar().GetId()); b.SetLeagueId(22); b.SetPlayerName("Ultrapowa Clash Server"); b.Send(); } } }
public override async void Process(Level level) { try { Level target = await ResourcesManager.GetPlayer(m_vId); ClientAvatar player = level.GetPlayerAvatar(); Alliance alliance = await ObjectManager.GetAlliance(player.GetAllianceId()); if (await player.GetAllianceRole() == 2 || await player.GetAllianceRole() == 4) { if (player.GetAllianceId() == target.GetPlayerAvatar().GetAllianceId()) { int oldrole = await target.GetPlayerAvatar().GetAllianceRole(); target.GetPlayerAvatar().SetAllianceRole(m_vRole); if (m_vRole == 2) { player.SetAllianceRole(4); AllianceEventStreamEntry demote = new AllianceEventStreamEntry(); demote.SetId(alliance.GetChatMessages().Count + 1); demote.SetSender(player); demote.SetEventType(6); demote.SetAvatarId(player.GetId()); demote.SetAvatarName(player.GetAvatarName()); alliance.AddChatMessage(demote); AllianceEventStreamEntry promote = new AllianceEventStreamEntry(); promote.SetId(alliance.GetChatMessages().Count + 1); promote.SetSender(target.GetPlayerAvatar()); promote.SetEventType(5); promote.SetAvatarId(player.GetId()); promote.SetAvatarName(player.GetAvatarName()); alliance.AddChatMessage(promote); PromoteAllianceMemberOkMessage rup = new PromoteAllianceMemberOkMessage(Client); PromoteAllianceMemberOkMessage rub = new PromoteAllianceMemberOkMessage(target.GetClient()); AllianceRoleUpdateCommand p = new AllianceRoleUpdateCommand(); AvailableServerCommandMessage pa = new AvailableServerCommandMessage(Client); AllianceRoleUpdateCommand t = new AllianceRoleUpdateCommand(); AvailableServerCommandMessage ta = new AvailableServerCommandMessage(target.GetClient()); rup.SetID(level.GetPlayerAvatar().GetId()); rup.SetRole(4); rub.SetID(target.GetPlayerAvatar().GetId()); rub.SetRole(2); t.SetAlliance(alliance); p.SetAlliance(alliance); t.SetRole(2); p.SetRole(4); t.Tick(target); p.Tick(level); ta.SetCommandId(8); pa.SetCommandId(8); ta.SetCommand(t); pa.SetCommand(p); if (ResourcesManager.IsPlayerOnline(target)) { PacketProcessor.Send(ta); PacketProcessor.Send(rub); } PacketProcessor.Send(rup); PacketProcessor.Send(pa); foreach (AllianceMemberEntry op in alliance.GetAllianceMembers()) { Level aplayer = await ResourcesManager.GetPlayer(op.GetAvatarId()); if (aplayer.GetClient() != null) { AllianceStreamEntryMessage a = new AllianceStreamEntryMessage(aplayer.GetClient()); AllianceStreamEntryMessage b = new AllianceStreamEntryMessage(aplayer.GetClient()); a.SetStreamEntry(demote); b.SetStreamEntry(promote); PacketProcessor.Send(a); PacketProcessor.Send(b); } } } else { AllianceRoleUpdateCommand t = new AllianceRoleUpdateCommand(); AvailableServerCommandMessage ta = new AvailableServerCommandMessage(target.GetClient()); PromoteAllianceMemberOkMessage ru = new PromoteAllianceMemberOkMessage(target.GetClient()); AllianceEventStreamEntry stream = new AllianceEventStreamEntry(); stream.SetId(alliance.GetChatMessages().Count + 1); stream.SetSender(target.GetPlayerAvatar()); stream.SetAvatarId(player.GetId()); stream.SetAvatarName(player.GetAvatarName()); if (m_vRole > oldrole) { stream.SetEventType(5); } else { stream.SetEventType(6); } t.SetAlliance(alliance); t.SetRole(m_vRole); t.Tick(target); ta.SetCommandId(8); ta.SetCommand(t); ru.SetID(target.GetPlayerAvatar().GetId()); ru.SetRole(m_vRole); alliance.AddChatMessage(stream); if (ResourcesManager.IsPlayerOnline(target)) { PacketProcessor.Send(ta); PacketProcessor.Send(ru); } foreach (AllianceMemberEntry op in alliance.GetAllianceMembers()) { Level aplayer = await ResourcesManager.GetPlayer(op.GetAvatarId()); if (aplayer.GetClient() != null) { AllianceStreamEntryMessage b = new AllianceStreamEntryMessage(aplayer.GetClient()); b.SetStreamEntry(stream); PacketProcessor.Send(b); } } } } } } catch (Exception) { } }
internal override async void Process() { try { Level target = await ResourcesManager.GetPlayer(m_vId); ClientAvatar player = this.Device.Player.Avatar; Alliance alliance = ObjectManager.GetAlliance(player.AllianceId); if (await player.GetAllianceRole() == 2 || await player.GetAllianceRole() == 4) { if (player.AllianceId == target.Avatar.AllianceId) { int oldrole = await target.Avatar.GetAllianceRole(); target.Avatar.SetAllianceRole(m_vRole); if (m_vRole == 2) { player.SetAllianceRole(4); AllianceEventStreamEntry demote = new AllianceEventStreamEntry(); demote.ID = alliance.m_vChatMessages.Count + 1; demote.SetSender(player); demote.EventType = 6; alliance.AddChatMessage(demote); AllianceEventStreamEntry promote = new AllianceEventStreamEntry(); promote.ID = alliance.m_vChatMessages.Count + 1; promote.SetSender(target.Avatar); promote.EventType = 5; alliance.AddChatMessage(promote); AllianceRoleUpdateCommand p = new AllianceRoleUpdateCommand(this.Device); AvailableServerCommandMessage pa = new AvailableServerCommandMessage(Device, p.Handle()); AllianceRoleUpdateCommand t = new AllianceRoleUpdateCommand(target.Client); AvailableServerCommandMessage ta = new AvailableServerCommandMessage(target.Client, t.Handle()); PromoteAllianceMemberOkMessage rup = new PromoteAllianceMemberOkMessage(Device) { Id = this.Device.Player.Avatar.UserId, Role = 4 }; PromoteAllianceMemberOkMessage rub = new PromoteAllianceMemberOkMessage(target.Client) { Id = target.Avatar.UserId, Role = 2 }; t.SetAlliance(alliance); p.SetAlliance(alliance); t.SetRole(2); p.SetRole(4); t.Tick(target); p.Tick(this.Device.Player); if (ResourcesManager.IsPlayerOnline(target)) { ta.Send(); rub.Send(); } rup.Send(); pa.Send(); foreach (AllianceMemberEntry op in alliance.GetAllianceMembers()) { Level aplayer = await ResourcesManager.GetPlayer(op.AvatarId); if (aplayer.Client != null) { new AllianceStreamEntryMessage(aplayer.Client) { StreamEntry = demote }.Send(); new AllianceStreamEntryMessage(aplayer.Client) { StreamEntry = promote }.Send(); } } } else { AllianceRoleUpdateCommand t = new AllianceRoleUpdateCommand(target.Client); AvailableServerCommandMessage ta = new AvailableServerCommandMessage(target.Client, t.Handle()); t.SetAlliance(alliance); t.SetRole(m_vRole); t.Tick(target); PromoteAllianceMemberOkMessage ru = new PromoteAllianceMemberOkMessage(target.Client) { Id = target.Avatar.UserId, Role = m_vRole }; if (ResourcesManager.IsPlayerOnline(target)) { ta.Send(); ru.Send(); } AllianceEventStreamEntry stream = new AllianceEventStreamEntry(); stream.ID = alliance.m_vChatMessages.Count + 1; stream.SetSender(target.Avatar); stream.EventType = m_vRole > oldrole ? 5 : 6; alliance.AddChatMessage(stream); foreach (AllianceMemberEntry op in alliance.GetAllianceMembers()) { Level aplayer = await ResourcesManager.GetPlayer(op.AvatarId); if (aplayer.Client != null) { new AllianceStreamEntryMessage(aplayer.Client) { StreamEntry = stream }.Send(); } } } } } } catch (Exception) { } }
internal override async void Process() { try { ClientAvatar avatar = this.Device.Player.Avatar; Alliance alliance = ObjectManager.GetAlliance(avatar.AllianceId); if (await avatar.GetAllianceRole() == 2 && alliance.GetAllianceMembers().Count > 1) { List <AllianceMemberEntry> members = alliance.GetAllianceMembers(); foreach (AllianceMemberEntry player in members.Where(player => player.Role >= 3)) { player.Role = 2; if (ResourcesManager.IsPlayerOnline(await ResourcesManager.GetPlayer(player.AvatarId))) { Level l = await ResourcesManager.GetPlayer(player.AvatarId); AllianceRoleUpdateCommand c = new AllianceRoleUpdateCommand(l.Client); c.SetAlliance(alliance); c.SetRole(2); c.Tick(l); new AvailableServerCommandMessage(l.Client, c.Handle()).Send(); } done = true; break; } if (!done) { int count = alliance.GetAllianceMembers().Count; Random rnd = new Random(); int id = rnd.Next(1, count); while (id != this.Device.Player.Avatar.UserId) { id = rnd.Next(1, count); } int loop = 0; foreach (AllianceMemberEntry player in members) { loop++; if (loop == id) { player.Role = 2; if (ResourcesManager.IsPlayerOnline(await ResourcesManager.GetPlayer(player.AvatarId))) { Level l2 = await ResourcesManager.GetPlayer(player.AvatarId); AllianceRoleUpdateCommand e = new AllianceRoleUpdateCommand(l2.Client); e.SetAlliance(alliance); e.SetRole(2); e.Tick(l2); new AvailableServerCommandMessage(l2.Client, e.Handle()).Send(); } break; } } } } LeavedAllianceCommand a = new LeavedAllianceCommand(this.Device); a.SetAlliance(alliance); a.SetReason(1); new AvailableServerCommandMessage(Device, a.Handle()).Send(); alliance.RemoveMember(avatar.UserId); avatar.AllianceId = 0; if (alliance.GetAllianceMembers().Count > 0) { AllianceEventStreamEntry eventStreamEntry = new AllianceEventStreamEntry(); eventStreamEntry.ID = alliance.m_vChatMessages.Count + 1; eventStreamEntry.SetSender(avatar); eventStreamEntry.EventType = 4; alliance.AddChatMessage(eventStreamEntry); foreach (Level onlinePlayer in ResourcesManager.m_vOnlinePlayers) { if (onlinePlayer.Avatar.AllianceId == alliance.m_vAllianceId) { new AllianceStreamEntryMessage(onlinePlayer.Client) { StreamEntry = eventStreamEntry }.Send(); } } } else { Resources.DatabaseManager.RemoveAlliance(alliance); } new LeaveAllianceOkMessage(Device, alliance).Send(); } catch (Exception) { } }