Beispiel #1
0
        internal bool RequestBuddy(string UserQuery)
        {
            uint userID;
            bool hasFQDisabled;

            GameClient client = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(UserQuery);

            if (client == null)
            {
                DataRow Row = null;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT id,block_newfriends FROM users WHERE username = @query");
                    dbClient.addParameter("query", UserQuery.ToLower());
                    Row = dbClient.getRow();
                }

                if (Row == null)
                    return false;

                userID = (uint)Row["id"];
                hasFQDisabled = ButterflyEnvironment.EnumToBool(Row["block_newfriends"].ToString());
            }
            else
            {
                userID = client.GetHabbo().Id;
                hasFQDisabled = client.GetHabbo().HasFriendRequestsDisabled;
            }

            uint ToId = userID;

            if (messenger.RequestExists(ToId))
            {
                return false;
            }

            if (hasFQDisabled)
            {
                SendNotAcceptFriendRequests();
                return false;
            }

            if (messenger.friends.Count >= HabboMessenger.MAX_FRIENDS)
            {
                this.SendNotificationToUser("To much friends! Max 600");
                return false;
            }

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("REPLACE INTO messenger_requests (sender,receiver) VALUES (" + messenger.UserId + "," + ToId + ")");
            }

            MessengerRequest Request = new MessengerRequest(ToId, messenger.UserId, ButterflyEnvironment.GetGame().GetClientManager().GetNameById(messenger.UserId));

            MessengerManager.instance.GetUserMessenger(ToId).OnNewRequest(messenger.UserId, Request);
            messenger.requests.Add(ToId, Request);
            return true;
        }
Beispiel #2
0
        internal bool RequestBuddy(string UserQuery)
        {
            if ((requests.Count + friends.Count) > EmuSettings.FRIENDS_LIMIT)
            {
                GetClient().GetMessageHandler().GetResponse().Init(Outgoing.CannotAddFriends);
                GetClient().GetMessageHandler().GetResponse().AppendInt32(39);
                GetClient().GetMessageHandler().GetResponse().AppendInt32(1); // 1 -> nuestra lista esta llena
                GetClient().GetMessageHandler().SendResponse();
                return(true);
            }

            uint userID;
            bool hasFQDisabled;

            var client = OtanixEnvironment.GetGame().GetClientManager().GetClientByUsername(UserQuery);

            if (client == null)
            {
                DataRow Row = null;
                using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT id,block_newfriends FROM users WHERE username = @query");
                    dbClient.addParameter("query", UserQuery.ToLower());
                    Row = dbClient.getRow();
                }

                if (Row == null)
                {
                    return(false);
                }

                userID        = Convert.ToUInt32(Row["id"]);
                hasFQDisabled = OtanixEnvironment.EnumToBool(Row["block_newfriends"].ToString());
            }
            else
            {
                userID        = client.GetHabbo().Id;
                hasFQDisabled = client.GetHabbo().HasFriendRequestsDisabled;
            }

            if (hasFQDisabled)
            {
                GetClient().GetMessageHandler().GetResponse().Init(Outgoing.CannotAddFriends);
                GetClient().GetMessageHandler().GetResponse().AppendInt32(39);
                GetClient().GetMessageHandler().GetResponse().AppendInt32(3); // 3 -> Amigo tiene peticiones desactivadas
                GetClient().GetMessageHandler().SendResponse();
                return(true);
            }

            var ToId = userID;

            if (RequestExists(ToId))
            {
                return(true);
            }

            using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("REPLACE INTO messenger_requests (sender,receiver) VALUES (" + UserId + "," + ToId + ")");
            }

            var ToUser = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(ToId);

            if (ToUser == null || ToUser.GetHabbo() == null || ToUser.GetHabbo().GetMessenger() == null)
            {
                return(true);
            }

            var Request = new MessengerRequest(ToId, UserId, OtanixEnvironment.GetGame().GetClientManager().GetNameById(UserId));

            ToUser.GetHabbo().GetMessenger().OnNewRequest(UserId);

            var NewFriendNotif = new ServerMessage(Outgoing.SendFriendRequest);

            Request.Serialize(NewFriendNotif);
            ToUser.SendMessage(NewFriendNotif);
            if (!requests.ContainsKey(ToId))
            {
                requests.Add(ToId, Request);
            }

            return(true);
        }
