public bool TryGetRequest(int senderID, out MessengerRequest Request) { return(_requests.TryGetValue(senderID, out Request)); }
public bool RequestBuddy(string UserQuery) { int userID; bool hasFQDisabled; GameClient client = NeonEnvironment.GetGame().GetClientManager().GetClientByUsername(UserQuery); if (client == null) { DataRow Row = null; using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id`,`block_newfriends` FROM `users` WHERE `username` = @query LIMIT 1"); dbClient.AddParameter("query", UserQuery.ToLower()); Row = dbClient.getRow(); } if (Row == null) { return(false); } userID = Convert.ToInt32(Row["id"]); hasFQDisabled = NeonEnvironment.EnumToBool(Row["block_newfriends"].ToString()); } else { userID = client.GetHabbo().Id; hasFQDisabled = client.GetHabbo().AllowFriendRequests; } if (hasFQDisabled) { GetClient().SendMessage(new MessengerErrorComposer(39, 3)); return(false); } int ToId = userID; if (RequestExists(ToId)) { return(true); } using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("REPLACE INTO `messenger_requests` (`from_id`,`to_id`) VALUES ('" + _userId + "','" + ToId + "')"); } NeonEnvironment.GetGame().GetQuestManager().ProgressUserQuest(GetClient(), QuestType.ADD_FRIENDS); GameClient ToUser = NeonEnvironment.GetGame().GetClientManager().GetClientByUserID(ToId); if (ToUser == null || ToUser.GetHabbo() == null) { return(true); } MessengerRequest Request = new MessengerRequest(ToId, _userId, NeonEnvironment.GetGame().GetClientManager().GetNameById(_userId)); ToUser.GetHabbo().GetMessenger().OnNewRequest(_userId); UserCache ThisUser = NeonEnvironment.GetGame().GetCacheManager().GenerateUser(_userId); if (ThisUser != null) { ToUser.SendMessage(new NewBuddyRequestComposer(ThisUser)); } _requests.Add(ToId, Request); return(true); }