Exemplo n.º 1
0
        public void OnNewFriendship(int friendID)
        {
            GameClient     clientByUserId = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID);
            MessengerBuddy friend;

            if (clientByUserId == null || clientByUserId.GetHabbo() == null)
            {
                DataRow row;
                using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor.SetQuery("SELECT username FROM users WHERE id = " + friendID);
                    row = queryreactor.GetRow();
                }
                if (row == null)
                {
                    return;
                }

                friend = new MessengerBuddy(friendID, (string)row["username"], "", 0);
            }
            else
            {
                Habbo habbo = clientByUserId.GetHabbo();
                friend = new MessengerBuddy(friendID, habbo.Username, habbo.Look, 0);
                friend.UpdateUser();
            }
            if (!this.friends.ContainsKey(friendID))
            {
                this.friends.Add(friendID, friend);
            }
            this.GetClient().SendPacket(SerializeUpdate(friend));
        }
Exemplo n.º 2
0
        internal void OnNewFriendship(uint friendID)
        {
            if ((requests.Count + friends.Count) > EmuSettings.FRIENDS_LIMIT)
            {
                GetClient().SendNotif("Você possui muitos amigos, exclua alguns para poder adicionar mais!");
                return;
            }

            var            friend = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID);
            MessengerBuddy newFriend;

            if (friend == null || friend.GetHabbo() == null)
            {
                DataRow dRow;
                using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT username,motto,look,last_online FROM users WHERE id = " + friendID);
                    dRow = dbClient.getRow();
                }

                newFriend = new MessengerBuddy(friendID, (string)dRow["username"], (string)dRow["look"], (string)dRow["motto"]);
            }
            else
            {
                var user = friend.GetHabbo();
                newFriend = new MessengerBuddy(friendID, user.Username, user.Look, user.Motto);
            }

            if (!friends.ContainsKey(friendID))
            {
                friends.Add(friendID, newFriend);
            }

            GetClient().SendMessage(SerializeUpdate(newFriend, GetClient().GetHabbo()));
        }
Exemplo n.º 3
0
        internal void OnNewFriendship(uint friendID)
        {
            GameClient friend = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID);

            MessengerBuddy newFriend;

            if (friend == null || friend.GetHabbo() == null)
            {
                DataRow dRow;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT username,motto,look,last_online FROM users WHERE id = " + friendID);
                    dRow = dbClient.getRow();
                }

                newFriend = new MessengerBuddy(friendID, (string)dRow["username"], (string)dRow["look"], (string)dRow["motto"], (string)dRow["last_online"]);
            }
            else
            {
                Habbo user = friend.GetHabbo();
                newFriend = new MessengerBuddy(friendID, user.Username, user.Look, user.Motto, string.Empty);
                newFriend.UpdateUser(friend);
            }

            if (!friends.ContainsKey(friendID))
            {
                friends.Add(friendID, newFriend);
            }

            GetClient().SendMessage(SerializeUpdate(newFriend));
        }
Exemplo n.º 4
0
        internal static void Initialize(IQueryAdapter dbClient)
        {
            dbClient.setQuery("SELECT username, look, motto FROM users WHERE id = '" + EmuSettings.CHAT_USER_ID + "'");
            DataRow dRow = dbClient.getRow();

            if (dRow != null)
            {
                MessengerStaff = new MessengerBuddy(EmuSettings.CHAT_USER_ID, (string)dRow["username"], (string)dRow["look"], (string)dRow["motto"]);
            }
        }
Exemplo n.º 5
0
        public ServerPacket SerializeUpdate(MessengerBuddy friend)
        {
            ServerPacket reply = new ServerPacket(ServerPacketHeader.FriendListUpdateMessageComposer);

            reply.WriteInteger(0);
            reply.WriteInteger(1);
            reply.WriteInteger(0);
            friend.Serialize(reply);
            reply.WriteBoolean(false);
            return(reply);
        }
