internal void LoadProfile() { try { int UserId = Request.ReadInt32(); Boolean IsMe = Request.ReadBoolean(); /* don't know * if (IsMe) * UserId = (int)Session.GetHabbo().Id;*/ Habbo Data = FirewindEnvironment.getHabboForId((uint)UserId); if (Data == null) { Logging.WriteLine("can't get data por profile with userid = " + UserId); return; } Response.Init(Outgoing.ProfileInformation); Response.AppendUInt(Data.Id); Response.AppendString(Data.Username); Response.AppendString(Data.Look); Response.AppendString(Data.Motto); Response.AppendString("12/12/12"); // created Response.AppendInt32(Data.AchievementPoints); // Achievement Points Response.AppendInt32(0); //friends //Response.AppendString(String.Empty); Response.AppendBoolean(Data.Id != Session.GetHabbo().Id); // is me maybe? Response.AppendInt32(0); // group count Response.AppendString(""); Response.AppendInt32(-1); Response.AppendBoolean(true); // show it /* group: * int(Id) * string(Name) * String(Badge) * String(FirstColor) * String(SecondColor) * Boolean(Fav) */ // and achiv points after dat if groups or sth??? SendResponse(); } catch (Exception e) { } }
internal void LoadProfile() { int userID = Request.ReadInt32(); bool unused = Request.ReadBoolean(); // Always true Habbo Data; Data = userID == Session.GetHabbo().Id ? Session.GetHabbo() : FirewindEnvironment.getHabboForId(userID); if (Data == null) { return; } // Get the info we need List <Group> groups = FirewindEnvironment.GetGame().GetGroupManager().GetMemberships(userID); bool isOnline = FirewindEnvironment.GetGame().GetClientManager().GetClientByUserID(userID) != null; Response.Init(Outgoing.ProfileInformation); Response.AppendInt32(Data.Id); Response.AppendString(Data.Username); Response.AppendString(Data.Look); Response.AppendString(Data.Motto); Response.AppendString("12/12/12"); // created Response.AppendInt32(Data.AchievementPoints); // Achievement Points Response.AppendInt32(Data.GetMessenger().myFriends); //friends Response.AppendBoolean(userID != Session.GetHabbo().Id&& Data.GetMessenger().FriendshipExists(Session.GetHabbo().Id)); // is friend Response.AppendBoolean(Data.GetMessenger().requests.ContainsKey(Session.GetHabbo().Id)); // firend request sent Response.AppendBoolean(isOnline); // is online Response.AppendInt32(groups.Count); // group count foreach (Group group in groups) { Response.AppendInt32(group.ID); Response.AppendString(group.Name); Response.AppendString(group.BadgeCode); Response.AppendString(group.Color1); Response.AppendString(group.Color2); Response.AppendBoolean(Data.FavouriteGroup == group.ID); } Response.AppendInt32(-1); // last online Response.AppendBoolean(true); // show it SendResponse(); }
internal bool tryLogin(string AuthTicket) { int loginProgress = 0; try { string ip = GetConnection().getIp(); byte errorCode = 0; UserData userData = UserDataFactory.GetUserData(AuthTicket, ip, out errorCode); if (errorCode == 1) { SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso")); return(false); } else if (errorCode == 2) { SendNotifWithScroll(LanguageLocale.GetValue("login.loggedin")); return(false); } loginProgress++; FirewindEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); this.Habbo = userData.user; userData.user.LoadData(userData); loginProgress++; if (userData.user.Username == null) { SendBanMessage("You have no username."); return(false); } string banReason = FirewindEnvironment.GetGame().GetBanManager().GetBanReason(userData.user.Username, ip); loginProgress++; if (!string.IsNullOrEmpty(banReason)) { SendBanMessage(banReason); return(false); } userData.user.Init(this, userData); QueuedServerMessage response = new QueuedServerMessage(Connection); ServerMessage UniqueId = new ServerMessage(Outgoing.UniqueID); UniqueId.AppendString(this.MachineId); response.appendResponse(UniqueId); ServerMessage authok = new ServerMessage(Outgoing.AuthenticationOK); response.appendResponse(authok); ServerMessage HomeRoom = new ServerMessage(Outgoing.HomeRoom); HomeRoom.AppendUInt(this.GetHabbo().HomeRoom); // first home HomeRoom.AppendUInt(this.GetHabbo().HomeRoom); // first home SendMessage(HomeRoom); loginProgress++; ServerMessage FavouriteRooms = new ServerMessage(Outgoing.FavouriteRooms); FavouriteRooms.AppendInt32(30); // max rooms FavouriteRooms.AppendInt32(userData.user.FavoriteRooms.Count); foreach (uint Id in userData.user.FavoriteRooms.ToArray()) { FavouriteRooms.AppendUInt(Id); } response.appendResponse(FavouriteRooms); loginProgress++; ServerMessage fuserights = new ServerMessage(Outgoing.Fuserights); if (GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip")) // VIP { fuserights.AppendInt32(2); } else if (GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club")) // HC { fuserights.AppendInt32(1); } else { fuserights.AppendInt32(0); } fuserights.AppendUInt(this.GetHabbo().Rank); response.appendResponse(fuserights); loginProgress++; ServerMessage bools1 = new ServerMessage(Outgoing.AvailabilityStatus); bools1.AppendBoolean(true); bools1.AppendBoolean(false); response.appendResponse(bools1); ServerMessage bools2 = new ServerMessage(Outgoing.InfoFeedEnable); bools2.AppendBoolean(false); response.appendResponse(bools2); loginProgress++; ServerMessage setRanking = new ServerMessage(Outgoing.SerializeCompetitionWinners); setRanking.AppendString("hlatCompetitions"); // competition type setRanking.AppendInt32(Ranking.getCompetitionForInfo("hlatCompetitions").Count); loginProgress++; int i = 0; foreach (Ranking r in Ranking.getCompetitionForInfo("hlatCompetitions")) { i++; setRanking.AppendUInt(r.UserId); Habbo data = FirewindEnvironment.getHabboForId(r.UserId); setRanking.AppendString((data != null) ? data.Username : "******"); setRanking.AppendString((data != null) ? data.Look : "sh-907-96.hd-3096-3.he-3082-91.lg-3018-81.ch-660-95.hr-9534-34"); setRanking.AppendInt32(i); // position setRanking.AppendInt32(r.Score); } response.appendResponse(setRanking); loginProgress++; if (userData.user.HasFuse("fuse_mod")) { this.SendMessage(FirewindEnvironment.GetGame().GetModerationTool().SerializeTool()); FirewindEnvironment.GetGame().GetModerationTool().SerializeOpenTickets(ref response, userData.userID); } if (LanguageLocale.welcomeAlertEnabled) { this.SendMOTD(LanguageLocale.welcomeAlert); } loginProgress++; using (IQueryAdapter db = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { db.setQuery("UPDATE users SET online = '1' WHERE id = @id"); db.addParameter("id", this.GetHabbo().Id); db.runQuery(); } loginProgress++; // Send the big chunk response.sendResponse(); // fire the event! FirewindEnvironment.GetGame().GetClientManager().ClientLoggedIn(this); return(true); } catch (UserDataNotFoundException e) { SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso") + "extra data: " + e.ToString()); } catch (Exception e) { Logging.LogCriticalException(String.Format("Invalid Dario bug duing user login (progress = {0}): ", loginProgress) + e.ToString()); SendNotifWithScroll("Login error: " + e.ToString()); } return(false); }
internal void Chat(GameClient Session, string Message, bool Shout) { if (Session != null) { if (Session.GetHabbo().Rank < 5) { if (GetRoom().RoomMuted) { return; } } } Unidle(); if (!IsPet && !IsBot) { Users.Habbo clientUser = GetClient().GetHabbo(); if (clientUser.Muted) { GetClient().SendNotif("You are muted."); return; } if (Message.StartsWith(":") && Session != null) { string[] parsedCommand = Message.Split(' '); if (ChatCommandRegister.IsChatCommand(parsedCommand[0].ToLower().Substring(1))) { try { ChatCommandHandler handler = new ChatCommandHandler(Message.Split(' '), Session); if (handler.WasExecuted()) { //Logging.LogMessage(string.Format("User {0} issued command {1}", GetUsername(), Message)); if (Session.GetHabbo().Rank > 5) { FirewindEnvironment.GetGame().GetModerationTool().LogStaffEntry(Session.GetHabbo().Username, string.Empty, "Chat command", string.Format("Issued chat command {0}", Message)); } return; } } catch (Exception x) { Logging.LogException("In-game command error: " + x.ToString()); } } if (FirewindEnvironment.IsHabin) { bool result; using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT id FROM users WHERE (hpo = '1' OR hpo = '1' OR hds = '1' OR hmg = '1' OR hmb = '1' OR ele = '1' OR lar = '1') AND username = @name"); dbClient.addParameter("name", Session.GetHabbo().Username); result = dbClient.findsResult(); string command = parsedCommand[0].Substring(1); // F**k this command system, we make our own! switch (command) { case "relationship": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("SELECT sender_id FROM users_relationships WHERE (recipent_id = @myid OR sender_id = @myid) AND accepted = '0'"); dbClient.addParameter("myid", Session.GetHabbo().Id); if (dbClient.findsResult()) { Session.SendMOTD("Du har allerede spurt om et forhold med denne personen, vennligst vent på et svar."); return; } dbClient.setQuery("SELECT id FROM users WHERE username = @name"); dbClient.addParameter("name", parsedCommand[1]); int id = dbClient.getInteger(); dbClient.setQuery("INSERT IGNORE INTO users_relationships(sender_id,recipent_id) VALUES(@myid,@hisid)"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.addParameter("hisid", id); dbClient.runQuery(); Session.SendMOTD("Du har sendt en forespørsel til " + parsedCommand[1]); return; case "mystatus": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } if (false) { Session.SendMOTD("Du er i et forhold med {0}, vil du avslutte forholdet skriv :remove {0}"); return; } StringBuilder statusMessage = new StringBuilder(); statusMessage.AppendLine("Du har følgende forespørsler:"); dbClient.setQuery("SELECT sender_id FROM users_relationships WHERE accepted = '0' AND recipent_id = @myid LIMIT 6"); dbClient.addParameter("myid", Session.GetHabbo().Id); DataTable table = dbClient.getTable(); foreach (DataRow row in table.Rows) { statusMessage.AppendLine(FirewindEnvironment.getHabboForId(Convert.ToUInt32(row[0])).Username); } statusMessage.AppendLine("Du kan maks ha 6 forespørsler på en gang."); statusMessage.AppendLine("Skriv :accept navn for å akseptere en forespørsel."); Session.SendMOTD(statusMessage.ToString()); return; case "accept": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("SELECT sender_id FROM users_relationships WHERE (recipent_id = @myid OR sender_id = @myid) AND accepted = '1'"); dbClient.addParameter("myid", Session.GetHabbo().Id); if (dbClient.findsResult()) { Session.SendMOTD("Du er allerede i et forhold!"); return; } dbClient.setQuery("UPDATE users_relationships SET accepted = '1' WHERE sender_id = @sid AND recipent_id = @myid LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.addParameter("sid", FirewindEnvironment.getHabboForName(parsedCommand[1]).Id); dbClient.runQuery(); Session.SendMOTD("Du er nå i et forhold med " + parsedCommand[1]); return; case "decline": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("DELETE FROM users_relationships WHERE sender_id = @sid AND recipent_id = @myid AND accepted = '0' LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.addParameter("sid", FirewindEnvironment.getHabboForName(parsedCommand[1]).Id); dbClient.runQuery(); Session.SendMOTD("Du har avslått " + parsedCommand[1]); return; case "declineall": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("DELETE FROM users_relationships WHERE recipent_id = @myid AND accepted = '0' LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.runQuery(); Session.SendMOTD("Du har avslått alle."); return; case "status": uint userID = FirewindEnvironment.getHabboForName(parsedCommand[1]).Id; dbClient.setQuery("SELECT sender_id,recipent_id FROM users_relationships WHERE (recipent_id = @userid OR sender_id = @userid) AND accepted = '1' LIMIT 1"); dbClient.addParameter("userid", userID); DataRow resultRow = dbClient.getRow(); if (resultRow == null) { Session.SendMOTD(parsedCommand[1] + " er singel."); } else { bool isSender = Convert.ToUInt32(resultRow[0]) == userID; Session.SendMOTD(parsedCommand[1] + " er i et forhold med " + (isSender ? FirewindEnvironment.getHabboForId(Convert.ToUInt32(resultRow[1])).Username : FirewindEnvironment.getHabboForId(Convert.ToUInt32(resultRow[0])).Username)); } return; case "removerelationship": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("DELETE FROM users_relationships WHERE accepted = '1' AND (recipent_id = @myid OR sender_id = @myid) LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.runQuery(); Session.SendMOTD("Du er ikke lenger i noen forhold."); return; } } } } uint rank = 1; Message = LanguageLocale.FilterSwearwords(Message); if (Session != null && Session.GetHabbo() != null) { rank = Session.GetHabbo().Rank; } TimeSpan SinceLastMessage = DateTime.Now - clientUser.spamFloodTime; if (SinceLastMessage.TotalSeconds > clientUser.spamProtectionTime && clientUser.spamProtectionBol == true) { FloodCount = 0; clientUser.spamProtectionBol = false; clientUser.spamProtectionAbuse = 0; } else { if (SinceLastMessage.TotalSeconds > 4) { FloodCount = 0; } } if (SinceLastMessage.TotalSeconds < clientUser.spamProtectionTime && clientUser.spamProtectionBol == true) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); int timeToWait = clientUser.spamProtectionTime - SinceLastMessage.Seconds; Packet.AppendInt32(timeToWait); //Blocked for X sec GetClient().SendMessage(Packet); if (FirewindEnvironment.spamBans == true) { clientUser.spamProtectionAbuse++; GameClient toBan; toBan = FirewindEnvironment.GetGame().GetClientManager().GetClientByUsername(Session.GetHabbo().Username); if (clientUser.spamProtectionAbuse >= FirewindEnvironment.spamBans_limit) { FirewindEnvironment.GetGame().GetBanManager().BanUser(toBan, "SPAM*ABUSE", 800, LanguageLocale.GetValue("flood.banmessage"), false); } else { toBan.SendNotif(LanguageLocale.GetValue("flood.pleasewait").Replace("%secs%", Convert.ToString(timeToWait))); } } return; } if (SinceLastMessage.TotalSeconds < 4 && FloodCount > 5 && rank < 5) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); clientUser.spamProtectionCount += 1; if (clientUser.spamProtectionCount % 2 == 0) { clientUser.spamProtectionTime = (10 * clientUser.spamProtectionCount); } else { clientUser.spamProtectionTime = 10 * (clientUser.spamProtectionCount - 1); } clientUser.spamProtectionBol = true; Packet.AppendInt32(clientUser.spamProtectionTime - SinceLastMessage.Seconds); //Blocked for X sec GetClient().SendMessage(Packet); return; } clientUser.spamFloodTime = DateTime.Now; FloodCount++; FirewindEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, HabboHotel.Quests.QuestType.SOCIAL_CHAT); GetClient().GetHabbo().GetChatMessageManager().AddMessage(ChatMessageFactory.CreateMessage(Message, this.GetClient(), this.GetRoom())); } InvokedChatMessage message = new InvokedChatMessage(this, Message, Shout); GetRoom().QueueChatMessage(message); }