示例#1
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (text.Length > 120 || player == null)
         {
             return;
         }
         Clan clan          = ClanManager.GetClan(player.clanId);
         int  playersLoaded = 0;
         if (clan.id > 0 && clan.ownerId == player.playerId)
         {
             List <Account> players = clan.GetPlayers(player.playerId, true);
             for (int i = 0; i < players.Count; i++)
             {
                 Account member = players[i];
                 if ((type == 0 || member.clanAuthority == ClanAuthorityEnum.Master && type == 1 || member.clanAuthority == ClanAuthorityEnum.Auxiliar && type == 2) && member.GetMessagesCount() < 100)
                 {
                     playersLoaded++;
                     Message message = new Message(15)
                     {
                         senderName = clan.name,
                         senderId   = player.playerId,
                         clanId     = clan.id,
                         type       = 4,
                         text       = text,
                         state      = 1
                     };
                     if (message != null && member.InsertMessage(message) && member.isOnline)
                     {
                         member.SendPacket(new BOX_MESSAGE_RECEIVE_PAK(message));
                     }
                 }
             }
         }
         client.SendPacket(new CLAN_MSG_FOR_PLAYERS_PAK(playersLoaded));
         if (playersLoaded > 0)
         {
             client.SendCompletePacket(PackageDataManager.BOX_MESSAGE_SEND_PAK);
         }
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
示例#2
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null)
         {
             return;
         }
         Clan clan = ClanManager.GetClan(player.clanId);
         if (clan.id == 0)
         {
             client.SendCompletePacket(PackageDataManager.CLAN_MEMBER_LIST_ERROR_PAK);
             return;
         }
         List <Account> clanPlayers = clan.GetPlayers(-1, false);
         using (PacketWriter writer = new PacketWriter())
         {
             int count = 0;
             for (int i = page * 14; i < clanPlayers.Count; i++)
             {
                 Account member = clanPlayers[i];
                 writer.WriteQ(member.playerId);
                 writer.WriteS(member.nickname, 33);
                 writer.WriteC(member.rankId);
                 writer.WriteC((byte)member.clanAuthority);
                 writer.WriteQ(Utilities.GetClanStatus(member.status, member.isOnline));
                 writer.WriteD(member.clanDate);
                 writer.WriteC(member.nickcolor);
                 if (count++ == 14)
                 {
                     break;
                 }
             }
             client.SendPacket(new CLAN_MEMBER_LIST_PAK(page, count, writer.memorystream.ToArray()));
         }
         clanPlayers = null;
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
示例#3
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null || player.nickname.Length == 0)
         {
             return;
         }
         Clan clan = ClanManager.GetClan(clanId);
         if (clan.id == 0)
         {
             client.SendCompletePacket(PackageDataManager.CLAN_MESSAGE_REQUEST_ACCEPT_2147487835_PAK);
             return;
         }
         if (player.clanId > 0)
         {
             client.SendCompletePacket(PackageDataManager.CLAN_MESSAGE_REQUEST_ACCEPT_2147487832_PAK);
             return;
         }
         List <Account> clanPlayers = clan.GetPlayers(-1, true);
         if (clan.maxPlayers <= clanPlayers.Count)
         {
             client.SendCompletePacket(PackageDataManager.CLAN_MESSAGE_REQUEST_ACCEPT_2147487830_PAK);
         }
         else if (type == 0 || type == 1)
         {
             Account owner = AccountManager.GetAccount(clan.ownerId, 0);
             if (owner != null)
             {
                 if (owner.GetMessagesCount() < 100)
                 {
                     Message message = new Message(15)
                     {
                         senderName = clan.name,
                         senderId   = player.playerId,
                         clanId     = clan.id,
                         type       = 4,
                         text       = player.nickname,
                         state      = 1,
                         noteEnum   = type == 0 ? NoteMessageClanEnum.JoinDenial : NoteMessageClanEnum.JoinAccept
                     };
                     if (message != null && owner.InsertMessage(message) && owner.isOnline)
                     {
                         owner.SendPacket(new BOX_MESSAGE_RECEIVE_PAK(message));
                     }
                 }
                 if (type == 1)
                 {
                     int date = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
                     if (player.ExecuteQuery($"UPDATE accounts SET clan_id='{clan.id}', clan_authority='3', clan_date='{date}' WHERE id='{player.playerId}'"))
                     {
                         using (CLAN_MEMBER_INFO_INSERT_PAK packet = new CLAN_MEMBER_INFO_INSERT_PAK(player))
                         {
                             player.SendPacketForPlayers(packet, clanPlayers);
                         }
                         player.clanId        = clan.id;
                         player.clanDate      = date;
                         player.clanAuthority = ClanAuthorityEnum.Membro;
                         client.SendPacket(new CLAN_GET_CLAN_MEMBERS_PAK(clanPlayers));
                         Room room = player.room;
                         if (room != null)
                         {
                             room.SendPacketToPlayers(new PROTOCOL_ROOM_GET_SLOTONEINFO_ACK(player, clan));
                         }
                         client.SendPacket(new CLAN_NEW_INFOS_PAK(clan, owner, clanPlayers.Count + 1));
                     }
                     else
                     {
                         client.SendCompletePacket(PackageDataManager.BOX_MESSAGE_SEND_ERROR_0x80000000_PAK);
                     }
                 }
                 client.SendCompletePacket(PackageDataManager.BOX_MESSAGE_SEND_SUCCESS_PAK);
             }
             else
             {
                 client.SendCompletePacket(PackageDataManager.BOX_MESSAGE_SEND_ERROR_0x80000000_PAK);
             }
         }
         clanPlayers = null;
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
示例#4
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null)
         {
             return;
         }
         Clan clan = ClanManager.GetClan(player.clanId);
         if (player.clanId == 0 || clan.id == 0 || !(player.clanAuthority >= ClanAuthorityEnum.Master && player.clanAuthority <= ClanAuthorityEnum.Auxiliar || clan.ownerId == player.playerId))
         {
             client.SendCompletePacket(PackageDataManager.CLAN_DEPORTATION_2147487833_PAK);
             return;
         }
         List <Account> clanPlayers = clan.GetPlayers(-1, true);
         for (int i = 0; i < players.Count; i++)
         {
             Account member = AccountManager.GetAccount(players[i], 0);
             if (member != null && member.clanId == clan.id && member.match == null && member.ExecuteQuery($"UPDATE accounts SET clan_id='0', clan_authority='0', clan_fights='0', clan_wins='0' WHERE id='{member.playerId}'"))
             {
                 using (PROTOCOL_CLAN_MEMBER_LEAVE_ACK packet = new PROTOCOL_CLAN_MEMBER_LEAVE_ACK(member.playerId))
                 {
                     member.SendPacketForPlayers(packet, clanPlayers, member.playerId);
                 }
                 member.clanId        = 0;
                 member.clanAuthority = ClanAuthorityEnum.None;
                 lock (member.clanPlayers)
                 {
                     member.clanPlayers.Clear();
                 }
                 if (member.GetMessagesCount() < 100)
                 {
                     Message message = new Message(15)
                     {
                         senderName = clan.name,
                         senderId   = player.playerId,
                         clanId     = clan.id,
                         type       = 4,
                         state      = 1,
                         noteEnum   = NoteMessageClanEnum.Deportation
                     };
                     if (message != null && member.InsertMessage(message) && member.isOnline)
                     {
                         //Envia mensagem para o jogador que foi expulso do clã, notificando a expulsão.
                         member.SendPacket(new BOX_MESSAGE_RECEIVE_PAK(message));
                     }
                 }
                 if (member.isOnline)
                 {
                     member.SendCompletePacket(PackageDataManager.CLAN_PRIVILEGES_KICK_PAK);
                 }
                 result++;
                 clanPlayers.Remove(member);
             }
             else
             {
                 client.SendCompletePacket(PackageDataManager.CLAN_DEPORTATION_2147487833_PAK);
                 break;
             }
         }
         client.SendPacket(new CLAN_DEPORTATION_PAK(result));
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
     finally
     {
         players = null;
     }
 }