Exemplo n.º 6
0
        internal static ServerMessage SerializeUpdate(MessengerBuddy friend)
        {
            ServerMessage reply = new ServerMessage(13);
            reply.AppendInt32(0);
            reply.AppendInt32(1);
            reply.AppendInt32(0);

            friend.Serialize(reply);
            reply.AppendBoolean(false);

            return reply;
        }
Exemplo n.º 7
0
        internal static ServerMessage SerializeUpdate(MessengerBuddy friend)
        {
            ServerMessage reply = new ServerMessage(13);

            reply.AppendInt32(0);
            reply.AppendInt32(1);
            reply.AppendInt32(0);

            friend.Serialize(reply);
            reply.AppendBoolean(false);

            return(reply);
        }
Exemplo n.º 8
0
        internal static ServerMessage SerializeUpdate(MessengerBuddy friend, Habbo Habbo)
        {
            friend.UpdateUserSettings();

            var reply = new ServerMessage(Outgoing.FriendUpdate);

            reply.AppendInt32(0);                       // category
            reply.AppendInt32(friend.IsOnline ? 2 : 1); // number of updates
            if (friend.IsOnline)
            {
                reply.AppendInt32(1);
                friend.Serialize(reply, Habbo);
            }
            reply.AppendInt32(0); // don't know
            friend.Serialize(reply, Habbo);
            reply.AppendBoolean(false);

            return(reply);
        }
Exemplo n.º 9
0
        internal override void SerializeAndSendUpdate(MessengerBuddy friend)
        {
            if (GetClient() == null)
                return;
            ServerMessage reply = PacketHandelingManager.GetRecycledItem(OutputCode.FriendListUpdateEvent);
            reply.AddInt32(0);
            reply.AddInt32(1);
            reply.AddInt32(0);
            
            friend.Serialize(reply);
            reply.AddBoolean(false);

            GetClient().SendMessage(reply);
        }
Exemplo n.º 10
0
 internal abstract void SerializeAndSendUpdate(MessengerBuddy friend);
Exemplo n.º 11
0
        internal void OnNewFriendship(uint friendID)
        {
            GameClient friend = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID);

            MessengerBuddy newFriend;
            if (friend == null || friend.GetHabbo() == null)
            {
                DataRow dRow;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT username,motto,look,last_online FROM users WHERE id = " + friendID);
                    dRow = dbClient.getRow();
                }

                newFriend = new MessengerBuddy(friendID, (string)dRow["username"], (string)dRow["look"], (string)dRow["motto"], (string)dRow["last_online"]);
            }
            else
            {
                Habbo user = friend.GetHabbo();
                newFriend = new MessengerBuddy(friendID, user.Username, user.Look, user.Motto, string.Empty);
                newFriend.UpdateUser(friend);
            }

            if (!friends.ContainsKey(friendID))
                friends.Add(friendID, newFriend);

            GetClient().SendMessage(SerializeUpdate(newFriend));
        }
Exemplo n.º 12
0
        internal void OnNewFriendship(uint friendID)
        {
            if (friends.Count >= MAX_FRIENDS)
                return;

            GameClient friend = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID);

            MessengerBuddy newFriend;
            if (friend == null || friend.GetHabbo() == null)
            {
                DataRow dRow;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT username,motto,look,last_online FROM users WHERE id = " + friendID);
                    dRow = dbClient.getRow();
                }

                newFriend = new MessengerBuddy(friendID, (string)dRow["username"], (string)dRow["look"], (string)dRow["motto"], (string)dRow["last_online"], 0);
            }
            else
            {
                Habbo user = friend.GetHabbo();
                newFriend = new MessengerBuddy(friendID, user.Username, user.Look, user.Motto, string.Empty, 0);
            }

            if (!friends.ContainsKey(friendID) && this.initialized)
                friends.Add(friendID, newFriend);

            foreach (AbstractChatHandler handlers in listeners)
            {
                handlers.SerializeAndSendUpdate(newFriend);
            }
        }