Beispiel #3
0
 internal abstract void OnNewFriendRequest(uint friendID, MessengerRequest request);
Beispiel #4
0
 internal override void OnNewFriendRequest(uint friendID, MessengerRequest request)
 {
     ServerMessage NewFriendNotif = PacketHandelingManager.GetRecycledItem(OutputCode.NewBuddyRequestEvent);
     request.Serialize(NewFriendNotif);
     GetClient().SendMessage(NewFriendNotif);
 }
Beispiel #5
0
        internal bool RequestBuddy(string UserQuery)
        {
            uint userID;
            bool hasFQDisabled;

            GameClient client = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(UserQuery);

            if (client == null)
            {
                DataRow Row = null;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT id,block_newfriends FROM users WHERE username = @query");
                    dbClient.addParameter("query", UserQuery.ToLower());
                    Row = dbClient.getRow();
                }

                if (Row == null)
                    return false;

                userID = Convert.ToUInt32(Row["id"]);
                hasFQDisabled = ButterflyEnvironment.EnumToBool(Row["block_newfriends"].ToString());
            }
            else
            {
                userID = client.GetHabbo().Id;
                hasFQDisabled = client.GetHabbo().HasFriendRequestsDisabled;
            }

            if (hasFQDisabled)
            {
                GetClient().GetMessageHandler().GetResponse().Init(260);
                GetClient().GetMessageHandler().GetResponse().AppendInt32(39);
                GetClient().GetMessageHandler().GetResponse().AppendInt32(3);
                GetClient().GetMessageHandler().SendResponse();
                return true;
            }

            uint ToId = userID;

            if (RequestExists(ToId))
            {
                return true;
            }

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == Database_Manager.Database.DatabaseType.MSSQL)
                {
                    dbClient.runFastQuery("DELETE FROM messenger_requests WHERE sender = " + userID + " AND receiver = " + ToId);
                    dbClient.runFastQuery("INSERT INTO messenger_requests (sender,receiver) VALUES (" + this.UserId + "," + ToId + ")");
                }
                else
                {
                    dbClient.runFastQuery("REPLACE INTO messenger_requests (sender,receiver) VALUES (" + this.UserId + "," + ToId + ")");
                }
            }

            GameClient ToUser = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(ToId);

            if (ToUser == null || ToUser.GetHabbo() == null)
            {
                return true;
            }

            MessengerRequest Request = new MessengerRequest(ToId, UserId, ButterflyEnvironment.GetGame().GetClientManager().GetNameById(UserId));

            ToUser.GetHabbo().GetMessenger().OnNewRequest(UserId);

            ServerMessage NewFriendNotif = new ServerMessage(132);
            Request.Serialize(NewFriendNotif);
            ToUser.SendMessage(NewFriendNotif);
            requests.Add(ToId, Request);
            return true;
        }
