public static UserData GetUserData(int UserId) { DataRow dUserInfo = null; DataRow UserInfo = null; DataTable dRelations = null; DataTable dGroups = null; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `users` WHERE `id` = @id LIMIT 1"); dbClient.AddParameter("id", UserId); dUserInfo = dbClient.getRow(); CloudServer.GetGame().GetClientManager().LogClonesOut(Convert.ToInt32(UserId)); if (dUserInfo == null) { return(null); } if (CloudServer.GetGame().GetClientManager().GetClientByUserID(UserId) != null) { return(null); } dbClient.SetQuery("SELECT * FROM `user_info` WHERE `user_id` = '" + UserId + "' LIMIT 1"); UserInfo = dbClient.getRow(); if (UserInfo == null) { dbClient.runFastQuery("INSERT INTO `user_info` (`user_id`) VALUES ('" + UserId + "')"); dbClient.SetQuery("SELECT * FROM `user_info` WHERE `user_id` = '" + UserId + "' LIMIT 1"); UserInfo = dbClient.getRow(); } dbClient.SetQuery("SELECT group_id,rank FROM group_memberships WHERE user_id=@id"); dbClient.AddParameter("id", UserId); dGroups = dbClient.getTable(); dbClient.SetQuery("SELECT `id`,`target`,`type` FROM user_relationships WHERE user_id=@id"); dbClient.AddParameter("id", UserId); dRelations = dbClient.getTable(); } ConcurrentDictionary <string, UserAchievement> Achievements = new ConcurrentDictionary <string, UserAchievement>(); Dictionary <int, UserTalent> talents = new Dictionary <int, UserTalent>(); List <int> FavouritedRooms = new List <int>(); List <Badge> Badges = new List <Badge>(); Dictionary <int, MessengerBuddy> Friends = new Dictionary <int, MessengerBuddy>(); Dictionary <int, MessengerRequest> FriendRequests = new Dictionary <int, MessengerRequest>(); List <RoomData> Rooms = new List <RoomData>(); Dictionary <int, int> Quests = new Dictionary <int, int>(); Dictionary <string, Subscription> subscriptions = new Dictionary <string, Subscription>(); var tags = new List <string>(); Dictionary <int, Relationship> Relationships = new Dictionary <int, Relationship>(); foreach (DataRow Row in dRelations.Rows) { if (!Relationships.ContainsKey(Convert.ToInt32(Row["id"]))) { Relationships.Add(Convert.ToInt32(Row["target"]), new Relationship(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["target"]), Convert.ToInt32(Row["type"].ToString()))); } } Habbo user = HabboFactory.GenerateHabbo(dUserInfo, UserInfo); return(new UserData(UserId, Achievements, FavouritedRooms, Badges, Friends, FriendRequests, Rooms, Quests, user, Relationships, talents, subscriptions, tags)); }
public void SendInstantMessage(int ToId, string Message) { if (ToId == 0) { return; } if (GetClient() == null) { return; } if (GetClient().GetHabbo() == null) { return; } #region Custom Chats var Group = CloudServer.GetGame().GetGroupManager().GetGroupsForUser(GetClient().GetHabbo().Id).Where(c => c.HasChat).ToList(); foreach (var gp in Group) { if (ToId == int.MinValue + gp.Id) // int.MaxValue { //CloudServer.GetGame().GetClientManager().SendMessaget(new FuckingConsoleMessageComposer(ToId, Message, GetClient().GetHabbo().Username + "/" + GetClient().GetHabbo().Look + "/" + GetClient().GetHabbo().Id), GetClient().GetHabbo().Id); CloudServer.GetGame().GetClientManager().GroupChatAlert(new FuckingConsoleMessageComposer(int.MinValue + gp.Id, Message, GetClient().GetHabbo().Username + "/" + GetClient().GetHabbo().Look + "/" + GetClient().GetHabbo().Id), gp, GetClient().GetHabbo().Id); return; } } if (GetClient().GetHabbo().Rank >= 3 && ToId == int.MinValue) // int.MaxValue { CloudServer.GetGame().GetClientManager().StaffAlert(new FuckingConsoleMessageComposer(ToId, Message, GetClient().GetHabbo().Username + "/" + GetClient().GetHabbo().Look + "/" + GetClient().GetHabbo().Id), GetClient().GetHabbo().Id); return; } else if (GetClient().GetHabbo().Rank == 2 || GetClient().GetHabbo().Rank >= 12 && ToId == (int.MinValue + 1)) { CloudServer.GetGame().GetClientManager().GuideAlert(new FuckingConsoleMessageComposer(ToId, Message, GetClient().GetHabbo().Username + "/" + GetClient().GetHabbo().Look + "/" + GetClient().GetHabbo().Id), GetClient().GetHabbo().Id); return; } #endregion if (!FriendshipExists(ToId)) { GetClient().SendMessage(new InstantMessageErrorComposer(MessengerMessageErrors.YOUR_NOT_FRIENDS, ToId)); return; } if (GetClient().GetHabbo().MessengerSpamCount >= 12) { GetClient().GetHabbo().MessengerSpamTime = CloudServer.GetUnixTimestamp() + 60; GetClient().GetHabbo().MessengerSpamCount = 0; GetClient().SendNotification("You cannot send a message, you have flooded the console.\n\nYou can send a message in 60 seconds."); return; } else if (GetClient().GetHabbo().MessengerSpamTime > CloudServer.GetUnixTimestamp()) { double Time = GetClient().GetHabbo().MessengerSpamTime - CloudServer.GetUnixTimestamp(); GetClient().SendNotification("You cannot send a message, you have flooded the console.\n\nYou can send a message in " + Time + " seconds."); return; } GetClient().GetHabbo().MessengerSpamCount++; GameClient Client = CloudServer.GetGame().GetClientManager().GetClientByUserID(ToId); if (Client == null || Client.GetHabbo() == null || Client.GetHabbo().GetMessenger() == null) { using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("INSERT INTO `messenger_offline_messages` (`to_id`, `from_id`, `message`, `timestamp`) VALUES (@tid, @fid, @msg, UNIX_TIMESTAMP())"); dbClient.AddParameter("tid", ToId); dbClient.AddParameter("fid", GetClient().GetHabbo().Id); dbClient.AddParameter("msg", Message); dbClient.RunQuery(); } return; } if (!Client.GetHabbo().AllowConsoleMessages || Client.GetHabbo().MutedUsers.Contains(GetClient().GetHabbo().Id)) { GetClient().SendMessage(new InstantMessageErrorComposer(MessengerMessageErrors.FRIEND_BUSY, ToId)); return; } if (GetClient().GetHabbo().TimeMuted > 0) { GetClient().SendMessage(new InstantMessageErrorComposer(MessengerMessageErrors.YOUR_MUTED, ToId)); return; } if (Client.GetHabbo().TimeMuted > 0) { GetClient().SendMessage(new InstantMessageErrorComposer(MessengerMessageErrors.FRIEND_MUTED, ToId)); } if (String.IsNullOrEmpty(Message)) { return; } Client.SendMessage(new NewConsoleMessageComposer(_userId, Message)); LogPM(_userId, ToId, Message); }
public static UserData GetUserData(string SessionTicket, out byte errorCode) { int UserId; DataRow dUserInfo = null; DataTable dAchievements = null; DataTable dFavouriteRooms = null; DataTable dBadges = null; DataTable dFriends = null; DataTable dRequests = null; DataTable dRooms = null; DataTable tagsTable; DataTable dQuests = null; DataTable dRelations = null; DataTable talentsTable = null; DataRow UserInfo = null; DataTable Subscriptions = null; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM users WHERE auth_ticket = @sso LIMIT 1"); dbClient.AddParameter("sso", SessionTicket); dUserInfo = dbClient.getRow(); if (dUserInfo == null) { errorCode = 1; return(null); } UserId = Convert.ToInt32(dUserInfo["id"]); if (CloudServer.GetGame().GetClientManager().GetClientByUserID(UserId) != null) { errorCode = 2; CloudServer.GetGame().GetClientManager().GetClientByUserID(UserId).Disconnect(); return(null); } dbClient.SetQuery("SELECT `group`,`level`,`progress` FROM `user_achievements` WHERE `userid` = '" + UserId + "'"); dAchievements = dbClient.getTable(); dbClient.SetQuery("SELECT room_id FROM user_favorites WHERE `user_id` = '" + UserId + "'"); dFavouriteRooms = dbClient.getTable(); dbClient.SetQuery("SELECT `badge_id`,`badge_slot` FROM user_badges WHERE `user_id` = '" + UserId + "'"); dBadges = dbClient.getTable(); dbClient.SetQuery( "SELECT users.id,users.username,users.motto,users.look,users.last_online,users.hide_inroom,users.hide_online " + "FROM users " + "JOIN messenger_friendships " + "ON users.id = messenger_friendships.user_one_id " + "WHERE messenger_friendships.user_two_id = " + UserId + " " + "UNION ALL " + "SELECT users.id,users.username,users.motto,users.look,users.last_online,users.hide_inroom,users.hide_online " + "FROM users " + "JOIN messenger_friendships " + "ON users.id = messenger_friendships.user_two_id " + "WHERE messenger_friendships.user_one_id = " + UserId); dFriends = dbClient.getTable(); dbClient.SetQuery("SELECT messenger_requests.from_id,messenger_requests.to_id,users.username FROM users JOIN messenger_requests ON users.id = messenger_requests.from_id WHERE messenger_requests.to_id = " + UserId); dRequests = dbClient.getTable(); dbClient.SetQuery("SELECT * FROM rooms WHERE `owner` = '" + UserId + "' LIMIT 150"); dRooms = dbClient.getTable(); dbClient.SetQuery("SELECT * FROM users_talents WHERE userid = '" + UserId + "'"); talentsTable = dbClient.getTable(); dbClient.SetQuery("SELECT `quest_id`,`progress` FROM user_quests WHERE `user_id` = '" + UserId + "'"); dQuests = dbClient.getTable(); dbClient.SetQuery("SELECT * FROM `user_relationships` WHERE `user_id` = @id"); dbClient.AddParameter("id", UserId); dRelations = dbClient.getTable(); dbClient.SetQuery("SELECT * FROM user_subscriptions WHERE user_id = '" + UserId + "'"); Subscriptions = dbClient.getTable(); dbClient.SetQuery(string.Format("SELECT `tag` FROM `user_tags` WHERE `user_id` = {0}", UserId)); tagsTable = dbClient.getTable(); dbClient.SetQuery("SELECT * FROM `user_info` WHERE `user_id` = '" + UserId + "' LIMIT 1"); UserInfo = dbClient.getRow(); if (UserInfo == null) { dbClient.runFastQuery("INSERT INTO `user_info` (`user_id`) VALUES ('" + UserId + "')"); dbClient.SetQuery("SELECT * FROM `user_info` WHERE `user_id` = '" + UserId + "' LIMIT 1"); UserInfo = dbClient.getRow(); } dbClient.runFastQuery("UPDATE `users` SET `online` = '1', `auth_ticket` = '' WHERE `id` = '" + UserId + "' LIMIT 1"); } ConcurrentDictionary <string, UserAchievement> Achievements = new ConcurrentDictionary <string, UserAchievement>(); foreach (DataRow dRow in dAchievements.Rows) { Achievements.TryAdd(Convert.ToString(dRow["group"]), new UserAchievement(Convert.ToString(dRow["group"]), Convert.ToInt32(dRow["level"]), Convert.ToInt32(dRow["progress"]))); } List <int> favouritedRooms = new List <int>(); foreach (DataRow dRow in dFavouriteRooms.Rows) { favouritedRooms.Add(Convert.ToInt32(dRow["room_id"])); } List <Badge> badges = new List <Badge>(); foreach (DataRow dRow in dBadges.Rows) { badges.Add(new Badge(Convert.ToString(dRow["badge_id"]), Convert.ToInt32(dRow["badge_slot"]))); } Dictionary <int, MessengerBuddy> friends = new Dictionary <int, MessengerBuddy>(); foreach (DataRow dRow in dFriends.Rows) { int friendID = Convert.ToInt32(dRow["id"]); string friendName = Convert.ToString(dRow["username"]); string friendLook = Convert.ToString(dRow["look"]); string friendMotto = Convert.ToString(dRow["motto"]); int friendLastOnline = Convert.ToInt32(dRow["last_online"]); bool friendHideOnline = CloudServer.EnumToBool(dRow["hide_online"].ToString()); bool friendHideRoom = CloudServer.EnumToBool(dRow["hide_inroom"].ToString()); if (friendID == UserId) { continue; } if (!friends.ContainsKey(friendID)) { friends.Add(friendID, new MessengerBuddy(friendID, friendName, friendLook, friendMotto, friendLastOnline, friendHideOnline, friendHideRoom)); } } Dictionary <int, MessengerRequest> requests = new Dictionary <int, MessengerRequest>(); foreach (DataRow dRow in dRequests.Rows) { int receiverID = Convert.ToInt32(dRow["from_id"]); int senderID = Convert.ToInt32(dRow["to_id"]); string requestUsername = Convert.ToString(dRow["username"]); if (receiverID != UserId) { if (!requests.ContainsKey(receiverID)) { requests.Add(receiverID, new MessengerRequest(UserId, receiverID, requestUsername)); } } else { if (!requests.ContainsKey(senderID)) { requests.Add(senderID, new MessengerRequest(UserId, senderID, requestUsername)); } } } List <RoomData> rooms = new List <RoomData>(); foreach (DataRow dRow in dRooms.Rows) { rooms.Add(CloudServer.GetGame().GetRoomManager().FetchRoomData(Convert.ToInt32(dRow["id"]), dRow)); } Dictionary <int, int> quests = new Dictionary <int, int>(); foreach (DataRow dRow in dQuests.Rows) { int questId = Convert.ToInt32(dRow["quest_id"]); if (quests.ContainsKey(questId)) { quests.Remove(questId); } quests.Add(questId, Convert.ToInt32(dRow["progress"])); } Dictionary <int, Relationship> Relationships = new Dictionary <int, Relationship>(); foreach (DataRow Row in dRelations.Rows) { if (friends.ContainsKey(Convert.ToInt32(Row[2]))) { Relationships.Add(Convert.ToInt32(Row[2]), new Relationship(Convert.ToInt32(Row[0]), Convert.ToInt32(Row[2]), Convert.ToInt32(Row[3].ToString()))); } } Dictionary <int, UserTalent> talents = new Dictionary <int, UserTalent>(); if (talentsTable != null) { foreach (DataRow row in talentsTable.Rows) { int num2 = (int)row["talent_id"]; int state = (int)row["talent_state"]; talents.Add(num2, new UserTalent(num2, state)); } } var tags = (from DataRow row in tagsTable.Rows select row["tag"].ToString().Replace(" ", "")).ToList(); Dictionary <string, Subscription> subscriptions = new Dictionary <string, Subscription>(); foreach (DataRow dataRow in Subscriptions.Rows) { string str = (string)dataRow["subscription_id"]; int TimeExpire = (int)dataRow["timestamp_expire"]; int TimeActivate = (int)dataRow["timestamp_activated"]; subscriptions.Add(str, new Subscription(str, TimeExpire, TimeActivate)); } Habbo user = HabboFactory.GenerateHabbo(dUserInfo, UserInfo); dUserInfo = null; dAchievements = null; dFavouriteRooms = null; dBadges = null; dFriends = null; dRequests = null; dRooms = null; dRelations = null; errorCode = 0; return(new UserData(UserId, Achievements, favouritedRooms, badges, friends, requests, rooms, quests, user, Relationships, talents, subscriptions, tags)); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) { return; } Room Room; if (!CloudServer.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room)) { return; } if (!Room.CheckRights(Session, true)) { return; } int BotId = Packet.PopInt(); int X = Packet.PopInt(); int Y = Packet.PopInt(); if (!Room.GetGameMap().CanWalk(X, Y, false) || !Room.GetGameMap().ValidTile(X, Y)) { Session.SendNotification("Não pode colocar um bot aqui!"); return; } Bot Bot = null; if (!Session.GetHabbo().GetInventoryComponent().TryGetBot(BotId, out Bot)) { return; } int BotCount = 0; foreach (RoomUser User in Room.GetRoomUserManager().GetUserList().ToList()) { if (User == null || User.IsPet || !User.IsBot) { continue; } BotCount += 1; } if (BotCount >= 25 && !Session.GetHabbo().GetPermissions().HasRight("bot_place_any_override")) { Session.SendNotification("Sentimos muito, mas só pode colocar 25 bots no quarto!"); return; } //TODO: Hmm, maybe not???? using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `bots` SET `room_id` = @roomId, `x` = @CoordX, `y` = @CoordY WHERE `id` = @BotId LIMIT 1"); dbClient.AddParameter("roomId", Room.RoomId); dbClient.AddParameter("BotId", Bot.Id); dbClient.AddParameter("CoordX", X); dbClient.AddParameter("CoordY", Y); dbClient.RunQuery(); } List <RandomSpeech> BotSpeechList = new List <RandomSpeech>(); //TODO: Grab data? DataRow GetData = null; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `ai_type`,`rotation`,`walk_mode`,`automatic_chat`,`speaking_interval`,`mix_sentences`,`chat_bubble` FROM `bots` WHERE `id` = @BotId LIMIT 1"); dbClient.AddParameter("BotId", Bot.Id); GetData = dbClient.getRow(); dbClient.SetQuery("SELECT * FROM `bots_speech` WHERE `bot_id` = @BotId ORDER BY id ASC"); dbClient.AddParameter("BotId", Bot.Id); DataTable BotSpeech = dbClient.getTable(); foreach (DataRow Speech in BotSpeech.Rows) { BotSpeechList.Add(new RandomSpeech(Convert.ToString(Speech["text"]), Bot.Id)); } } RoomUser BotUser = Room.GetRoomUserManager().DeployBot(new RoomBot(Bot.Id, Session.GetHabbo().CurrentRoomId, Convert.ToString(GetData["ai_type"]), Convert.ToString(GetData["walk_mode"]), Bot.Name, "", Bot.Figure, X, Y, 0, 4, 0, 0, 0, 0, ref BotSpeechList, "", 0, Bot.OwnerId, CloudServer.EnumToBool(GetData["automatic_chat"].ToString()), Convert.ToInt32(GetData["speaking_interval"]), CloudServer.EnumToBool(GetData["mix_sentences"].ToString()), Convert.ToInt32(GetData["chat_bubble"])), null); using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `bots` WHERE `id` = @BotId "); dbClient.AddParameter("BotId", Bot.Id); DataTable BotSpeechData = dbClient.getTable(); foreach (DataRow SpeechData in BotSpeechData.Rows) { BotUser.Chat("Olá!", false, (Convert.ToInt32(SpeechData["chat_bubble"]))); } } Room.GetGameMap().UpdateUserMovement(new System.Drawing.Point(X, Y), new System.Drawing.Point(X, Y), BotUser); Bot ToRemove = null; if (!Session.GetHabbo().GetInventoryComponent().TryRemoveBot(BotId, out ToRemove)) { Console.WriteLine("Erro em eliminar no bot: " + ToRemove.Id); return; } Session.SendMessage(new BotInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetBots())); }
public bool RequestBuddy(string UserQuery) { int userID; bool hasFQDisabled; GameClient client = CloudServer.GetGame().GetClientManager().GetClientByUsername(UserQuery); if (client == null) { DataRow Row = null; using (IQueryAdapter dbClient = CloudServer.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 = CloudServer.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 = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("REPLACE INTO `messenger_requests` (`from_id`,`to_id`) VALUES ('" + _userId + "','" + ToId + "')"); } CloudServer.GetGame().GetQuestManager().ProgressUserQuest(GetClient(), QuestType.ADD_FRIENDS); GameClient ToUser = CloudServer.GetGame().GetClientManager().GetClientByUserID(ToId); if (ToUser == null || ToUser.GetHabbo() == null) { return(true); } MessengerRequest Request = new MessengerRequest(ToId, _userId, CloudServer.GetGame().GetClientManager().GetNameById(_userId)); ToUser.GetHabbo().GetMessenger().OnNewRequest(_userId); UserCache ThisUser = CloudServer.GetGame().GetCacheManager().GenerateUser(_userId); if (ThisUser != null) { ToUser.SendMessage(new NewBuddyRequestComposer(ThisUser)); } _requests.Add(ToId, Request); return(true); }
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { if (Params.Length == 1) { Session.SendMessage(new RoomNotificationComposer("Lista de colores:", "<font color='#FF8000'><b>LISTA DE COLORES:</b>\n" + "<font size=\"12\" color=\"#1C1C1C\">El comando :pcolor te permitirá fijar un color que tu desees en tu prefijo, para poder seleccionar el color deberás especificarlo después de hacer el comando, como por ejemplo:\r\r" + "<font size =\"11\" color=\"#00e676\"><b>:pcolor cgreen</b> » Prefijo Verde Claro</font>\r\n" + "<font size =\"11\" color=\"#00bcd4\"><b>:pcolor cyan</b> » Prefijo Azul Cielo</font>\r\n" + "<font size =\"11\" color=\"#0000FF\"><b>:pcolor blue</b> » Prefijo Azul Fuerte</font>\r\n" + "<font size =\"11\" color=\"#e91e63\"><b>:pcolor pink</b> » Prefijo Rosado</font>\r\n" + "<font size =\"11\" color=\"#f50101\"><b>:pcolor red</b> » Prefijo Rojo</font>\r\n" + "<font size =\"11\" color=\"#0000FF\"><b>:pcolor tblue</b> » Prefijo Azul Fuerte Claro :D</font>\r\n" + "<font size =\"11\" color=\"#ff0000\"><b>:pcolor orange</b> » Prefijo Naranja</font>\r\n" + "<font size =\"11\" color=\"#31B404\"><b>:pcolor green</b> » Prefijo Verde</font>\r\n" + "<font size =\"11\" color=\"#ff9100\"><b>:pcolor torange</b> » Prefijo Naranja Claro</font>\r\n" + "<font size =\"11\" color=\"" + CloudServer.Rainbow() + "\"><b>:pcolor rainbow</b> » Prefijo Color Aleatorio</font>\r\n" + "", "", "")); return; } string chatColour = Params[1]; string Colour = chatColour.ToUpper(); switch (chatColour) { case "none": case "black": case "off": Session.GetHabbo()._NamePrefixColor = ""; Session.SendWhisper("Tu color de prefijo Ha Sido Desactivado"); break; case "rainbow": Session.GetHabbo()._NamePrefixColor = "rainbow"; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name_color` = 'rainbow' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.SendWhisper("Tu Color de chat ha sido activado a: rainbow"); break; case "cgreen": Session.GetHabbo()._NamePrefixColor = "#00e676"; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name_color` = '#00e676' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.SendWhisper("Tu Color de chat ha sido activado a: cgreen"); break; case "tblue": Session.GetHabbo()._NamePrefixColor = "#0000FF"; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name_color` = '#0000FF' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.SendWhisper("Tu Color de chat ha sido activado a: tblue"); break; case "torange": Session.GetHabbo()._NamePrefixColor = "#ff9100"; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name_color` = '#ff9100' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.SendWhisper("Tu Color de chat ha sido activado a: torange"); break; case "pink": Session.GetHabbo()._NamePrefixColor = "#e91e63"; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name_color` = '#e91e63' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.SendWhisper("Tu Color de chat ha sido activado a: pink"); break; case "blue": Session.GetHabbo()._NamePrefixColor = "#0000FF"; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name_color` = '#0000FF' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.SendWhisper("Tu Color de chat ha sido activado a: blue"); break; case "red": Session.GetHabbo()._NamePrefixColor = "#f50101"; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name_color` = '#f50101' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.SendWhisper("Tu Color de chat ha sido activado a: red"); break; case "green": Session.GetHabbo()._NamePrefixColor = "#31B404"; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name_color` = '#31B404' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.SendWhisper("Tu Color de chat ha sido activado a: green"); break; case "cyan": Session.GetHabbo()._NamePrefixColor = "#00bcd4"; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name_color` = '#00bcd4' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.SendWhisper("Tu Color de chat ha sido activado a: cyan"); break; case "orange": Session.GetHabbo()._NamePrefixColor = "#ff9100"; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name_color` = '#ff9100' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.SendWhisper("Tu Color de chat ha sido activado a: orange"); break; default: Session.SendWhisper("El color del prefijo: " + Colour + " No Existe!"); break; } return; }
public void ProgressUserQuest(GameClient Session, QuestType QuestType, int EventData = 0) { if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetStats().QuestID <= 0) { return; } Quest UserQuest = GetQuest(Session.GetHabbo().GetStats().QuestID); if (UserQuest == null || UserQuest.GoalType != QuestType) { return; } int CurrentProgress = Session.GetHabbo().GetQuestProgress(UserQuest.Id); int NewProgress = CurrentProgress; bool PassQuest = false; switch (QuestType) { default: NewProgress++; if (NewProgress >= UserQuest.GoalData) { PassQuest = true; } break; case QuestType.EXPLORE_FIND_ITEM: if (EventData != UserQuest.GoalData) { return; } NewProgress = Convert.ToInt32(UserQuest.GoalData); PassQuest = true; break; case QuestType.STAND_ON: if (EventData != UserQuest.GoalData) { return; } NewProgress = Convert.ToInt32(UserQuest.GoalData); PassQuest = true; break; case QuestType.XMAS_PARTY: NewProgress++; if (NewProgress == UserQuest.GoalData) { PassQuest = true; } break; case QuestType.GIVE_ITEM: if (EventData != UserQuest.GoalData) { return; } NewProgress = Convert.ToInt32(UserQuest.GoalData); PassQuest = true; break; } using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE `user_quests` SET `progress` = '" + NewProgress + "' WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `quest_id` = '" + UserQuest.Id + "' LIMIT 1"); if (PassQuest) { dbClient.RunQuery("UPDATE `user_stats` SET `quest_id` = '0' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } } Session.GetHabbo().quests[Session.GetHabbo().GetStats().QuestID] = NewProgress; Session.SendMessage(new QuestStartedComposer(Session, UserQuest)); if (PassQuest) { Session.GetHabbo().GetMessenger().BroadcastAchievement(Session.GetHabbo().Id, Users.Messenger.MessengerEventTypes.QUEST_COMPLETED, UserQuest.Category + "." + UserQuest.Name); Session.GetHabbo().GetStats().QuestID = 0; Session.GetHabbo().QuestLastCompleted = UserQuest.Id; Session.SendMessage(new QuestCompletedComposer(Session, UserQuest)); Session.GetHabbo().Duckets += UserQuest.Reward; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, UserQuest.Reward)); GetList(Session, null); } }
public Item AddNewItem(int Id, int BaseItem, string ExtraData, int Group, bool ToInsert, bool FromRoom, int LimitedNumber, int LimitedStack) { UpdateItems(true); if (ToInsert) { if (FromRoom) { using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `items` SET `room_id` = '0', `user_id` = '" + _userId + "' WHERE `id` = '" + Id + "' LIMIT 1"); } } else { using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { if (Id > 0) { dbClient.runFastQuery("INSERT INTO `items` (`id`,`base_item`, `user_id`, `limited_number`, `limited_stack`) VALUES ('" + Id + "', '" + BaseItem + "', '" + _userId + "', '" + LimitedNumber + "', '" + LimitedStack + "')"); } else { dbClient.SetQuery("INSERT INTO `items` (`base_item`, `user_id`, `limited_number`, `limited_stack`) VALUES ('" + BaseItem + "', '" + _userId + "', '" + LimitedNumber + "', '" + LimitedStack + "')"); Id = Convert.ToInt32(dbClient.InsertQuery()); } SendNewItems(Convert.ToInt32(Id)); if (Group > 0) { dbClient.runFastQuery("INSERT INTO `items_groups` VALUES (" + Id + ", " + Group + ")"); } if (!string.IsNullOrEmpty(ExtraData)) { dbClient.SetQuery("UPDATE `items` SET `extra_data` = @extradata WHERE `id` = '" + Id + "' LIMIT 1"); dbClient.AddParameter("extradata", ExtraData); dbClient.RunQuery(); } } } } Item ItemToAdd = new Item(Id, 0, BaseItem, ExtraData, 0, 0, 0, 0, _userId, Group, LimitedNumber, LimitedStack, string.Empty); if (UserHoldsItem(Id)) { RemoveItem(Id); } if (ItemToAdd.IsWallItem) { this._wallItems.TryAdd(ItemToAdd.Id, ItemToAdd); } else { this._floorItems.TryAdd(ItemToAdd.Id, ItemToAdd); } return(ItemToAdd); }
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { Room = Session.GetHabbo().CurrentRoom; if (Room == null) { return; } if (Room.Group == null) { Session.SendWhisper("Bem, não há nenhum grupo aqui?"); return; } using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("DELETE FROM `groups` WHERE `id` = '" + Room.Group.Id + "'"); dbClient.runFastQuery("DELETE FROM `group_memberships` WHERE `group_id` = '" + Room.Group.Id + "'"); dbClient.runFastQuery("DELETE FROM `group_requests` WHERE `group_id` = '" + Room.Group.Id + "'"); dbClient.runFastQuery("UPDATE `rooms` SET `group_id` = '0' WHERE `group_id` = '" + Room.Group.Id + "' LIMIT 1"); dbClient.runFastQuery("UPDATE `user_stats` SET `groupid` = '0' WHERE `groupid` = '" + Room.Group.Id + "' LIMIT 1"); dbClient.runFastQuery("DELETE FROM `items_groups` WHERE `group_id` = '" + Room.Group.Id + "'"); } CloudServer.GetGame().GetGroupManager().DeleteGroup(Room.RoomData.Group.Id); Room.Group = null; Room.RoomData.Group = null; CloudServer.GetGame().GetRoomManager().UnloadRoom(Room); if (Room.RoomData.Group.HasChat) { var Client = CloudServer.GetGame().GetClientManager().GetClientByUserID(Session.GetHabbo().Id); if (Client != null) { Client.SendMessage(new FriendListUpdateComposer(Room.RoomData.Group, -1)); Client.SendMessage(new BroadcastMessageAlertComposer(CloudServer.GetGame().GetLanguageManager().TryGetValue("server.console.alert") + "\n\n Você deixou o grupo, por favor, se você ver o grupo de chat, no entanto, relogue no jogo.")); } } var roomId = Session.GetHabbo().CurrentRoomId; List <RoomUser> UsersToReturn = new List <RoomUser>(Session.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUsers().ToList()); RoomData Data = CloudServer.GetGame().GetRoomManager().GenerateRoomData(roomId); Session.GetHabbo().PrepareRoom(Session.GetHabbo().CurrentRoom.RoomId, ""); CloudServer.GetGame().GetRoomManager().LoadRoom(roomId); foreach (RoomUser User in UsersToReturn) { if (User == null || User.GetClient() == null) { continue; } User.GetClient().SendMessage(new RoomForwardComposer(roomId)); } Session.SendNotification("Éxito, grupo eliminado."); return; }
public void Init() { if (this._userPresets.Count > 0) this._userPresets.Clear(); if (this._moderationCFHTopics.Count > 0) this._moderationCFHTopics.Clear(); if (this._moderationCFHTopicActions.Count > 0) this._moderationCFHTopicActions.Clear(); if (this._bans.Count > 0) this._bans.Clear(); using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { DataTable PresetsTable = null; dbClient.SetQuery("SELECT * FROM `moderation_presets`;"); PresetsTable = dbClient.getTable(); if (PresetsTable != null) { foreach (DataRow Row in PresetsTable.Rows) { string Type = Convert.ToString(Row["type"]).ToLower(); switch (Type) { case "user": this._userPresets.Add(Convert.ToString(Row["message"])); break; case "room": this._roomPresets.Add(Convert.ToString(Row["message"])); break; } } } } using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { DataTable ModerationTopics = null; dbClient.SetQuery("SELECT * FROM `moderation_topics`;"); ModerationTopics = dbClient.getTable(); if (ModerationTopics != null) { foreach (DataRow Row in ModerationTopics.Rows) { if (!this._moderationCFHTopics.ContainsKey(Convert.ToInt32(Row["id"]))) this._moderationCFHTopics.Add(Convert.ToInt32(Row["id"]), Convert.ToString(Row["caption"])); } } } using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { DataTable ModerationTopicsActions = null; dbClient.SetQuery("SELECT * FROM `moderation_topic_actions`;"); ModerationTopicsActions = dbClient.getTable(); if (ModerationTopicsActions != null) { foreach (DataRow Row in ModerationTopicsActions.Rows) { int ParentId = Convert.ToInt32(Row["parent_id"]); if (!this._moderationCFHTopicActions.ContainsKey(ParentId)) { this._moderationCFHTopicActions.Add(ParentId, new List<ModerationPresetActions>()); } this._moderationCFHTopicActions[ParentId].Add(new ModerationPresetActions(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["parent_id"]), Convert.ToString(Row["type"]), Convert.ToString(Row["caption"]), Convert.ToString(Row["message_text"]), Convert.ToInt32(Row["mute_time"]), Convert.ToInt32(Row["ban_time"]), Convert.ToInt32(Row["ip_time"]), Convert.ToInt32(Row["trade_lock_time"]), Convert.ToString(Row["default_sanction"]))); } } } using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { DataTable PresetsActionCats = null; dbClient.SetQuery("SELECT * FROM `moderation_preset_action_categories`;"); PresetsActionCats = dbClient.getTable(); if (PresetsActionCats != null) { foreach (DataRow Row in PresetsActionCats.Rows) { this._userActionPresetCategories.Add(Convert.ToInt32(Row["id"]), Convert.ToString(Row["caption"])); } } } using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { DataTable PresetsActionMessages = null; dbClient.SetQuery("SELECT * FROM `moderation_preset_action_messages`;"); PresetsActionMessages = dbClient.getTable(); if (PresetsActionMessages != null) { foreach (DataRow Row in PresetsActionMessages.Rows) { int ParentId = Convert.ToInt32(Row["parent_id"]); if (!this._userActionPresetMessages.ContainsKey(ParentId)) { this._userActionPresetMessages.Add(ParentId, new List<ModerationPresetActionMessages>()); } this._userActionPresetMessages[ParentId].Add(new ModerationPresetActionMessages(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["parent_id"]), Convert.ToString(Row["caption"]), Convert.ToString(Row["message_text"]), Convert.ToInt32(Row["mute_hours"]), Convert.ToInt32(Row["ban_hours"]), Convert.ToInt32(Row["ip_ban_hours"]), Convert.ToInt32(Row["trade_lock_days"]), Convert.ToString(Row["notice"]))); } } } using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { DataTable GetBans = null; dbClient.SetQuery("SELECT `bantype`,`value`,`reason`,`expire` FROM `bans` WHERE `bantype` = 'machine' OR `bantype` = 'user'"); GetBans = dbClient.getTable(); if (GetBans != null) { foreach (DataRow dRow in GetBans.Rows) { string value = Convert.ToString(dRow["value"]); string reason = Convert.ToString(dRow["reason"]); double expires = (double)dRow["expire"]; string type = Convert.ToString(dRow["bantype"]); ModerationBan Ban = new ModerationBan(BanTypeUtility.GetModerationBanType(type), value, reason, expires); if (Ban != null) { if (expires > CloudServer.GetUnixTimestamp()) { if (!this._bans.ContainsKey(value)) this._bans.Add(value, Ban); } else { dbClient.SetQuery("DELETE FROM `bans` WHERE `bantype` = '" + BanTypeUtility.FromModerationBanType(Ban.Type) + "' AND `value` = @Key LIMIT 1"); dbClient.AddParameter("Key", value); dbClient.RunQuery(); } } } } } log.Info("» Cargado(s): " + (this._userPresets.Count + this._roomPresets.Count) + " moderation presets."); log.Info("» Cargado(s): " + this._userActionPresetCategories.Count + " categorías de moderación."); log.Info("» Cargado(s): " + this._userActionPresetMessages.Count + " Msj. de preajuste de acción de moderación."); log.Info("» En caché hay: " + this._bans.Count + " usuarios y maquinas de baneo."); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) { return; } if (!CloudServer.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room Room)) { return; } if (!Room.CheckRights(Session, true)) { return; } if (CloudServer.GetGame().GetSettingsManager().TryGetValue("room.item.exchangeables.enabled") != "1") { Session.SendNotification("Desculpe, mas o catálogo foi desativado!"); return; } Item Exchange = Room.GetRoomItemHandler().GetItem(Packet.PopInt()); if (Exchange == null) { return; } if (!Exchange.GetBaseItem().ItemName.StartsWith("CF_") && !Exchange.GetBaseItem().ItemName.StartsWith("CFC_") && !Exchange.GetBaseItem().ItemName.StartsWith("DF_") && !Exchange.GetBaseItem().ItemName.StartsWith("DFD_")) { return; } string[] Split = Exchange.GetBaseItem().ItemName.Split('_'); int Valuee = int.Parse(Split[1]); if (Valuee > 0) { if (Exchange.GetBaseItem().ItemName.StartsWith("CF_") || Exchange.GetBaseItem().ItemName.StartsWith("CFC_")) { Session.GetHabbo().Credits += Valuee; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); } else if (Exchange.GetBaseItem().ItemName.StartsWith("DF_") || Exchange.GetBaseItem().ItemName.StartsWith("DFD_")) { Session.GetHabbo().Diamonds += Valuee; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, Valuee, 5)); } } if (Exchange.Data.InteractionType != InteractionType.EXCHANGE) { return; } int Value = Exchange.Data.BehaviourData; if (Value > 0) { Session.GetHabbo().Credits += Value; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); } using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @exchangeId LIMIT 1"); dbClient.AddParameter("exchangeId", Exchange.Id); dbClient.RunQuery(); } Session.SendMessage(new FurniListUpdateComposer()); Room.GetRoomItemHandler().RemoveFurniture(null, Exchange.Id, false); Session.GetHabbo().GetInventoryComponent().RemoveItem(Exchange.Id); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { int pId = Packet.PopInt(); bool isConfirmed = Packet.PopBoolean(); Room Room = Session.GetHabbo().CurrentRoom; if (Room == null) { return; } Item Item = Room.GetRoomItemHandler().GetItem(pId); if (Item == null || Item.GetBaseItem() == null || Item.GetBaseItem().InteractionType != InteractionType.LOVELOCK) { return; } int UserOneId = Item.InteractingUser; int UserTwoId = Item.InteractingUser2; RoomUser UserOne = Room.GetRoomUserManager().GetRoomUserByHabbo(UserOneId); RoomUser UserTwo = Room.GetRoomUserManager().GetRoomUserByHabbo(UserTwoId); if (UserOne == null && UserTwo == null) { Item.InteractingUser = 0; Item.InteractingUser2 = 0; Session.SendNotification("Seu parceiro deixou o quarto ou cancelou."); return; } else if (UserOne.GetClient() == null || UserTwo.GetClient() == null) { Item.InteractingUser = 0; Item.InteractingUser2 = 0; Session.SendNotification("Seu parceiro deixou o quarto ou cancelou."); return; } else if (UserOne == null) { UserTwo.CanWalk = true; UserTwo.GetClient().SendNotification("Seu parceiro deixou o quarto ou cancelou."); UserTwo.LLPartner = 0; Item.InteractingUser = 0; Item.InteractingUser2 = 0; return; } else if (UserTwo == null) { UserOne.CanWalk = true; UserOne.GetClient().SendNotification("Seu parceiro deixou o quarto ou cancelou."); UserOne.LLPartner = 0; Item.InteractingUser = 0; Item.InteractingUser2 = 0; return; } else if (Item.ExtraData.Contains(Convert.ToChar(5).ToString())) { UserTwo.CanWalk = true; UserTwo.GetClient().SendNotification("Parece que este mob já foi usado."); UserTwo.LLPartner = 0; UserOne.CanWalk = true; UserOne.GetClient().SendNotification("Parece que este mob já foi usado."); UserOne.LLPartner = 0; Item.InteractingUser = 0; Item.InteractingUser2 = 0; return; } else if (!isConfirmed) { Item.InteractingUser = 0; Item.InteractingUser2 = 0; UserOne.LLPartner = 0; UserTwo.LLPartner = 0; UserOne.CanWalk = true; UserTwo.CanWalk = true; return; } else { if (UserOneId == Session.GetHabbo().Id) { Session.SendMessage(new LoveLockDialogueSetLockedMessageComposer(pId)); UserOne.LLPartner = UserTwoId; } else if (UserTwoId == Session.GetHabbo().Id) { Session.SendMessage(new LoveLockDialogueSetLockedMessageComposer(pId)); UserTwo.LLPartner = UserOneId; } if (UserOne.LLPartner == 0 || UserTwo.LLPartner == 0) { return; } else { Item.ExtraData = "1" + (char)5 + UserOne.GetUsername() + (char)5 + UserTwo.GetUsername() + (char)5 + UserOne.GetClient().GetHabbo().Look + (char)5 + UserTwo.GetClient().GetHabbo().Look + (char)5 + DateTime.Now.ToString("dd/MM/yyyy"); Item.InteractingUser = 0; Item.InteractingUser2 = 0; UserOne.LLPartner = 0; UserTwo.LLPartner = 0; Item.UpdateState(true, true); using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `items` SET `extra_data` = @extraData WHERE `id` = @ID LIMIT 1"); dbClient.AddParameter("extraData", Item.ExtraData); dbClient.AddParameter("ID", Item.Id); dbClient.RunQuery(); } UserOne.GetClient().SendMessage(new LoveLockDialogueCloseMessageComposer(pId)); UserTwo.GetClient().SendMessage(new LoveLockDialogueCloseMessageComposer(pId)); UserOne.CanWalk = true; UserTwo.CanWalk = true; UserOne = null; UserTwo = null; } } }
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { if (Params.Length == 1) { Session.SendWhisper("Por favor, introduzca un nombre de usuario y una longitud válida en días (minuto 1 día, máximo 365 días)."); return; } Habbo Habbo = CloudServer.GetHabboByUsername(Params[1]); if (Habbo == null) { Session.SendWhisper("Se produjo un error mientras que la búsqueda de usuario en la base de datos."); return; } if (Convert.ToDouble(Params[2]) == 0) { using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE `user_info` SET `trading_locked` = '0' WHERE `user_id` = '" + Habbo.Id + "' LIMIT 1"); } if (Habbo.GetClient() != null) { Habbo.TradingLockExpiry = 0; Habbo.GetClient().SendNotification("Su prohibición comercial excepcional se ha eliminado."); } Session.SendWhisper("Usted ha eliminado con éxito el baneo de tradeo a: " + Habbo.Username + "."); return; } double Days; if (double.TryParse(Params[2], out Days)) { if (Days < 1) { Days = 1; } if (Days > 365) { Days = 365; } double Length = (CloudServer.GetUnixTimestamp() + (Days * 86400)); using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `user_info` SET `trading_locked` = '" + Length + "', `trading_locks_count` = `trading_locks_count` + '1' WHERE `user_id` = '" + Habbo.Id + "' LIMIT 1"); } if (Habbo.GetClient() != null) { Habbo.TradingLockExpiry = Length; Habbo.GetClient().SendNotification("Se le ha prohibido el tradei por: " + Days + " día(s)!"); } Session.SendWhisper("Usted con éxito ha prohibido el tradeo de " + Habbo.Username + " por " + Days + " día(s)."); } else { Session.SendWhisper("Por favor, introduzca un número entero válido."); } }
public void Parse(GameClient Session, ClientPacket Packet) { if (Session.GetHabbo().TimeMuted > 0) { Session.SendNotification("Bem, agora você está mudo: Você não pode mudar a sua missão."); return; } if ((DateTime.Now - Session.GetHabbo().LastMottoUpdateTime).TotalSeconds <= 2.0) { Session.GetHabbo().MottoUpdateWarnings += 1; if (Session.GetHabbo().MottoUpdateWarnings >= 25) { Session.GetHabbo().SessionMottoBlocked = true; } return; } if (Session.GetHabbo().SessionMottoBlocked) { return; } Session.GetHabbo().LastMottoUpdateTime = DateTime.Now; string newMotto = StringCharFilter.Escape(Packet.PopString().Trim()); if (newMotto.Length > 38) { newMotto = newMotto.Substring(0, 38); } if (newMotto == Session.GetHabbo().Motto) { return; } string word; if (!Session.GetHabbo().GetPermissions().HasRight("word_filter_override")) { newMotto = CloudServer.GetGame().GetChatManager().GetFilter().IsUnnaceptableWord(newMotto, out word) ? "Spam" : newMotto; } Session.GetHabbo().Motto = newMotto; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `users` SET `motto` = @motto WHERE `id` = @userId LIMIT 1"); dbClient.AddParameter("userId", Session.GetHabbo().Id); dbClient.AddParameter("motto", newMotto); dbClient.RunQuery(); } CloudServer.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.PROFILE_CHANGE_MOTTO); CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_Motto", 1); if (Session.GetHabbo().InRoom) { Room Room = Session.GetHabbo().CurrentRoom; if (Room == null) { return; } RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id); if (User == null || User.GetClient() == null) { return; } Room.SendMessage(new UserChangeComposer(User, false)); } }
public void Parse(GameClient Session, ClientPacket Packet) { string VoucherCode = Packet.PopString().Replace("\r", ""); Voucher Voucher = null; if (!CloudServer.GetGame().GetCatalog().GetVoucherManager().TryGetVoucher(VoucherCode, out Voucher)) { Session.SendMessage(new VoucherRedeemErrorComposer(0)); return; } if (Voucher.CurrentUses >= Voucher.MaxUses) { Session.SendNotification("Você usou esse código o máximo de vezes permitidas!"); return; } DataRow GetRow = null; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `user_vouchers` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `voucher` = @Voucher LIMIT 1"); dbClient.AddParameter("Voucher", VoucherCode); GetRow = dbClient.getRow(); } if (GetRow != null) { Session.SendNotification("Ops! Você já está usando esse código!"); return; } else { using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("INSERT INTO `user_vouchers` (`user_id`,`voucher`) VALUES ('" + Session.GetHabbo().Id + "', @Voucher)"); dbClient.AddParameter("Voucher", VoucherCode); dbClient.RunQuery(); } } Voucher.UpdateUses(); if (Voucher.Type == VoucherType.CREDIT) { Session.GetHabbo().Credits += Voucher.Value; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " créditos. Use com sabedoria " + Session.GetHabbo().Username + ".", "")); } else if (Voucher.Type == VoucherType.DUCKET) { Session.GetHabbo().Duckets += Voucher.Value; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Voucher.Value)); Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " duckets. Use com sabedoria " + Session.GetHabbo().Username + ".", "")); } else if (Voucher.Type == VoucherType.DIAMOND) { Session.GetHabbo().Diamonds += Voucher.Value; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, Voucher.Value, 5)); Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " diamantes. Use com sabedoria " + Session.GetHabbo().Username + ".", "")); } else if (Voucher.Type == VoucherType.GOTW) { Session.GetHabbo().GOTWPoints += Voucher.Value; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, Voucher.Value, 103)); Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " " + ExtraSettings.PTOS_COINS + ". Use com sabedoria " + Session.GetHabbo().Username + ".", "")); } else if (Voucher.Type == VoucherType.ITEM) { ItemData Item = null; if (!CloudServer.GetGame().GetItemManager().GetItem((Voucher.Value), out Item)) { // No existe este ItemId. return; } Item GiveItem = ItemFactory.CreateSingleItemNullable(Item, Session.GetHabbo(), "", ""); if (GiveItem != null) { Session.GetHabbo().GetInventoryComponent().TryAddItem(GiveItem); Session.SendMessage(new FurniListNotificationComposer(GiveItem.Id, 1)); Session.SendMessage(new FurniListUpdateComposer()); Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acabou de receber o objeto raro, corre " + Session.GetHabbo().Username + ", confira seu invetário algo novo está ai!", "")); } Session.GetHabbo().GetInventoryComponent().UpdateItems(false); } Session.SendMessage(new VoucherRedeemOkComposer()); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { int craftingTable = Packet.PopInt(); //int itemCount = Packet.PopInt(); //int[] myItems = new int[itemCount]; //for (int i = 0; i < itemCount; itemCount++) //{ // int ItemID = Packet.PopInt(); // Item InventoryItem = Session.GetHabbo().GetInventoryComponent().GetItem(ItemID); // if (InventoryItem == null) // continue; // myItems[i] = InventoryItem.BaseItem; //} List <Item> items = new List <Item>(); var count = Packet.PopInt(); for (var i = 1; i <= count; i++) { var id = Packet.PopInt(); var item = Session.GetHabbo().GetInventoryComponent().GetItem(id); if (item == null || items.Contains(item)) { return; } items.Add(item); } CraftingRecipe recipe = null; foreach (var Receta in CloudServer.GetGame().GetCraftingManager().CraftingRecipes) { bool found = false; foreach (var item in Receta.Value.ItemsNeeded) { if (item.Value != items.Count(item2 => item2.GetBaseItem().ItemName == item.Key)) { found = false; break; } found = true; } if (found == false) { continue; } recipe = Receta.Value; break; } if (recipe == null) { return; } ItemData resultItem = CloudServer.GetGame().GetItemManager().GetItemByName(recipe.Result); if (resultItem == null) { return; } bool success = true; foreach (var need in recipe.ItemsNeeded) { for (var i = 1; i <= need.Value; i++) { ItemData item = CloudServer.GetGame().GetItemManager().GetItemByName(need.Key); if (item == null) { success = false; continue; } var inv = Session.GetHabbo().GetInventoryComponent().GetFirstItemByBaseId(item.Id); if (inv == null) { success = false; continue; } using (var dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + inv.Id + "' AND `user_id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); Session.GetHabbo().GetInventoryComponent().RemoveItem(inv.Id); Console.WriteLine(inv.Id); } } Session.GetHabbo().GetInventoryComponent().UpdateItems(true); if (success) { Session.GetHabbo().GetInventoryComponent().AddNewItem(0, resultItem.Id, "", 0, true, false, 0, 0); Session.SendMessage(new FurniListUpdateComposer()); Session.GetHabbo().GetInventoryComponent().UpdateItems(true); Session.SendMessage(new CraftableProductsComposer()); //int xd = recipe.type; //Console.WriteLine(recipe.type); switch (recipe.Type) { case 1: CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_CrystalCracker", 1); break; case 2: CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_PetLover", 1); break; case 3: CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_PetLover", 1); break; } } Session.SendMessage(new CraftingResultComposer(recipe, success)); }