示例#5
0
        public override void RunImplement()
        {
            try
            {
                Account player = client.SessionPlayer;
                if (player == null)
                {
                    return;
                }
                Clan clan = ClanManager.GetClan(player.clanId);
                if (clan.id > 0 && (player.clanAuthority >= ClanAuthorityEnum.Master && player.clanAuthority <= ClanAuthorityEnum.Auxiliar || player.playerId == clan.ownerId))
                {
                    List <Account> clanPlayers = clan.GetPlayers(-1, true);
                    if (clanPlayers.Count >= clan.maxPlayers)
                    {
                        client.SendPacket(new CLAN_REQUEST_ACCEPT_PAK(-1));
                        return;
                    }
                    int result = 0;
                    for (int i = 0; i < players.Count; i++)
                    {
                        Account member = AccountManager.GetAccount(players[i], 0);
                        if (member != null && clanPlayers.Count < clan.maxPlayers && member.clanId == 0 && member.GetRequestClanId() > 0)
                        {
                            using (CLAN_MEMBER_INFO_INSERT_PAK packet = new CLAN_MEMBER_INFO_INSERT_PAK(member))
                            {
                                member.SendPacketForPlayers(packet, clanPlayers);
                            }
                            member.clanId        = player.clanId;
                            member.clanDate      = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
                            member.clanAuthority = ClanAuthorityEnum.Membro;

                            member.ExecuteQuery($"UPDATE accounts SET clan_id='{clan.id}', clan_authority='{member.clanAuthority}', clan_date='{member.clanDate}', clan_id='{member.clanId}' WHERE id='{member.playerId}'");

                            member.DeleteInvite(player.clanId);
                            if (member.isOnline)
                            {
                                member.SendPacket(new CLAN_GET_CLAN_MEMBERS_PAK(clanPlayers));
                                Room room = member.room;
                                if (room != null)
                                {
                                    room.SendPacketToPlayers(new PROTOCOL_ROOM_GET_SLOTONEINFO_ACK(member, clan));
                                }
                                member.SendPacket(new CLAN_NEW_INFOS_PAK(clan, clanPlayers.Count + 1));
                            }
                            if (member.GetMessagesCount() < 100)
                            {
                                Message message = new Message(15)
                                {
                                    senderName = clan.name,
                                    senderId   = player.playerId,
                                    clanId     = clan.id,
                                    type       = 4,
                                    state      = 1,
                                    noteEnum   = NoteMessageClanEnum.InviteAccept
                                };
                                if (message != null && member.InsertMessage(message) && member.isOnline)
                                {
                                    //Envia mensagem para o jogador, notificando que foi aceito no clã.
                                    member.SendPacket(new BOX_MESSAGE_RECEIVE_PAK(message));
                                }
                            }
                            result++;
                            clanPlayers.Add(member);
                        }
                    }
                    client.SendPacket(new CLAN_REQUEST_ACCEPT_PAK(result));
                    clanPlayers = null;
                }
                else
                {
                    client.SendPacket(new CLAN_REQUEST_ACCEPT_PAK(-1));
                }
            }
            catch (Exception ex)
            {
                PacketLog(ex);
            }
            finally
            {
                players = null;
            }
        }