Beispiel #6
0
        public bool RequestBuddy(string UserQuery)
        {
            GameClient clientByUsername = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(UserQuery);
            int        num1;
            bool       flag;

            if (clientByUsername == null)
            {
                DataRow dataRow = (DataRow)null;
                using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor.SetQuery("SELECT id,block_newfriends FROM users WHERE username = @query");
                    queryreactor.AddParameter("query", UserQuery.ToLower());
                    dataRow = queryreactor.GetRow();
                }
                if (dataRow == null)
                {
                    return(false);
                }
                num1 = Convert.ToInt32(dataRow["id"]);
                flag = ButterflyEnvironment.EnumToBool(dataRow["block_newfriends"].ToString());
            }
            else
            {
                if (clientByUsername.GetHabbo() != null)
                {
                    num1 = clientByUsername.GetHabbo().Id;
                    flag = clientByUsername.GetHabbo().HasFriendRequestsDisabled;
                }
                else
                {
                    return(false);
                }
            }
            if (flag)
            {
                this.GetClient().SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("notif.textamigo.error", this.GetClient().Langue));
                return(false);
            }
            else
            {
                int num2 = num1;
                if (this.RequestExists(num2))
                {
                    return(false);
                }
                using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor.RunQuery("REPLACE INTO messenger_requests (from_id,to_id) VALUES (" + this.UserId + "," + num2 + ")");
                }
                GameClient clientByUserId = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(num2);
                if (clientByUserId == null || clientByUserId.GetHabbo() == null)
                {
                    return(false);
                }
                MessengerRequest messengerRequest = new MessengerRequest(num2, this.UserId, ButterflyEnvironment.GetGame().GetClientManager().GetNameById(this.UserId));
                clientByUserId.GetHabbo().GetMessenger().OnNewRequest(this.UserId);
                ServerPacket serverMessage = new ServerPacket(ServerPacketHeader.NewBuddyRequestMessageComposer);
                messengerRequest.Serialize(serverMessage);
                clientByUserId.SendPacket(serverMessage);
                if (!this.requests.ContainsKey(num2))
                {
                    this.requests.Add(num2, messengerRequest);
                }
                return(true);
            }
        }
Beispiel #7
0
        internal void OnNewRequest(uint friendID, MessengerRequest request)
        {
            if (requests.Count >= MAX_FRIENDS)
                return;

            if (!requests.ContainsKey(friendID))
                requests.Add(friendID, new MessengerRequest(UserId, friendID, ButterflyEnvironment.GetGame().GetClientManager().GetNameById(friendID)));
            foreach (AbstractChatHandler handler in listeners)
            {
                handler.OnNewFriendRequest(friendID, request);
            }
        }
Beispiel #8
0
        internal bool RequestBuddy(string UserQuery)
        {
            uint userID;
            bool hasFQDisabled;

            GameClient client = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(UserQuery);

            if (client == null)
            {
                DataRow Row = null;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT id,block_newfriends FROM users WHERE username = @query");
                    dbClient.addParameter("query", UserQuery.ToLower());
                    Row = dbClient.getRow();
                }

                if (Row == null)
                {
                    return(false);
                }

                userID        = Convert.ToUInt32(Row["id"]);
                hasFQDisabled = ButterflyEnvironment.EnumToBool(Row["block_newfriends"].ToString());
            }
            else
            {
                userID        = client.GetHabbo().Id;
                hasFQDisabled = client.GetHabbo().HasFriendRequestsDisabled;
            }

            if (hasFQDisabled)
            {
                GetClient().GetMessageHandler().GetResponse().Init(260);
                GetClient().GetMessageHandler().GetResponse().AppendInt32(39);
                GetClient().GetMessageHandler().GetResponse().AppendInt32(3);
                GetClient().GetMessageHandler().SendResponse();
                return(true);
            }

            uint ToId = userID;

            if (RequestExists(ToId))
            {
                return(true);
            }

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == Database_Manager.Database.DatabaseType.MSSQL)
                {
                    dbClient.runFastQuery("DELETE FROM messenger_requests WHERE sender = " + userID + " AND receiver = " + ToId);
                    dbClient.runFastQuery("INSERT INTO messenger_requests (sender,receiver) VALUES (" + this.UserId + "," + ToId + ")");
                }
                else
                {
                    dbClient.runFastQuery("REPLACE INTO messenger_requests (sender,receiver) VALUES (" + this.UserId + "," + ToId + ")");
                }
            }

            GameClient ToUser = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(ToId);

            if (ToUser == null || ToUser.GetHabbo() == null)
            {
                return(true);
            }

            MessengerRequest Request = new MessengerRequest(ToId, UserId, ButterflyEnvironment.GetGame().GetClientManager().GetNameById(UserId));

            ToUser.GetHabbo().GetMessenger().OnNewRequest(UserId);

            ServerMessage NewFriendNotif = new ServerMessage(132);

            Request.Serialize(NewFriendNotif);
            ToUser.SendMessage(NewFriendNotif);
            requests.Add(ToId, Request);
            return(true);
        }