//internal void LoadRoles(DatabaseClient dbClient) //{ // ClearRoles(); // DataTable Data = dbClient.getTable("SELECT * FROM ranks ORDER BY id ASC;"); // if (Data != null) // { // foreach (DataRow Row in Data.Rows) // { // Roles.Add((uint)Row["id"], new Role((uint)Row["id"], (string)Row["name"])); // } // } //} internal void LoadRights(IQueryAdapter dbClient) { ClearRights(); dbClient.setQuery("SELECT fuse, rank FROM fuserights;"); DataTable Data = dbClient.getTable(); dbClient.setQuery("SELECT fuse, sub FROM fuserights_subs;"); DataTable SubData = dbClient.getTable(); if (Data != null) { foreach (DataRow Row in Data.Rows) { Rights.Add((string)Row["fuse"], Convert.ToUInt32(Row["rank"])); } } if (SubData != null) { foreach (DataRow Row in SubData.Rows) { SubRights.Add((string)Row["fuse"], (string)Row["sub"]); } } }
internal void Init(IQueryAdapter DBClient) { this.Polls.Clear(); DBClient.setQuery("SELECT * FROM polls WHERE enabled = '1'"); DataTable table = DBClient.getTable(); if (table != null) { foreach (DataRow dataRow in table.Rows) { uint num = uint.Parse(dataRow["id"].ToString()); DBClient.setQuery("SELECT * FROM poll_questions WHERE poll_id = " + num); DataTable table2 = DBClient.getTable(); List<PollQuestion> list = new List<PollQuestion>(); foreach (DataRow dataRow2 in table2.Rows) { list.Add(new PollQuestion(uint.Parse(dataRow2["id"].ToString()), (string)dataRow2["question"], int.Parse(dataRow2["answertype"].ToString()), dataRow2["answers"].ToString().Split(new char[] { '|' }), (string)dataRow2["correct_answer"])); } Poll value = new Poll(num, uint.Parse(dataRow["room_id"].ToString()), (string)dataRow["caption"], (string)dataRow["invitation"], (string)dataRow["greetings"], (string)dataRow["prize"], int.Parse(dataRow["type"].ToString()), list); this.Polls.Add(num, value); } } }
public void Initialize(IQueryAdapter dbClient) { dbClient.setQuery("SELECT id,caption,min_rank FROM navigator_flatcats WHERE enabled = 2"); DataTable dPrivCats = dbClient.getTable(); dbClient.setQuery("SELECT * FROM navigator_publics ORDER BY ordernum ASC"); DataTable dPubItems = dbClient.getTable(); if (dPrivCats != null) { PrivateCategories.Clear(); foreach (DataRow Row in dPrivCats.Rows) { PrivateCategories.Add((int)Row["id"], new FlatCat((int)Row["id"], (string)Row["caption"], (int)Row["min_rank"])); } } if (dPubItems != null) { PublicItems.Clear(); foreach (DataRow Row in dPubItems.Rows) { PublicItems.Add((int)Row["id"], new PublicItem((int)Row["id"], int.Parse(Row["bannertype"].ToString()), (string)Row["caption"], (string)Row["description"], (string)Row["image"], ((Row["image_type"].ToString().ToLower() == "internal") ? PublicImageType.INTERNAL : PublicImageType.EXTERNAL), Convert.ToUInt32(Row["room_id"]), (int)Row["category_id"], (int)Row["category_parent_id"], SilverwaveEnvironment.EnumToBool(Row["recommended"].ToString()), (int)Row["typeofdata"], (string)Row["tag"])); } } }
internal static WiredLoaderObject LoadItem(RoomItem item, Room room, IQueryAdapter dbClient) { InteractionType type = item.GetBaseItem().InteractionType; List<RoomItem> items = null; if (NeedsFurnitures(type)) { dbClient.setQuery("SELECT trigger_item FROM wired_to_item WHERE wired_id = " + item.Id); DataTable dTable = dbClient.getTable(); RoomItem targetItem; items = new List<RoomItem>(5); foreach (DataRow dRows in dTable.Rows) { targetItem = room.GetRoomItemHandler().GetItem(Convert.ToUInt32(dRows[0])); if (targetItem == null || items.Contains(targetItem)) { continue; } items.Add(targetItem); } } string[] settings = null; if(HasSettings(type)) { settings = new string[4]; dbClient.setQuery("SELECT data_one, data_two,data_three, data_four FROM wired_data WHERE wired_id = " + item.Id); DataRow dRow = dbClient.getRow(); if (dRow != null) { for (int i = 0; i < 4; i++) { settings[i] = dRow[i].ToString(); } } else { settings = new string[] { "", "", "", "" }; } } Dictionary<uint, OriginalItemLocation> originalPositionList = null; if (HasOriginalItemLocations(type)) { originalPositionList = new Dictionary<uint, OriginalItemLocation>(5); dbClient.setQuery("SELECT item_id, original_x, original_y, rotation, height, extradata FROM wired_original_item_locations WHERE wired_id = " + item.Id); DataTable dTable = dbClient.getTable(); foreach (DataRow dRows in dTable.Rows) { originalPositionList.Add(uint.Parse(dRows[0].ToString()), new OriginalItemLocation(uint.Parse(dRows[0].ToString()), int.Parse(dRows[1].ToString()), int.Parse(dRows[2].ToString()), (double)Convert.ToDecimal(dRows[4]), int.Parse(dRows[3].ToString()), dRows[5].ToString())); } } return new WiredLoaderObject(items, originalPositionList, settings); }
internal void LoadBots(IQueryAdapter dbClient) { Bots = new List<RoomBot>(); dbClient.setQuery("SELECT id, room_id, ai_type, walk_mode, name, motto, look, x, y, z, rotation, min_x, min_y, max_x, max_y FROM bots;"); DataTable Data = dbClient.getTable(); dbClient.setQuery("SELECT id, bot_id, keywords, response_text, mode, serve_id FROM bots_responses;"); DataTable BotResponses = dbClient.getTable(); dbClient.setQuery("SELECT text, shout, bot_id FROM bots_speech;"); DataTable BotSpeech = dbClient.getTable(); List<BotResponse> Responses = new List<BotResponse>(); List<RandomSpeech> Speeches = new List<RandomSpeech>(); foreach (DataRow Row in BotResponses.Rows) { Responses.Add(new BotResponse(Convert.ToUInt32(Row["bot_id"]), (string)Row["keywords"], (string)Row["response_text"], Row["mode"].ToString(), (int)Row["serve_id"])); } foreach (DataRow Row in BotSpeech.Rows) { Speeches.Add(new RandomSpeech((string)Row["text"], ButterflyEnvironment.EnumToBool(Row["shout"].ToString()), Convert.ToUInt32(Row["bot_id"]))); } if (Data == null) { return; } foreach (DataRow Row in Data.Rows) { string BotAI = (string)Row["ai_type"]; AIType BotAIType; switch (BotAI) { case "generic": BotAIType = AIType.Generic; break; case "guide": BotAIType = AIType.Guide; break; case "pet": BotAIType = AIType.Pet; break; default: BotAIType = AIType.Generic; break; } Bots.Add(new RoomBot(Convert.ToUInt32(Row["id"]), Convert.ToUInt32(Row["room_id"]), BotAIType, (string)Row["walk_mode"], (String)Row["name"], (string)Row["motto"], (String)Row["look"], (int)Row["x"], (int)Row["y"], (int)Row["z"], (int)Row["rotation"], (int)Row["min_x"], (int)Row["min_y"], (int)Row["max_x"], (int)Row["max_y"], ref Speeches, ref Responses)); } }
internal static void Load(IQueryAdapter DBClient) { DBClient.setQuery("SELECT * FROM mercury_bannedhotels"); DataTable Table = DBClient.getTable(); bannedHotels = new string[Table.Rows.Count]; int i = 0; foreach (DataRow dataRow in DBClient.getTable().Rows) { AntiPublicistas.bannedHotels[i] = (dataRow[0].ToString()); i++; } }
internal void LoadRights(IQueryAdapter dbClient) { this.ClearRights(); dbClient.setQuery("SELECT command,rank FROM fuse_cmds;"); DataTable table = dbClient.getTable(); if (table != null) { foreach (DataRow dataRow in table.Rows) { if (!this.CMDRights.ContainsKey((string)dataRow[0])) { this.CMDRights.Add((string)dataRow[0], Convert.ToUInt32(dataRow[1])); } else { Logging.LogException(string.Format("Duplicate Fuse Command \"{0}\" found", dataRow[0])); } } } dbClient.setQuery("SELECT * FROM server_fuserights"); DataTable table2 = dbClient.getTable(); if (table2 != null) { foreach (DataRow dataRow2 in table2.Rows) { if ((int)dataRow2[3] == 0) { if (!this.Rights.ContainsKey((string)dataRow2[0])) { this.Rights.Add((string)dataRow2[0], Convert.ToUInt32(dataRow2[1])); } else { Logging.LogException(string.Format("Unknown Subscription Fuse \"{0}\" found", dataRow2[0])); } } else { if ((int)dataRow2[3] > 0) { this.SubRights.Add((string)dataRow2[0], (int)dataRow2[3]); } else { Logging.LogException(string.Format("Unknown fuse type \"{0}\" found", dataRow2[3])); } } } } }
public Group(DataRow Data, IQueryAdapter dbClient) { this.ID = Convert.ToInt32(Data["id"]); this.Name = Data["name"].ToString(); this.Description = Data["description"].ToString(); this.DateCreated = Data["date_created"].ToString(); this.OwnerID = Convert.ToInt32(Data["users_id"]); this.RoomID = Convert.ToInt32(Data["rooms_id"]); this.ColorID1 = Convert.ToInt32(Data["color1"]); this.ColorID2 = Convert.ToInt32(Data["color2"]); this.Type = Convert.ToInt32(Data["type"]); this.RightsType = Convert.ToInt32(Data["rights_type"]); // Parse badge data string[] rawData = Data["badge_data"].ToString().Split((char)1); List<Tuple<int, int, int>> badgeData = new List<Tuple<int,int,int>>(); for (int i = 0; i < rawData.Length; i++) { int value1 = int.Parse(rawData[i++]); int value2 = int.Parse(rawData[i++]); int value3 = int.Parse(rawData[i]); badgeData.Add(new Tuple<int, int, int>(value1, value2, value3)); } this.BadgeData = badgeData; this.Members = new List<int>(); // Load members dbClient.setQuery("SELECT * FROM group_memberships WHERE groups_id = @id"); dbClient.addParameter("id", ID); foreach (DataRow row in dbClient.getTable().Rows) { this.Members.Add((int)row["users_id"]); } }
private void ReloadQuests(IQueryAdapter dbClient) { quests.Clear(); dbClient.setQuery("SELECT * FROM quests"); DataTable dTable = dbClient.getTable(); uint id; string category; int num; int type; uint goalData; string name; int reward; string dataBit; foreach (DataRow dRow in dTable.Rows) { id = Convert.ToUInt32(dRow["id"]); category = (string)dRow["category"]; num = (int)dRow["series_number"]; type = (int)dRow["goal_type"]; goalData = Convert.ToUInt32(dRow["goal_data"]); name = (string)dRow["name"]; reward = (int)dRow["reward"]; dataBit = (string)dRow["data_bit"]; Quest quest = new Quest(id, category, num, (QuestType)type, goalData, name, reward, dataBit); quests.Add(id, quest); AddToCounter(category); } }
internal static void GetAchievementLevels(out Dictionary<string, Achievement> achievements, IQueryAdapter dbClient) { achievements = new Dictionary<string, Achievement>(); dbClient.setQuery("SELECT * FROM achievements"); DataTable table = dbClient.getTable(); foreach (DataRow dataRow in table.Rows) { uint id = Convert.ToUInt32(dataRow["id"]); string category = (string)dataRow["category"]; string text = (string)dataRow["group_name"]; int level = (int)dataRow["level"]; int rewardPixels = (int)dataRow["reward_pixels"]; int rewardPoints = (int)dataRow["reward_points"]; int requirement = (int)dataRow["progress_needed"]; AchievementLevel level2 = new AchievementLevel(level, rewardPixels, rewardPoints, requirement); if (!achievements.ContainsKey(text)) { Achievement achievement = new Achievement(id, text, category); achievement.AddLevel(level2); achievements.Add(text, achievement); } else { achievements[text].AddLevel(level2); } } }
internal void LoadBans(IQueryAdapter dbClient) { this.bannedUsernames.Clear(); this.bannedIPs.Clear(); this.bannedMachines.Clear(); dbClient.setQuery("SELECT bantype,value,reason,expire FROM bans"); DataTable table = dbClient.getTable(); double num = (double)CyberEnvironment.GetUnixTimestamp(); foreach (DataRow dataRow in table.Rows) { string text = (string)dataRow["value"]; string reasonMessage = (string)dataRow["reason"]; double num2 = (double)dataRow["expire"]; string a = (string)dataRow["bantype"]; ModerationBanType type; if (a == "user") { type = ModerationBanType.USERNAME; } else { if (a == "ip") { type = ModerationBanType.IP; } else { type = ModerationBanType.MACHINE; } } ModerationBan moderationBan = new ModerationBan(type, text, reasonMessage, num2); if (num2 > num) { if (moderationBan.Type == ModerationBanType.USERNAME) { if (!this.bannedUsernames.Contains(text)) { this.bannedUsernames.Add(text, moderationBan); } } else { if (moderationBan.Type == ModerationBanType.IP) { if (!this.bannedIPs.Contains(text)) { this.bannedIPs.Add(text, moderationBan); } } else { if (!this.bannedMachines.ContainsKey(text)) { this.bannedMachines.Add(text, moderationBan); } } } } } }
internal static void InitAchievementManager(IQueryAdapter dbClient) { dbClient.setQuery("SELECT achievements.*, achievement_categories.name " + "FROM achievements " + "JOIN achievement_categories " + "ON achievement_categories.id = achievements.category"); DataTable dTable = dbClient.getTable(); achievements = new Dictionary<uint, AchievementBase>(); uint achievementID; uint levels; uint badgelevel; string badge; int pixelBase; int pixelMMPORG; int pixelReward; string category; foreach (DataRow dRow in dTable.Rows) { achievementID = Convert.ToUInt32(dRow[0]); levels = Convert.ToUInt32(dRow[1]); badgelevel = Convert.ToUInt32(dRow[2]); badge = (string)dRow[3]; pixelBase = (int)dRow[4]; pixelMMPORG = (int)dRow[5]; pixelReward = (int)dRow[6]; category = (string)dRow[8]; AchievementBase achivement = new AchievementBase(achievementID, levels, badgelevel, badge, pixelBase, pixelMMPORG, pixelReward, category); achievements.Add(achievementID, achivement); } }
//internal void ClearCategories() //{ // Categories.Clear(); //} internal void LoadTopics(IQueryAdapter dbClient) { Topics.Clear(); DataTable TopicData = null; dbClient.setQuery("SELECT id, title, body, subject, known_issue FROM help_topics"); TopicData = dbClient.getTable(); if (TopicData == null) { return; } foreach (DataRow Row in TopicData.Rows) { HelpTopic NewTopic = new HelpTopic(Convert.ToUInt32(Row["id"]), (string)Row["title"], (string)Row["body"], Convert.ToUInt32(Row["subject"])); Topics.Add(Convert.ToUInt32(Row["id"]), NewTopic); int Importance = int.Parse(Row["known_issue"].ToString()); if (Importance == 1) { KnownIssues.Add(NewTopic); } else if (Importance == 2) { ImportantTopics.Add(NewTopic); } } }
internal void InitGroups(IQueryAdapter dbClient) { dbClient.setQuery("SELECT * FROM groups_elements"); DataTable table = dbClient.getTable(); string type; foreach (DataRow row in table.Rows) { type = (string)row["Type"]; GuildsPartsData data = new GuildsPartsData((int)row["Id"], (string)row["ExtraData1"], (string)row["ExtraData2"]); if (type == "Base") { baseBadges.Add(data); } else if (data.ExtraData1.StartsWith("symbol_")) { symbolBadges.Add(data); } else if (type == "Color1") { colorBadges1.Add(data); } else if (type == "Color2") { colorBadges2.Add(data); } else if (type == "Color3") { colorBadges3.Add(data); htmlBadges.Add(data.Id, data.ExtraData1); } } }
internal void Initialize(IQueryAdapter dbClient) { //dbClient.setQuery("SELECT id,caption FROM navigator_pubcats WHERE enabled = 2"); //wtf? //DataTable dPubCats = dbClient.getTable(); dbClient.setQuery("SELECT id,caption,min_rank FROM navigator_flatcats WHERE enabled = 2"); DataTable dPrivCats = dbClient.getTable(); dbClient.setQuery("SELECT * FROM navigator_publics ORDER BY ordernum ASC"); DataTable dPubItems = dbClient.getTable(); //if (dPubCats != null) //{ // foreach (DataRow Row in dPubCats.Rows) // { // PublicCategories.Add((int)Row["id"], (string)Row["caption"]); // } //} if (dPrivCats != null) { foreach (DataRow Row in dPrivCats.Rows) { PrivateCategories.Add((int)Row["id"], new FlatCat((int)Row["id"], (string)Row["caption"], (int)Row["min_rank"])); } } if (dPubItems != null) { foreach (DataRow Row in dPubItems.Rows) { PublicItems.Add((int)Row["id"], new PublicItem((int)Row["id"], int.Parse(Row["bannertype"].ToString()), (string)Row["caption"], (string)Row["image"], ((Row["image_type"].ToString().ToLower() == "internal") ? PublicImageType.INTERNAL : PublicImageType.EXTERNAL), Convert.ToUInt32(Row["room_id"]), (int)Row["category_parent_id"], ButterflyEnvironment.EnumToBool(Row["category"].ToString()) ,ButterflyEnvironment.EnumToBool(Row["recommended"].ToString()))); } } //if (dPubRecommended != null) //{ // foreach (DataRow Row in dPubRecommended.Rows) // { // PublicRecommended.Add((int)Row["id"], new PublicItem((int)Row["id"], int.Parse(Row["bannertype"].ToString()), (string)Row["caption"], // (string)Row["image"], ((Row["image_type"].ToString().ToLower() == "internal") ? PublicImageType.INTERNAL : PublicImageType.EXTERNAL), // (uint)Row["room_id"], (int)Row["category_parent_id"], false)); // } //} }
internal void LoadItems(IQueryAdapter dbClient) { this.Items = new Dictionary<uint, Item>(); dbClient.setQuery("SELECT * FROM furniture"); DataTable table = dbClient.getTable(); if (table != null) { string[] array = null; foreach (DataRow dataRow in table.Rows) { try { uint num = Convert.ToUInt32(dataRow["id"]); int sprite = (int)dataRow["sprite_id"]; int flatId = (int)dataRow["flat_id"]; string publicName = (string)dataRow["public_name"]; string name = (string)dataRow["item_name"]; string type = dataRow["type"].ToString(); int width = (int)dataRow["width"]; int length = (int)dataRow["length"]; double height; if (dataRow["stack_height"].ToString().Contains(";")) { array = dataRow["stack_height"].ToString().Split(new char[] { ';' }); height = Convert.ToDouble(array[0]); } else { height = Convert.ToDouble(dataRow["stack_height"]); } bool stackable = Convert.ToInt32(dataRow["can_stack"]) == 1; bool walkable = Convert.ToInt32(dataRow["is_walkable"]) == 1; bool isSeat = Convert.ToInt32(dataRow["can_sit"]) == 1; bool allowRecycle = Convert.ToInt32(dataRow["allow_recycle"]) == 1; bool allowTrade = Convert.ToInt32(dataRow["allow_trade"]) == 1; bool allowMarketplaceSell = Convert.ToInt32(dataRow["allow_marketplace_sell"]) == 1; bool allowGift = Convert.ToInt32(dataRow["allow_gift"]) == 1; bool allowInventoryStack = Convert.ToInt32(dataRow["allow_inventory_stack"]) == 1; InteractionType typeFromString = InterractionTypes.GetTypeFromString((string)dataRow["interaction_type"]); int modes = (int)dataRow["interaction_modes_count"]; string vendingIds = (string)dataRow["vending_ids"]; bool sub = MercuryEnvironment.EnumToBool(dataRow["subscriber"].ToString()); int effect = (int)dataRow["effectid"]; bool stackMultiple = MercuryEnvironment.EnumToBool(dataRow["stack_multiplier"].ToString()); Item value = new Item(num, sprite, publicName, name, type, width, length, height, stackable, walkable, isSeat, allowRecycle, allowTrade, allowMarketplaceSell, allowGift, allowInventoryStack, typeFromString, modes, vendingIds, sub, effect, stackMultiple, array, flatId); this.Items.Add(num, value); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Console.ReadKey(); Logging.WriteLine("Could not load item #" + Convert.ToUInt32(dataRow[0]) + ", please verify the data is okay.", ConsoleColor.Gray); } } } }
internal void Initialize(IQueryAdapter dbClient) { dbClient.setQuery("SELECT * FROM achievements_talenttrack ORDER BY `order_num` ASC"); DataTable table = dbClient.getTable(); foreach (DataRow dataRow in table.Rows) { Talent talent = new Talent((int)dataRow["id"], (string)dataRow["type"], (int)dataRow["parent_category"], (int)dataRow["level"], (string)dataRow["achievement_group"], (int)dataRow["achievement_level"], (string)dataRow["prize"], (uint)dataRow["prize_baseitem"]); this.Talents.Add(talent.Id, talent); } }
internal static void Init(IQueryAdapter dbClient) { DataTable Pets; dbClient.setQuery("SELECT * FROM bots_pet_responses"); Pets = dbClient.getTable(); values = new Dictionary<string, string[]>(); foreach (DataRow Row in Pets.Rows) values.Add(Row[0].ToString(), Row[1].ToString().Split(';')); }
internal void Initialize(IQueryAdapter dbClient) { dbClient.setQuery("SELECT * FROM pinatas_items"); this.Pinatas = new Dictionary<uint, PinataItem>(); this.Table = dbClient.getTable(); foreach (DataRow dataRow in this.Table.Rows) { PinataItem value = new PinataItem(dataRow); this.Pinatas.Add(uint.Parse(dataRow["item_baseid"].ToString()), value); } }
internal ConfigData(IQueryAdapter dbClient) { this.DBData = new Dictionary<string, string>(); this.DBData.Clear(); dbClient.setQuery("SELECT * FROM server_settings"); DataTable table = dbClient.getTable(); foreach (DataRow dataRow in table.Rows) { this.DBData.Add(dataRow[0].ToString(), dataRow[1].ToString()); } }
internal void Initialize(IQueryAdapter dbClient) { dbClient.setQuery("SELECT id,caption,min_rank FROM navigator_flatcats WHERE enabled = '1'"); DataTable dPrivCats = dbClient.getTable(); foreach (DataRow Row in dPrivCats.Rows) { PrivateCategories.Add((int)Row["id"], new FlatCat((int)Row["id"], (string)Row["caption"], (int)Row["min_rank"])); } InitializePublicRoomListing(dbClient); }
public GiftWrappers(IQueryAdapter dbClient) { DataTable wrappers = null; dbClient.setQuery("SELECT * FROM gift_wrappers"); wrappers = dbClient.getTable(); if (wrappers.Rows.Count <= 0) Logging.LogCriticalException("Failed to load the Gift Wrappers"); else foreach (DataRow dr in wrappers.Rows) GiftWrappersList.Add((uint)dr["baseid"]); }
public void LoadFromDatabase(IQueryAdapter dbClient, Room insideRoom) { dbClient.setQuery("SELECT triggers_item FROM trigger_in_place WHERE original_trigger = " + this.item.Id); DataTable dTable = dbClient.getTable(); RoomItem targetItem; foreach (DataRow dRows in dTable.Rows) { targetItem = insideRoom.GetRoomItemHandler().GetItem(Convert.ToUInt32(dRows[0])); if (targetItem == null || this.items.Contains(targetItem)) continue; this.items.Add(targetItem); } }
internal static void LoadSwearWords(IQueryAdapter dbClient) { DataTable dTable; dbClient.setQuery("SELECT word FROM room_swearword_filter"); dTable = dbClient.getTable(); string swearWord; foreach (DataRow dRow in dTable.Rows) { swearWord = (string)dRow[0]; swearwords.Add(swearWord); } }
internal static void Init(IQueryAdapter dbClient) { dbClient.setQuery("SELECT * FROM bots_pet_responses"); DataTable table = dbClient.getTable(); PetLocale.values = new Dictionary<string, string[]>(); foreach (DataRow dataRow in table.Rows) { PetLocale.values.Add(dataRow[0].ToString(), dataRow[1].ToString().Split(new char[] { ';' })); } }
internal ConfigData(IQueryAdapter dbClient) { DBData = new Dictionary<string, string>(); DBData.Clear(); dbClient.setQuery("SELECT * FROM server_settings"); DataTable ConfigData = dbClient.getTable(); foreach (DataRow Data in ConfigData.Rows) { DBData.Add(Data[0].ToString(), Data[1].ToString()); } return; }
public void Initialize(IQueryAdapter dbClient) { Ranking = new Dictionary<uint, RankingEnum>(); dbClient.setQuery("SELECT id,username,look,diamonds FROM users WHERE rank < 3 ORDER BY diamonds DESC LIMIT 15;"); DataTable rankDataTable = dbClient.getTable(); if (rankDataTable != null) { foreach (DataRow Row in rankDataTable.Rows) Ranking.Add((uint)Row["id"], new RankingEnum((uint)Row["id"], (string)Row["username"], (string)Row["look"], (int)Row["diamonds"])); } }
internal void LoadBans(IQueryAdapter dbClient) { bannedUsernames.Clear(); bannedIPs.Clear(); dbClient.setQuery("SELECT bantype,value,reason,expire FROM bans"); DataTable BanData = dbClient.getTable(); double timestmp = ButterflyEnvironment.GetUnixTimestamp(); string value; string reason; string type; double expires; foreach (DataRow dRow in BanData.Rows) { value = (string)dRow["value"]; reason = (string)dRow["reason"]; expires = (double)dRow["expire"]; type = (string)dRow["bantype"]; ModerationBanType banType; if (type == "user") banType = ModerationBanType.USERNAME; else banType = ModerationBanType.IP; ModerationBan ban = new ModerationBan(banType, value, reason, expires); if (expires > timestmp) { if (ban.Type == ModerationBanType.USERNAME) { if (!bannedUsernames.ContainsKey(value)) { bannedUsernames.Add(value, ban); } } else if (!bannedIPs.ContainsKey(value)) { bannedIPs.Add(value, ban); } } } }
internal void LoadBots(IQueryAdapter dbClient) { Bots = new List<RoomBot>(); dbClient.setQuery("SELECT * FROM bots"); DataTable Data = dbClient.getTable(); dbClient.setQuery("SELECT id, bot_id, keywords, response_text, mode, serve_id FROM bots_responses"); DataTable BotResponses = dbClient.getTable(); dbClient.setQuery("SELECT text, shout, bot_id FROM bots_speech"); DataTable BotSpeech = dbClient.getTable(); Responses = new List<BotResponse>(); Speeches = new List<RandomSpeech>(); foreach (DataRow Row in BotResponses.Rows) { Responses.Add(new BotResponse(Convert.ToUInt32(Row["bot_id"]), (string)Row["keywords"], (string)Row["response_text"], Row["mode"].ToString(), (int)Row["serve_id"])); } foreach (DataRow Row in BotSpeech.Rows) { Speeches.Add(new RandomSpeech((string)Row["text"], ButterflyEnvironment.EnumToBool(Row["shout"].ToString()), Convert.ToUInt32(Row["bot_id"]))); } if (Data == null) { return; } foreach (DataRow Row in Data.Rows) { Bots.Add(FetchBot(Row)); } }
internal void InitializePublicRoomListing(IQueryAdapter dbClient) { Dictionary<int, PublicItem> items = new Dictionary<int, PublicItem>(); dbClient.setQuery("SELECT * FROM navigator_publics ORDER BY ordernum ASC"); DataTable dPubItems = dbClient.getTable(); foreach (DataRow Row in dPubItems.Rows) { items.Add((int)Row["id"], new PublicItem((int)Row["id"], int.Parse(Row["bannertype"].ToString()), (string)Row["caption"], (string)Row["description"], (string)Row["image"], ((Row["image_type"].ToString().ToLower() == "internal") ? PublicImageType.INTERNAL : PublicImageType.EXTERNAL), Convert.ToUInt32(Row["room_id"]), (int)Row["category_id"], (int)Row["category_parent_id"], ButterflyEnvironment.EnumToBool(Row["recommended"].ToString()), (int)Row["typeofdata"], (string)Row["tag"])); } this.PublicItems = items; }
public static void GetAchievementLevels(out Dictionary <string, Achievement> Achievements) { Achievements = new Dictionary <string, Achievement>(); using (IQueryAdapter DbClient = ProjectHub.GetDatabaseManager().GetQueryReactor()) { DbClient.SetQuery("SELECT `id`,`category`,`group_name`,`level`,`reward_pixels`,`reward_points`,`progress_needed`,`game_id` FROM `" + ProjectHub.DbPrefix + "achievements`"); DataTable DataTable = DbClient.getTable(); if (DataTable != null) { foreach (DataRow DataRow in DataTable.Rows) { int Id = Convert.ToInt32(DataRow["id"]); string Category = Convert.ToString(DataRow["category"]); string GroupName = Convert.ToString(DataRow["group_name"]); int Level = Convert.ToInt32(DataRow["level"]); int RewardPixels = Convert.ToInt32(DataRow["reward_pixels"]); int RewardPoints = Convert.ToInt32(DataRow["reward_points"]); int ProgressNeeded = Convert.ToInt32(DataRow["progress_needed"]); AchievementLevel AchievementLevel = new AchievementLevel(Level, RewardPixels, RewardPoints, ProgressNeeded); if (!Achievements.ContainsKey(GroupName)) { Achievement Achievement = new Achievement(Id, GroupName, Category, Convert.ToInt32(DataRow["game_id"])); Achievement.AddLevel(AchievementLevel); Achievements.Add(GroupName, Achievement); } else { Achievements[GroupName].AddLevel(AchievementLevel); } } } } }
internal static void Fix() { DataTable dTable = null; using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT * FROM items_extradata JOIN user_presents ON user_presents.item_id = items_extradata.item_id"); dTable = dbClient.getTable(); if (dTable != null) { foreach (DataRow dRow in dTable.Rows) { try { int itemId = Convert.ToInt32(dRow["item_id"]); string data = (string)dRow["data"]; uint userId = Convert.ToUInt32(data.Split(';')[0]); string message = data.Split(';')[1].Split((char)5)[0]; int lazo = int.Parse(data.Split(';')[1].Split((char)5)[1]); int color = int.Parse(data.Split(';')[1].Split((char)5)[2]); string newStr = userId + ";" + (lazo * 1000 + color) + ";" + message; dbClient.setQuery("UPDATE items_extradata SET data = @message WHERE item_id = " + itemId); dbClient.addParameter("message", newStr); dbClient.runQuery(); } catch { Console.WriteLine("Error!"); } } } } Console.WriteLine("Regalos actualizados."); }
public List <int> BannedUsers() { DataTable GetBans = null; List <int> Bans = new List <int>(); using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `user_id` FROM `room_bans` WHERE `room_id` = '" + this._instance.Id + "' AND `expire` > UNIX_TIMESTAMP();"); GetBans = dbClient.getTable(); if (GetBans != null) { foreach (DataRow Row in GetBans.Rows) { if (!Bans.Contains(Convert.ToInt32(Row["user_id"]))) { Bans.Add(Convert.ToInt32(Row["user_id"])); } } } } return(Bans); }
public static List <SearchResult> GetSearchResult(string query) { DataTable dTable; using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id`,`username`,`motto`,`look`,`last_online` FROM users WHERE username LIKE @query LIMIT 50"); dbClient.AddParameter("query", query + "%"); dTable = dbClient.getTable(); } List <SearchResult> results = new List <SearchResult>(); if (dTable != null) { foreach (DataRow dRow in dTable.Rows) { results.Add(new SearchResult(Convert.ToInt32(dRow[0]), Convert.ToString(dRow[1]), Convert.ToString(dRow[2]), Convert.ToString(dRow[3]), dRow[4].ToString())); } } return(results); }
public void Init() { if (this._quests.Count > 0) { _quests.Clear(); } using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id`,`type`,`level_num`,`goal_type`,`goal_data`,`action`,`pixel_reward`,`data_bit`,`reward_type`,`timestamp_unlock`,`timestamp_lock` FROM `quests`"); DataTable dTable = dbClient.getTable(); if (dTable != null) { foreach (DataRow dRow in dTable.Rows) { int id = Convert.ToInt32(dRow["id"]); string category = Convert.ToString(dRow["type"]); int num = Convert.ToInt32(dRow["level_num"]); int type = Convert.ToInt32(dRow["goal_type"]); int goalData = Convert.ToInt32(dRow["goal_data"]); string name = Convert.ToString(dRow["action"]); int reward = Convert.ToInt32(dRow["pixel_reward"]); string dataBit = Convert.ToString(dRow["data_bit"]); int rewardtype = Convert.ToInt32(dRow["reward_type"].ToString()); int time = Convert.ToInt32(dRow["timestamp_unlock"]); int locked = Convert.ToInt32(dRow["timestamp_lock"]); _quests.Add(id, new Quest(id, category, num, (QuestType)type, goalData, name, reward, dataBit, rewardtype, time, locked)); AddToCounter(category); } } } log.Info(">> Quest Manager -> READY!"); }
internal void LoadMusic() { DataTable dTable; using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT items_rooms_songs.songid,items.* FROM items_rooms_songs LEFT JOIN items ON items.item_id = items_rooms_songs.itemid WHERE items_rooms_songs.roomid = " + this.RoomId); dTable = dbClient.getTable(); } int songID; uint itemID; int baseID; foreach (DataRow dRow in dTable.Rows) { songID = (int)dRow[0]; itemID = Convert.ToUInt32(dRow[1]); baseID = Convert.ToInt32(dRow[2]); SongItem item = new SongItem(itemID, songID, baseID); GetRoomMusicController().AddDisk(item); } }
public void LoadPromotions() { if (this._promotionItems.Count > 0) { this._promotionItems.Clear(); } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `server_landing` ORDER BY `id` DESC"); DataTable GetData = dbClient.getTable(); if (GetData != null) { foreach (DataRow Row in GetData.Rows) { this._promotionItems.Add(Convert.ToInt32(Row[0]), new Promotion((int)Row[0], Row[1].ToString(), Row[2].ToString(), Row[3].ToString(), Convert.ToInt32(Row[4]), Row[5].ToString(), Row[6].ToString())); } } } //log.Info("Landing View Manager -> LOADED"); }
public List <Group> GetGroupsForUser(int UserId) { List <Group> Groups = new List <Group>(); using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT g.id FROM `group_memberships` AS m RIGHT JOIN `groups` AS g ON m.group_id = g.id WHERE m.user_id = @user"); dbClient.AddParameter("user", UserId); DataTable GetGroups = dbClient.getTable(); if (GetGroups != null) { foreach (DataRow Row in GetGroups.Rows) { Group Group = null; if (this.TryGetGroup(Convert.ToInt32(Row["id"]), out Group)) { Groups.Add(Group); } } } } return(Groups); }
public void Init() { if (this._items.Count > 0) { this._items.Clear(); } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id`,`item_name`,`public_name`,`type`,`width`,`length`,`stack_height`,`can_stack`,`can_sit`,`is_walkable`,`sprite_id`,`allow_recycle`,`allow_trade`,`allow_marketplace_sell`,`allow_gift`,`allow_inventory_stack`,`interaction_type`,`interaction_modes_count`,`vending_ids`,`height_adjustable`,`effect_id`,`wired_id`,`is_rare`,`clothing_id`, `extra_rot` FROM `furniture`"); DataTable ItemData = dbClient.getTable(); if (ItemData != null) { foreach (DataRow Row in ItemData.Rows) { try { int id = Convert.ToInt32(Row["id"]); int spriteID = Convert.ToInt32(Row["sprite_id"]); string itemName = Convert.ToString(Row["item_name"]); string PublicName = Convert.ToString(Row["public_name"]); string type = Row["type"].ToString(); int width = Convert.ToInt32(Row["width"]); int length = Convert.ToInt32(Row["length"]); double height = Convert.ToDouble(Row["stack_height"]); bool allowStack = PlusEnvironment.EnumToBool(Row["can_stack"].ToString()); bool allowWalk = PlusEnvironment.EnumToBool(Row["is_walkable"].ToString()); bool allowSit = PlusEnvironment.EnumToBool(Row["can_sit"].ToString()); bool allowRecycle = PlusEnvironment.EnumToBool(Row["allow_recycle"].ToString()); bool allowTrade = PlusEnvironment.EnumToBool(Row["allow_trade"].ToString()); bool allowMarketplace = Convert.ToInt32(Row["allow_marketplace_sell"]) == 1; bool allowGift = Convert.ToInt32(Row["allow_gift"]) == 1; bool allowInventoryStack = PlusEnvironment.EnumToBool(Row["allow_inventory_stack"].ToString()); InteractionType interactionType = InteractionTypes.GetTypeFromString(Convert.ToString(Row["interaction_type"])); int cycleCount = Convert.ToInt32(Row["interaction_modes_count"]); string vendingIDS = Convert.ToString(Row["vending_ids"]); List <double> heightAdjustable = Row["height_adjustable"].ToString() != String.Empty ? Row["height_adjustable"].ToString().Split(',').Select(x => Convert.ToDouble(x)).ToList() : new List <double>(); int EffectId = Convert.ToInt32(Row["effect_id"]); int WiredId = Convert.ToInt32(Row["wired_id"]); bool IsRare = PlusEnvironment.EnumToBool(Row["is_rare"].ToString()); int ClothingId = Convert.ToInt32(Row["clothing_id"]); bool ExtraRot = PlusEnvironment.EnumToBool(Row["extra_rot"].ToString()); if (!this._gifts.ContainsKey(spriteID)) { this._gifts.Add(spriteID, new ItemData(id, spriteID, itemName, PublicName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS, heightAdjustable, EffectId, WiredId, IsRare, ClothingId, ExtraRot)); } if (!this._items.ContainsKey(id)) { this._items.Add(id, new ItemData(id, spriteID, itemName, PublicName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS, heightAdjustable, EffectId, WiredId, IsRare, ClothingId, ExtraRot)); } } catch (Exception e) { Console.WriteLine(e.ToString()); Console.ReadKey(); Logging.WriteLine("Não foi possível carregar item #" + Convert.ToInt32(Row[0]) + ", verifiqu os dados."); } } } } //log.Info("Item Manager -> LOADED"); }
public ModeratorUserChatlogComposer(int UserId) : base(ServerPacketHeader.ModeratorUserChatlogMessageComposer) { base.WriteInteger(UserId); base.WriteString(RavenEnvironment.GetGame().GetClientManager().GetNameById(UserId)); using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT room_id,entry_timestamp,exit_timestamp FROM user_roomvisits WHERE `user_id` = " + UserId + " ORDER BY entry_timestamp DESC LIMIT 5"); DataTable Visits = dbClient.getTable(); if (Visits != null) { base.WriteInteger(Visits.Rows.Count); foreach (DataRow Visit in Visits.Rows) { string RoomName = "Unknown"; Room Room = RavenEnvironment.GetGame().GetRoomManager().LoadRoom(Convert.ToInt32(Visit["room_id"])); if (Room != null) { RoomName = Room.Name; } base.WriteByte(1); base.WriteShort(2);//Count base.WriteString("roomName"); base.WriteByte(2); base.WriteString(RoomName); // room name base.WriteString("roomId"); base.WriteByte(1); base.WriteInteger(Convert.ToInt32(Visit["room_id"])); DataTable Chatlogs = null; if ((Double)Visit["exit_timestamp"] <= 0) { Visit["exit_timestamp"] = RavenEnvironment.GetUnixTimestamp(); } dbClient.SetQuery("SELECT user_id,timestamp,message FROM `chatlogs` WHERE room_id = " + Convert.ToInt32(Visit["room_id"]) + " AND timestamp > " + (Double)Visit["entry_timestamp"] + " AND timestamp < " + (Double)Visit["exit_timestamp"] + " ORDER BY timestamp DESC LIMIT 150"); Chatlogs = dbClient.getTable(); if (Chatlogs != null) { base.WriteShort(Chatlogs.Rows.Count); foreach (DataRow Log in Chatlogs.Rows) { UserCache Habbo = RavenEnvironment.GetGame().GetCacheManager().GenerateUser(Convert.ToInt32(Log["user_id"])); if (Habbo == null) { continue; } DateTime dDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); dDateTime = dDateTime.AddSeconds(Convert.ToInt32(Log["timestamp"])).ToLocalTime(); base.WriteString(dDateTime.Hour + ":" + dDateTime.Minute); base.WriteInteger(Habbo.Id); base.WriteString(Habbo.Username); base.WriteString(string.IsNullOrWhiteSpace(Convert.ToString(Log["message"])) ? "*stemen*" : Convert.ToString(Log["message"])); base.WriteBoolean(false); } } else { base.WriteInteger(0); } } } else { base.WriteInteger(0); } } }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) { return; } Room Room; if (!BiosEmuThiago.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 = BiosEmuThiago.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 = BiosEmuThiago.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, BiosEmuThiago.EnumToBool(GetData["automatic_chat"].ToString()), Convert.ToInt32(GetData["speaking_interval"]), BiosEmuThiago.EnumToBool(GetData["mix_sentences"].ToString()), Convert.ToInt32(GetData["chat_bubble"])), null); using (IQueryAdapter dbClient = BiosEmuThiago.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 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 = RavenEnvironment.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 = RavenEnvironment.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 = RavenEnvironment.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 = RavenEnvironment.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 = RavenEnvironment.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 = RavenEnvironment.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 > RavenEnvironment.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("Loaded " + (this._userPresets.Count + this._roomPresets.Count) + " moderation presets."); * log.Info("Loaded " + this._userActionPresetCategories.Count + " moderation categories."); * log.Info("Loaded " + this._userActionPresetMessages.Count + " moderation action preset messages."); * log.Info("Cached " + this._bans.Count + " username and machine bans.");*/ log.Info(">> Moderation Manager -> READY!"); }
public void Init() { if (this._questions.Count > 0) { this._questions.Clear(); } int QuestionsLoaded = 0; DataTable GetQuestions = null; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `room_poll_questions`;"); GetQuestions = dbClient.getTable(); if (GetQuestions != null) { foreach (DataRow Row in GetQuestions.Rows) { int PollId = Convert.ToInt32(Row["poll_id"]); if (!this._questions.ContainsKey(PollId)) { this._questions[PollId] = new Dictionary <int, RoomPollQuestion>(); } RoomPollQuestion CatalogItem = new RoomPollQuestion(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["poll_id"]), Convert.ToString(Row["question"]), Convert.ToString(Row["question_type"]), Convert.ToInt32(Row["series_order"]), Convert.ToInt32(Row["minimum_selections"])); this._questions[CatalogItem.PollId].Add(CatalogItem.Id, CatalogItem); QuestionsLoaded++; } } } if (this._polls.Count > 0) { this._polls.Clear(); } DataTable GetPolls = null; int PollsLoaded = 0; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `room_polls` WHERE `enabled` = 'Y'"); GetPolls = dbClient.getTable(); if (GetPolls != null) { foreach (DataRow Row in GetPolls.Rows) { this._polls.Add(Convert.ToInt32(Row["id"]), new RoomPoll(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["room_id"]), Convert.ToString(Row["type"]), Convert.ToString(Row["headline"]), Convert.ToString(Row["summary"]), Convert.ToString(Row["completion_message"]), Convert.ToInt32(Row["credit_reward"]), Convert.ToInt32(Row["pixel_reward"]), Convert.ToString(Row["badge_reward"]), Convert.ToDouble(Row["expiry"]), this._questions.ContainsKey(Convert.ToInt32(Row["id"])) ? this._questions[Convert.ToInt32(Row["id"])] : new Dictionary <int, RoomPollQuestion>())); PollsLoaded++; } } log.Info("Loaded " + PollsLoaded + " room polls & " + QuestionsLoaded + " poll questions"); } }
public void Init(ItemDataManager ItemDataManager) { if (_pages.Count > 0) { _pages.Clear(); } if (_botPresets.Count > 0) { _botPresets.Clear(); } if (_items.Count > 0) { _items.Clear(); } if (_deals.Count > 0) { _deals.Clear(); } if (_predesignedItems.Count > 0) { _predesignedItems.Clear(); } if (_recyclerLevels.Count > 0) { _recyclerLevels.Clear(); } using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id`,`item_id`,`catalog_name`,`cost_credits`,`cost_pixels`,`cost_diamonds`,`cost_gotw`,`amount`,`page_id`,`limited_sells`,`limited_stack`,`offer_active`,`extradata`,`badge`,`offer_id`, `predesigned_id` FROM `catalog_items`"); DataTable CatalogueItems = dbClient.getTable(); if (CatalogueItems != null) { foreach (DataRow Row in CatalogueItems.Rows) { if (Convert.ToInt32(Row["amount"]) <= 0) { continue; } int ItemId = Convert.ToInt32(Row["id"]); int PageId = Convert.ToInt32(Row["page_id"]); int BaseId = Convert.ToInt32(Row["item_id"]); int OfferId = Convert.ToInt32(Row["offer_id"]); uint PredesignedId = Convert.ToUInt32(Row["predesigned_id"]); if (BaseId == 0 && PredesignedId > 0) { var roomPack = _predesignedManager.predesignedRoom[PredesignedId]; if (roomPack == null) { continue; } if (roomPack.CatalogItems.Contains(";")) { var cataItems = new Dictionary <int, int>(); var itemArray = roomPack.CatalogItems.Split(new char[] { ';' }); foreach (var item in itemArray) { var items = item.Split(','); ItemData PredesignedData = null; if (!ItemDataManager.GetItem(Convert.ToInt32(items[0]), out PredesignedData)) { log.Error("Ops, o id {" + ItemId + "}, do pack no catalogo esta com erro!"); continue; } cataItems.Add(Convert.ToInt32(items[0]), Convert.ToInt32(items[1])); } this._predesignedItems[PageId] = new PredesignedContent(ItemId, cataItems); } } ItemData Data = null; if (PredesignedId <= 0) { if (!ItemDataManager.GetItem(BaseId, out Data)) { log.Error("Ops, o id {" + ItemId + "}, do pack no catalogo esta com erro!"); continue; } } if (!this._items.ContainsKey(PageId)) { this._items[PageId] = new Dictionary <int, CatalogItem>(); } if (OfferId != -1 && !this._itemOffers.ContainsKey(OfferId)) { this._itemOffers.Add(OfferId, PageId); } this._items[PageId].Add(Convert.ToInt32(Row["id"]), new CatalogItem(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["item_id"]), Data, Convert.ToString(Row["catalog_name"]), Convert.ToInt32(Row["page_id"]), Convert.ToInt32(Row["cost_credits"]), Convert.ToInt32(Row["cost_pixels"]), Convert.ToInt32(Row["cost_diamonds"]), Convert.ToInt32(Row["cost_gotw"]), Convert.ToInt32(Row["amount"]), Convert.ToInt32(Row["limited_sells"]), Convert.ToInt32(Row["limited_stack"]), BiosEmuThiago.EnumToBool(Row["offer_active"].ToString()), Convert.ToString(Row["extradata"]), Convert.ToString(Row["badge"]), Convert.ToInt32(Row["offer_id"]), Convert.ToInt32(Row["predesigned_id"]))); } } dbClient.SetQuery("SELECT * FROM `catalog_deals`"); DataTable GetDeals = dbClient.getTable(); if (GetDeals != null) { foreach (DataRow Row in GetDeals.Rows) { int Id = Convert.ToInt32(Row["id"]); int PageId = Convert.ToInt32(Row["page_id"]); string Items = Convert.ToString(Row["items"]); string Name = Convert.ToString(Row["name"]); int Credits = Convert.ToInt32(Row["cost_credits"]); int Pixels = Convert.ToInt32(Row["cost_pixels"]); if (!_deals.ContainsKey(PageId)) { _deals[PageId] = new Dictionary <int, CatalogDeal>(); } CatalogDeal Deal = new CatalogDeal(Id, PageId, Items, Name, Credits, Pixels, ItemDataManager); _deals[PageId].Add(Deal.Id, Deal); } } dbClient.SetQuery("SELECT `id`,`parent_id`,`caption`,`page_link`,`visible`,`enabled`,`min_rank`,`min_vip`,`icon_image`,`page_layout`,`page_strings_1`,`page_strings_2` FROM `catalog_pages` ORDER BY `order_num`"); DataTable CatalogPages = dbClient.getTable(); if (CatalogPages != null) { foreach (DataRow Row in CatalogPages.Rows) { _pages.Add(Convert.ToInt32(Row["id"]), new CatalogPage(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["parent_id"]), Row["enabled"].ToString(), Convert.ToString(Row["caption"]), Convert.ToString(Row["page_link"]), Convert.ToInt32(Row["icon_image"]), Convert.ToInt32(Row["min_rank"]), Convert.ToInt32(Row["min_vip"]), Row["visible"].ToString(), Convert.ToString(Row["page_layout"]), Convert.ToString(Row["page_strings_1"]), Convert.ToString(Row["page_strings_2"]), _items.ContainsKey(Convert.ToInt32(Row["id"])) ? _items[Convert.ToInt32(Row["id"])] : new Dictionary <int, CatalogItem>(), _deals.ContainsKey(Convert.ToInt32(Row["id"])) ? _deals[Convert.ToInt32(Row["id"])] : new Dictionary <int, CatalogDeal>(), _predesignedItems.ContainsKey(Convert.ToInt32(Row["id"])) ? _predesignedItems[Convert.ToInt32(Row["id"])] : null, ref _itemOffers)); } } dbClient.SetQuery("SELECT `id`,`name`,`figure`,`motto`,`gender`,`ai_type` FROM `catalog_bot_presets`"); DataTable bots = dbClient.getTable(); if (bots != null) { foreach (DataRow Row in bots.Rows) { _botPresets.Add(Convert.ToInt32(Row[0]), new CatalogBot(Convert.ToInt32(Row[0]), Convert.ToString(Row[1]), Convert.ToString(Row[2]), Convert.ToString(Row[3]), Convert.ToString(Row[4]), Convert.ToString(Row[5]))); } } _petRaceManager.Init(); _clothingManager.Init(); } log.Info("» Catalogo -> PRONTO - BY: Thiago Araujo"); }
internal void Initialize(IQueryAdapter dbClient) { Pages = new Dictionary <int, CatalogPage>(); EcotronRewards = new List <EcotronReward>(); dbClient.setQuery("SELECT * FROM catalog_pages ORDER BY order_num"); DataTable Data = dbClient.getTable(); dbClient.setQuery("SELECT * FROM ecotron_rewards ORDER BY item_id"); DataTable EcoData = dbClient.getTable(); Hashtable CataItems = new Hashtable(); dbClient.setQuery("SELECT * FROM catalog_items"); DataTable CatalogueItems = dbClient.getTable(); if (CatalogueItems != null) { foreach (DataRow Row in CatalogueItems.Rows) { if (string.IsNullOrEmpty(Row["item_ids"].ToString()) || (int)Row["amount"] <= 0) { continue; } CataItems.Add(Convert.ToUInt32(Row["id"]), new CatalogItem(Row)); //Items.Add(new CatalogItem((uint)Row["id"], (string)Row["catalog_name"], (string)Row["item_ids"], (int)Row["cost_credits"], (int)Row["cost_pixels"], (int)Row["amount"])); } } if (Data != null) { foreach (DataRow Row in Data.Rows) { Boolean Visible = false; Boolean Enabled = false; if (Row["visible"].ToString() == "1") { Visible = true; } if (Row["enabled"].ToString() == "1") { Enabled = true; } Pages.Add((int)Row["id"], new CatalogPage((int)Row["id"], (int)Row["parent_id"], (string)Row["caption"], Visible, Enabled, Convert.ToUInt32(Row["min_rank"]), FirewindEnvironment.EnumToBool(Row["club_only"].ToString()), (int)Row["icon_color"], (int)Row["icon_image"], (string)Row["page_layout"], (string)Row["page_headline"], (string)Row["page_teaser"], (string)Row["page_special"], (string)Row["page_text1"], (string)Row["page_text2"], (string)Row["page_text_details"], (string)Row["page_text_teaser"], ref CataItems)); } } if (EcoData != null) { foreach (DataRow Row in EcoData.Rows) { EcotronRewards.Add(new EcotronReward(Convert.ToUInt32(Row["display_id"]), Convert.ToUInt32(Row["item_id"]), Convert.ToUInt32(Row["reward_level"]))); } } RestackByFrontpage(); }
public static UserData GetUserData(string SessionTicket, out byte errorCode) { int UserId; DataRow dUserInfo = null; DataTable dAchievements = null; DataTable dFavouriteRooms = null; DataTable dIgnores = null; DataTable dBadges = null; DataTable dEffects = null; DataTable dFriends = null; DataTable dRequests = null; DataTable dRooms = null; DataTable dQuests = null; DataTable dRelations = null; DataTable talentsTable = null; DataRow UserInfo = null; DataTable Subscriptions = null; using (IQueryAdapter dbClient = QuasarEnvironment.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 (QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId) != null) { errorCode = 2; QuasarEnvironment.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 ignore_id FROM user_ignores WHERE `user_id` = '" + UserId + "'"); dIgnores = dbClient.getTable(); dbClient.SetQuery("SELECT `badge_id`,`badge_slot` FROM user_badges WHERE `user_id` = '" + UserId + "'"); dBadges = dbClient.getTable(); dbClient.SetQuery("SELECT `effect_id`,`total_duration`,`is_activated`,`activated_stamp` FROM user_effects WHERE `user_id` = '" + UserId + "'"); dEffects = 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("SELECT * FROM `user_info` WHERE `user_id` = '" + UserId + "' LIMIT 1"); UserInfo = dbClient.getRow(); if (UserInfo == null) { dbClient.RunQuery("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' 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 <int> ignores = new List <int>(); foreach (DataRow dRow in dIgnores.Rows) { ignores.Add(Convert.ToInt32(dRow["ignore_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 = QuasarEnvironment.EnumToBool(dRow["hide_online"].ToString()); bool friendHideRoom = QuasarEnvironment.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(QuasarEnvironment.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)); } } 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"]; subscriptions.Add(str, new Subscription(str, TimeExpire)); } Habbo user = HabboFactory.GenerateHabbo(dUserInfo, UserInfo); dUserInfo = null; dAchievements = null; dFavouriteRooms = null; dIgnores = null; dBadges = null; dEffects = null; dFriends = null; dRequests = null; dRooms = null; dRelations = null; errorCode = 0; return(new UserData(UserId, Achievements, favouritedRooms, ignores, badges, friends, requests, rooms, quests, user, Relationships, talents, subscriptions)); }
public static UserData GetUserData(int UserId) { DataRow dUserInfo = null; DataRow UserInfo = null; DataTable dRelations = null; DataTable dGroups = null; using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `users` WHERE `id` = @id LIMIT 1"); dbClient.AddParameter("id", UserId); dUserInfo = dbClient.getRow(); QuasarEnvironment.GetGame().GetClientManager().LogClonesOut(Convert.ToInt32(UserId)); if (dUserInfo == null) { return(null); } if (QuasarEnvironment.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.RunQuery("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 <int> Ignores = 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>(); 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, Ignores, Badges, Friends, FriendRequests, Rooms, Quests, user, Relationships, talents, subscriptions)); }
public static void Search(ServerPacket Message, SearchResultList SearchResult, string SearchData, GameClient Session, int FetchLimit) { //Switching by categorys. switch (SearchResult.CategoryType) { default: Message.WriteInteger(0); break; case NavigatorCategoryType.QUERY: { #region Query if (SearchData.ToLower().StartsWith("owner:")) { if (SearchData.Length > 0) { int UserId = 0; DataTable GetRooms = null; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { if (SearchData.ToLower().StartsWith("owner:")) { dbClient.SetQuery("SELECT r.* FROM rooms r, users u WHERE u.username = @username AND r.owner = u.id AND r.state != 'invisible' ORDER BY r.users_now DESC LIMIT 50;"); dbClient.AddParameter("username", SearchData.Remove(0, 6)); GetRooms = dbClient.getTable(); } } List <RoomData> Results = new List <RoomData>(); if (GetRooms != null) { foreach (DataRow Row in GetRooms.Rows) { RoomData RoomData = PlusEnvironment.GetGame().GetRoomManager().FetchRoomData(Convert.ToInt32(Row["id"]), Row); if (RoomData != null && !Results.Contains(RoomData)) { Results.Add(RoomData); } } } Message.WriteInteger(Results.Count); foreach (RoomData Data in Results.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } } } else if (SearchData.ToLower().StartsWith("tag:")) { SearchData = SearchData.Remove(0, 4); ICollection <RoomData> TagMatches = PlusEnvironment.GetGame().GetRoomManager().SearchTaggedRooms(SearchData); Message.WriteInteger(TagMatches.Count); foreach (RoomData Data in TagMatches.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } } else if (SearchData.ToLower().StartsWith("group:")) { SearchData = SearchData.Remove(0, 6); ICollection <RoomData> GroupRooms = PlusEnvironment.GetGame().GetRoomManager().SearchGroupRooms(SearchData); Message.WriteInteger(GroupRooms.Count); foreach (RoomData Data in GroupRooms.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } } else { if (SearchData.Length > 0) { DataTable Table = null; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id`,`caption`,`description`,`roomtype`,`owner`,`state`,`category`,`users_now`,`users_max`,`model_name`,`score`,`allow_pets`,`allow_pets_eat`,`room_blocking_disabled`,`allow_hidewall`,`password`,`wallpaper`,`floor`,`landscape`,`floorthick`,`wallthick`,`mute_settings`,`kick_settings`,`ban_settings`,`chat_mode`,`chat_speed`,`chat_size`,`trade_settings`,`group_id`,`tags`,`push_enabled`,`pull_enabled`,`enables_enabled`,`respect_notifications_enabled`,`pet_morphs_allowed`,`spush_enabled`,`spull_enabled` FROM rooms WHERE `caption` LIKE @query ORDER BY `users_now` DESC LIMIT 50"); if (SearchData.ToLower().StartsWith("roomname:")) { dbClient.AddParameter("query", "%" + SearchData.Split(new char[] { ':' }, 2)[1] + "%"); } else { dbClient.AddParameter("query", "%" + SearchData + "%"); } Table = dbClient.getTable(); } List <RoomData> Results = new List <RoomData>(); if (Table != null) { foreach (DataRow Row in Table.Rows) { if (Convert.ToString(Row["state"]) == "invisible") { continue; } RoomData RData = PlusEnvironment.GetGame().GetRoomManager().FetchRoomData(Convert.ToInt32(Row["id"]), Row); if (RData != null && !Results.Contains(RData)) { Results.Add(RData); } } } Message.WriteInteger(Results.Count); foreach (RoomData Data in Results.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } } } #endregion break; } case NavigatorCategoryType.FEATURED: #region Featured List <RoomData> Rooms = new List <RoomData>(); ICollection <FeaturedRoom> Featured = PlusEnvironment.GetGame().GetNavigator().GetFeaturedRooms(); foreach (FeaturedRoom FeaturedItem in Featured.ToList()) { if (FeaturedItem == null) { continue; } RoomData Data = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(FeaturedItem.RoomId); if (Data == null) { continue; } if (!Rooms.Contains(Data)) { Rooms.Add(Data); } } Message.WriteInteger(Rooms.Count); foreach (RoomData Data in Rooms.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } #endregion break; case NavigatorCategoryType.POPULAR: { List <RoomData> PopularRooms = PlusEnvironment.GetGame().GetRoomManager().GetPopularRooms(-1, FetchLimit); Message.WriteInteger(PopularRooms.Count); foreach (RoomData Data in PopularRooms.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } break; } case NavigatorCategoryType.RECOMMENDED: { List <RoomData> RecommendedRooms = PlusEnvironment.GetGame().GetRoomManager().GetRecommendedRooms(FetchLimit); Message.WriteInteger(RecommendedRooms.Count); foreach (RoomData Data in RecommendedRooms.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } break; } case NavigatorCategoryType.CATEGORY: { List <RoomData> GetRoomsByCategory = PlusEnvironment.GetGame().GetRoomManager().GetRoomsByCategory(SearchResult.Id, FetchLimit); Message.WriteInteger(GetRoomsByCategory.Count); foreach (RoomData Data in GetRoomsByCategory.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } break; } case NavigatorCategoryType.MY_ROOMS: Message.WriteInteger(Session.GetHabbo().UsersRooms.Count); foreach (RoomData Data in Session.GetHabbo().UsersRooms.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } break; case NavigatorCategoryType.MY_FAVORITES: List <RoomData> Favourites = new List <RoomData>(); foreach (int Id in Session.GetHabbo().FavoriteRooms.ToArray()) { RoomData Room = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(Id); if (Room == null) { continue; } if (!Favourites.Contains(Room)) { Favourites.Add(Room); } } Favourites = Favourites.Take(FetchLimit).ToList(); Message.WriteInteger(Favourites.Count); foreach (RoomData Data in Favourites.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } break; case NavigatorCategoryType.MY_GROUPS: List <RoomData> MyGroups = new List <RoomData>(); foreach (Group Group in PlusEnvironment.GetGame().GetGroupManager().GetGroupsForUser(Session.GetHabbo().Id).ToList()) { if (Group == null) { continue; } RoomData Data = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId); if (Data == null) { continue; } if (!MyGroups.Contains(Data)) { MyGroups.Add(Data); } } MyGroups = MyGroups.Take(FetchLimit).ToList(); Message.WriteInteger(MyGroups.Count); foreach (RoomData Data in MyGroups.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } break; case NavigatorCategoryType.MY_FRIENDS_ROOMS: List <RoomData> MyFriendsRooms = new List <RoomData>(); foreach (MessengerBuddy buddy in Session.GetHabbo().GetMessenger().GetFriends().Where(p => p.InRoom)) { if (buddy == null || !buddy.InRoom || buddy.UserId == Session.GetHabbo().Id) { continue; } if (!MyFriendsRooms.Contains(buddy.CurrentRoom.RoomData)) { MyFriendsRooms.Add(buddy.CurrentRoom.RoomData); } } Message.WriteInteger(MyFriendsRooms.Count); foreach (RoomData Data in MyFriendsRooms.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } break; case NavigatorCategoryType.MY_RIGHTS: List <RoomData> MyRights = new List <RoomData>(); DataTable GetRights = null; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `room_id` FROM `room_rights` WHERE `user_id` = @UserId LIMIT @FetchLimit"); dbClient.AddParameter("UserId", Session.GetHabbo().Id); dbClient.AddParameter("FetchLimit", FetchLimit); GetRights = dbClient.getTable(); foreach (DataRow Row in GetRights.Rows) { RoomData Data = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(Convert.ToInt32(Row["room_id"])); if (Data == null) { continue; } if (!MyRights.Contains(Data)) { MyRights.Add(Data); } } } Message.WriteInteger(MyRights.Count); foreach (RoomData Data in MyRights.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } break; case NavigatorCategoryType.TOP_PROMOTIONS: { List <RoomData> GetPopularPromotions = PlusEnvironment.GetGame().GetRoomManager().GetOnGoingRoomPromotions(16, FetchLimit); Message.WriteInteger(GetPopularPromotions.Count); foreach (RoomData Data in GetPopularPromotions.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } break; } case NavigatorCategoryType.PROMOTION_CATEGORY: { List <RoomData> GetPromotedRooms = PlusEnvironment.GetGame().GetRoomManager().GetPromotedRooms(SearchResult.Id, FetchLimit); Message.WriteInteger(GetPromotedRooms.Count); foreach (RoomData Data in GetPromotedRooms.ToList()) { RoomAppender.WriteRoom(Message, Data, Data.Promotion); } break; } } }
public void Init() { if (_items.Count > 0) { _items.Clear(); } using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `furniture`"); DataTable ItemData = dbClient.getTable(); if (ItemData != null) { foreach (DataRow Row in ItemData.Rows) { try { int id = Convert.ToInt32(Row["id"]); int spriteID = Convert.ToInt32(Row["sprite_id"]); string itemName = Convert.ToString(Row["item_name"]); string PublicName = Convert.ToString(Row["public_name"]); string type = Row["type"].ToString(); int width = Convert.ToInt32(Row["width"]); int length = Convert.ToInt32(Row["length"]); double height = Convert.ToDouble(Row["stack_height"]); bool allowStack = NeonEnvironment.EnumToBool(Row["can_stack"].ToString()); bool allowWalk = NeonEnvironment.EnumToBool(Row["is_walkable"].ToString()); bool allowSit = NeonEnvironment.EnumToBool(Row["can_sit"].ToString()); bool allowRecycle = NeonEnvironment.EnumToBool(Row["allow_recycle"].ToString()); bool allowTrade = NeonEnvironment.EnumToBool(Row["allow_trade"].ToString()); bool allowMarketplace = Convert.ToInt32(Row["allow_marketplace_sell"]) == 1; bool allowGift = Convert.ToInt32(Row["allow_gift"]) == 1; bool allowInventoryStack = NeonEnvironment.EnumToBool(Row["allow_inventory_stack"].ToString()); InteractionType interactionType = InteractionTypes.GetTypeFromString(Convert.ToString(Row["interaction_type"])); int cycleCount = Convert.ToInt32(Row["interaction_modes_count"]); string vendingIDS = Convert.ToString(Row["vending_ids"]); string heightAdjustable = Convert.ToString(Row["height_adjustable"]); int EffectId = Convert.ToInt32(Row["effect_id"]); int WiredId = Convert.ToInt32(Row["wired_id"]); bool IsRare = NeonEnvironment.EnumToBool(Row["is_rare"].ToString()); int ClothingId = Convert.ToInt32(Row["clothing_id"]); bool ExtraRot = NeonEnvironment.EnumToBool(Row["extra_rot"].ToString()); int SongID = Convert.ToInt32(Row["song_Id"]); if (!_gifts.ContainsKey(spriteID)) { _gifts.Add(spriteID, new ItemData(id, spriteID, itemName, PublicName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS, heightAdjustable, EffectId, WiredId, IsRare, ClothingId, ExtraRot, SongID)); } if (!_items.ContainsKey(id)) { _items.Add(id, new ItemData(id, spriteID, itemName, PublicName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS, heightAdjustable, EffectId, WiredId, IsRare, ClothingId, ExtraRot, SongID)); } } catch (Exception e) { Console.WriteLine(e.ToString()); Console.ReadKey(); Logging.WriteLine("Could not load item #" + Convert.ToInt32(Row[0]) + ", please verify the data is okay."); } } } } log.Info(">> Items Manager -> READY!"); }
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { int TotalDuckets = 0; try { DataTable Table = null; using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id` FROM `items` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND (`room_id`= '0' OR `room_id` = '')"); Table = dbClient.getTable(); } if (Table == null) { Session.SendWhisper("¡Você não tem nenhuma moeda em seu inventário!"); return; } foreach (DataRow Row in Table.Rows) { Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(Convert.ToInt32(Row[0])); if (Item == null) { continue; } if (!Item.GetBaseItem().ItemName.StartsWith("DU_") && !Item.GetBaseItem().ItemName.StartsWith("DUC_")) { continue; } if (Item.RoomId > 0) { continue; } string[] Split = Item.GetBaseItem().ItemName.Split('_'); int Value = int.Parse(Split[1]); using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("DELETE FROM `items` WHERE `id` = '" + Item.Id + "' LIMIT 1"); } Session.GetHabbo().GetInventoryComponent().RemoveItem(Item.Id); TotalDuckets += Value; if (Value > 0) { Session.GetHabbo().Duckets += Value; Session.SendMessage(new ActivityPointsComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Diamonds, Session.GetHabbo().GOTWPoints)); } } if (TotalDuckets > 0) { Session.SendWhisper("¡Você resgatou corretamente " + TotalDuckets + " duckets do seu inventario!"); } else { Session.SendWhisper("¡Ocorreu algum Erro!"); } } catch { Session.SendNotification("¡Sinto muito, Ocorreu algum erro!"); } }
internal void LoadFurniture() { //this.Items.Clear(); this.mFloorItems.Clear(); this.mWallItems.Clear(); DataTable Data; using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("CALL getroomitems(@roomid)"); dbClient.addParameter("roomid", room.RoomId); Data = dbClient.getTable(); uint itemID; decimal x; decimal y; sbyte n; uint baseID; int dataType; string extradata; WallCoordinate wallCoord; int extra; foreach (DataRow dRow in Data.Rows) { itemID = Convert.ToUInt32(dRow[0]); x = Convert.ToDecimal(dRow[1]); y = Convert.ToDecimal(dRow[2]); n = Convert.ToSByte(dRow[3]); baseID = Convert.ToUInt32(dRow[4]); IRoomItemData data; if (DBNull.Value.Equals(dRow[5])) { data = new StringData(""); extra = 0; } else { dataType = Convert.ToInt32(dRow[5]); extradata = (string)dRow[6]; extra = Convert.ToInt32(dRow[7]); switch (dataType) { case 0: data = new StringData(extradata); break; case 1: data = new MapStuffData(); break; case 2: data = new StringArrayStuffData(); break; case 3: data = new StringIntData(); break; default: data = new StringData(extradata); break; } try { data.Parse(extradata); } catch { Logging.LogException(string.Format("Error in furni data! Item ID: \"{0}\" and data: \"{1}\"", itemID, extradata.Replace(Convert.ToChar(1).ToString(), "[1]"))); dbClient.runFastQuery(string.Format("DELETE FROM items_extradata WHERE item_id = {0}", itemID)); } } if (FirewindEnvironment.GetGame().GetItemManager().GetItem(baseID).Type == 'i') // Is wallitem { wallCoord = new WallCoordinate((double)x, (double)y, n); RoomItem item = new RoomItem(itemID, room.RoomId, baseID, data, extra, wallCoord, room); if (!mWallItems.ContainsKey(itemID)) { mWallItems.Inner.Add(itemID, item); } } else //Is flooritem { int coordX, coordY; TextHandling.Split((double)x, out coordX, out coordY); RoomItem item = new RoomItem(itemID, room.RoomId, baseID, data, extra, coordX, coordY, (double)y, n, room); if (!mFloorItems.ContainsKey(itemID)) { mFloorItems.Inner.Add(itemID, item); } } } foreach (RoomItem Item in mFloorItems.Values) { if (Item.IsRoller) { mGotRollers = true; } else if (Item.GetBaseItem().InteractionType == Firewind.HabboHotel.Items.InteractionType.dimmer) { if (room.MoodlightData == null) { room.MoodlightData = new MoodlightData(Item.Id); } } else if (WiredUtillity.TypeIsWired(Item.GetBaseItem().InteractionType)) { WiredLoader.LoadWiredItem(Item, room, dbClient); room.GetWiredHandler().AddWire(Item, Item.Coordinate, Item.Rot, Item.GetBaseItem().InteractionType); } } } }
public void Init() { #region oldnav /* * if (this._searchResultLists.Count > 0) * this._searchResultLists.Clear(); * * if (this._featuredRooms.Count > 0) * this._featuredRooms.Clear(); * * DataTable Table = null; * using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) * { * dbClient.SetQuery("SELECT * FROM `navigator_categories` ORDER BY `id` ASC"); * Table = dbClient.getTable(); * * if (Table != null) * { * foreach (DataRow Row in Table.Rows) * { * if (Convert.ToInt32(Row["enabled"]) == 1) * { * if (!this._searchResultLists.ContainsKey(Convert.ToInt32(Row["id"]))) * this._searchResultLists.Add(Convert.ToInt32(Row["id"]), new SearchResultList(Convert.ToInt32(Row["id"]), Convert.ToString(Row["category"]), Convert.ToString(Row["category_identifier"]), Convert.ToString(Row["public_name"]), true, -1, Convert.ToInt32(Row["required_rank"]), NavigatorViewModeUtility.GetViewModeByString(Convert.ToString(Row["view_mode"])), Convert.ToString(Row["category_type"]), Convert.ToString(Row["search_allowance"]), Convert.ToInt32(Row["order_id"]))); * } * } * } * * dbClient.SetQuery("SELECT `room_id`,`caption`,`description`,`image_url`,`enabled` FROM `navigator_publics` ORDER BY `order_num` ASC"); * DataTable GetPublics = dbClient.getTable(); * * if (GetPublics != null) * { * foreach (DataRow Row in GetPublics.Rows) * { * if (Convert.ToInt32(Row["enabled"]) == 1) * { * if (!this._featuredRooms.ContainsKey(Convert.ToInt32(Row["room_id"]))) * this._featuredRooms.Add(Convert.ToInt32(Row["room_id"]), new FeaturedRoom(Convert.ToInt32(Row["room_id"]), Convert.ToString(Row["caption"]), Convert.ToString(Row["description"]), Convert.ToString(Row["image_url"]))); * } * } * } * } * * log.Info(">> Navigator -> Ready!"); */ #endregion if (_searchResultLists.Count > 0) { _searchResultLists.Clear(); } if (_featuredRooms.Count > 0) { _featuredRooms.Clear(); } if (_staffPicks.Count > 0) { _staffPicks.Clear(); } DataTable Table = null; using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `navigator_categories` ORDER BY `id` ASC"); Table = dbClient.getTable(); if (Table != null) { foreach (DataRow Row in Table.Rows) { if (Convert.ToInt32(Row["enabled"]) == 1) { if (!_searchResultLists.ContainsKey(Convert.ToInt32(Row["id"]))) { _searchResultLists.Add(Convert.ToInt32(Row["id"]), new SearchResultList(Convert.ToInt32(Row["id"]), Convert.ToString(Row["category"]), Convert.ToString(Row["category_identifier"]), Convert.ToString(Row["public_name"]), true, -1, Convert.ToInt32(Row["required_rank"]), NavigatorViewModeUtility.GetViewModeByString(Convert.ToString(Row["view_mode"])), Convert.ToString(Row["category_type"]), Convert.ToString(Row["search_allowance"]), Convert.ToInt32(Row["order_id"]))); } } } } dbClient.SetQuery("SELECT `id`,`room_id`,`caption`,`description`,`image_url`,`enabled`,`category_id` FROM `navigator_publics` ORDER BY `order_num` ASC"); DataTable GetPublics = dbClient.getTable(); if (GetPublics != null) { foreach (DataRow Row in GetPublics.Rows) { if (Convert.ToInt32(Row["enabled"]) == 1) { if (!_featuredRooms.ContainsKey(Convert.ToInt32(Row["id"]))) { _featuredRooms.Add(Convert.ToInt32(Row["id"]), new FeaturedRoom(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["room_id"]), Convert.ToString(Row["caption"]), Convert.ToString(Row["description"]), Convert.ToString(Row["image_url"]), Convert.ToInt32(Row["category_id"]))); } } } } dbClient.SetQuery("SELECT `room_id`,`image` FROM `navigator_staff_picks`"); DataTable GetPicks = dbClient.getTable(); if (GetPicks != null) { foreach (DataRow Row in GetPicks.Rows) { if (!_staffPicks.ContainsKey(Convert.ToInt32(Row["room_id"]))) { _staffPicks.Add(Convert.ToInt32(Row["room_id"]), new StaffPick(Convert.ToInt32(Row["room_id"]), Convert.ToString(Row["image"]))); } } } } log.Info("» Navigator Manager -> READY!"); }
internal void LoadItems(IQueryAdapter dbClient) { Items = new Dictionary <uint, Item>(); dbClient.setQuery("SELECT * FROM items_base"); DataTable ItemData = dbClient.getTable(); if (ItemData != null) { uint id; int spriteID; string publicName; string itemName; string type; int width; int length; double height; bool allowStack; bool allowWalk; bool allowSit; bool allowRecycle; bool allowTrade; bool allowMarketplace; bool allowGift; bool allowInventoryStack; InteractionType interactionType; int cycleCount; string vendingIDS; foreach (DataRow dRow in ItemData.Rows) { try { id = Convert.ToUInt16(dRow[0]); spriteID = (int)dRow[1]; publicName = (string)dRow[2]; itemName = (string)dRow[3]; type = (string)dRow[4]; width = (int)dRow[5]; length = (int)dRow[6]; height = Convert.ToDouble(dRow[7]); allowStack = Convert.ToInt32(dRow[8]) == 1; allowWalk = Convert.ToInt32(dRow[9]) == 1; allowSit = Convert.ToInt32(dRow[10]) == 1; allowRecycle = Convert.ToInt32(dRow[11]) == 1; allowTrade = Convert.ToInt32(dRow[12]) == 1; allowMarketplace = Convert.ToInt32(dRow[13]) == 1; allowGift = Convert.ToInt32(dRow[14]) == 1; allowInventoryStack = Convert.ToInt32(dRow[15]) == 1; interactionType = InterractionTypes.GetTypeFromString((string)dRow[16]); cycleCount = (int)dRow[17]; vendingIDS = (string)dRow[18]; Item item = new Item(id, spriteID, publicName, itemName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS); Items.Add(id, item); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.ReadKey(); Logging.WriteLine("Could not load item #" + Convert.ToUInt32(dRow[0]) + ", please verify the data is okay."); } } } }
public void Fill(DataRow Row) { Id = Convert.ToInt32(Row["id"]); Name = Convert.ToString(Row["caption"]); Description = Convert.ToString(Row["description"]); Type = Convert.ToString(Row["roomtype"]); OwnerId = Convert.ToInt32(Row["owner"]); OwnerName = ""; using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `username` FROM `users` WHERE `id` = @owner LIMIT 1"); dbClient.AddParameter("owner", OwnerId); string result = dbClient.getString(); if (!string.IsNullOrEmpty(result)) { OwnerName = result; } } Access = RoomAccessUtility.ToRoomAccess(Row["state"].ToString().ToLower()); Category = Convert.ToInt32(Row["category"]); if (!string.IsNullOrEmpty(Row["users_now"].ToString())) { UsersNow = Convert.ToInt32(Row["users_now"]); } else { UsersNow = 0; } UsersMax = Convert.ToInt32(Row["users_max"]); ModelName = Convert.ToString(Row["model_name"]); Score = Convert.ToInt32(Row["score"]); Tags = new List <string>(); AllowPets = Convert.ToInt32(Row["allow_pets"].ToString()); AllowPetsEating = Convert.ToInt32(Row["allow_pets_eat"].ToString()); RoomBlockingEnabled = Convert.ToInt32(Row["room_blocking_disabled"].ToString()); Hidewall = Convert.ToInt32(Row["allow_hidewall"].ToString()); Password = Convert.ToString(Row["password"]); Wallpaper = Convert.ToString(Row["wallpaper"]); Floor = Convert.ToString(Row["floor"]); Landscape = Convert.ToString(Row["landscape"]); FloorThickness = Convert.ToInt32(Row["floorthick"]); WallThickness = Convert.ToInt32(Row["wallthick"]); WhoCanMute = Convert.ToInt32(Row["mute_settings"]); WhoCanKick = Convert.ToInt32(Row["kick_settings"]); WhoCanBan = Convert.ToInt32(Row["ban_settings"]); chatMode = Convert.ToInt32(Row["chat_mode"]); chatSpeed = Convert.ToInt32(Row["chat_speed"]); chatSize = Convert.ToInt32(Row["chat_size"]); TradeSettings = Convert.ToInt32(Row["trade_settings"]); RollerSpeed = Convert.ToInt32(Row["roller_speed"]); if (NeonEnvironment.GetGame().GetGroupManager().TryGetGroup(Convert.ToInt32(Row["group_id"]), out Group G)) { Group = G; } else { Group = null; } foreach (string Tag in Row["tags"].ToString().Split(',')) { Tags.Add(Tag); } mModel = NeonEnvironment.GetGame().GetRoomManager().GetModel(ModelName); PushEnabled = NeonEnvironment.EnumToBool(Row["push_enabled"].ToString()); PullEnabled = NeonEnvironment.EnumToBool(Row["pull_enabled"].ToString()); SPushEnabled = NeonEnvironment.EnumToBool(Row["spush_enabled"].ToString()); SPullEnabled = NeonEnvironment.EnumToBool(Row["spull_enabled"].ToString()); EnablesEnabled = NeonEnvironment.EnumToBool(Row["enables_enabled"].ToString()); RespectNotificationsEnabled = NeonEnvironment.EnumToBool(Row["respect_notifications_enabled"].ToString()); PetMorphsAllowed = NeonEnvironment.EnumToBool(Row["pet_morphs_allowed"].ToString()); Shoot = Convert.ToInt32(Row["shoot"]); HideWired = NeonEnvironment.EnumToBool(Row["hide_wired"].ToString()); WiredScoreBordDay = new Dictionary <int, KeyValuePair <int, string> >(); WiredScoreBordWeek = new Dictionary <int, KeyValuePair <int, string> >(); WiredScoreBordMonth = new Dictionary <int, KeyValuePair <int, string> >(); using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { List <bool> SuperCheck = new List <bool>() { false, false, false }; DateTime now = DateTime.Now; int getdaytoday = Convert.ToInt32(now.ToString("MMddyyyy")); int getmonthtoday = Convert.ToInt32(now.ToString("MM")); int getweektoday = CultureInfo.GetCultureInfo("Nl-nl").Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); WiredScoreFirstBordInformation = new List <int>() { getdaytoday, getmonthtoday, getweektoday }; dbClient.SetQuery("SELECT * FROM wired_scorebord WHERE roomid = @id ORDER BY `punten` DESC "); dbClient.AddParameter("id", Id); foreach (DataRow row in dbClient.getTable().Rows) { int userid = Convert.ToInt32(row["userid"]); string username = Convert.ToString(row["username"]); int Punten = Convert.ToInt32(row["punten"]); string soort = Convert.ToString(row["soort"]); int timestamp = Convert.ToInt32(row["timestamp"]); if ((!(soort == "day") || WiredScoreBordDay.ContainsKey(userid) ? false : !SuperCheck[0])) { if (timestamp != getdaytoday) { SuperCheck[0] = false; } if (!SuperCheck[0]) { WiredScoreBordDay.Add(userid, new KeyValuePair <int, string>(Punten, username)); } } if ((!(soort == "month") || WiredScoreBordMonth.ContainsKey(userid) ? false : !SuperCheck[1])) { if (timestamp != getmonthtoday) { SuperCheck[1] = false; } WiredScoreBordMonth.Add(userid, new KeyValuePair <int, string>(Punten, username)); } if ((!(soort == "week") || WiredScoreBordWeek.ContainsKey(userid) ? false : !SuperCheck[2])) { if (timestamp != getweektoday) { SuperCheck[2] = false; } WiredScoreBordWeek.Add(userid, new KeyValuePair <int, string>(Punten, username)); } } if (SuperCheck[0]) { dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", Id, "' AND `soort`='day'")); WiredScoreBordDay.Clear(); } if (SuperCheck[1]) { dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", Id, "' AND `soort`='month'")); WiredScoreBordMonth.Clear(); } if (SuperCheck[2]) { dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", Id, "' AND `soort`='week'")); WiredScoreBordDay.Clear(); } } }
public Game2LastWeekLeaderboardMessageComposer(int GameId, int Week) : base(ServerPacketHeader.Game2LastWeekLeaderboardMessageComposer) { base.WriteInteger(2018); base.WriteInteger(1); base.WriteInteger(0); base.WriteInteger(1); base.WriteInteger(1581); int count = 0; using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT COUNT(0) FROM `games_leaderboard` WHERE game_id = " + GameId + " AND week = " + Week + " LIMIT 5"); count = dbClient.getInteger(); } base.WriteInteger(count);//Count int id = 1; using (IQueryAdapter dbClient2 = RavenEnvironment.GetDatabaseManager().GetQueryReactor()) { DataTable GetLeaderData = null; dbClient2.SetQuery("SELECT * FROM `games_leaderboard` WHERE game_id = " + GameId + " AND week = " + Week + " LIMIT 5"); GetLeaderData = dbClient2.getTable(); if (GetLeaderData != null) { foreach (DataRow Rows in GetLeaderData.Rows) { Habbo habbo = RavenEnvironment.GetHabboById(Convert.ToInt32(Rows["user_id"])); base.WriteInteger(habbo.Id); //Id base.WriteInteger(Convert.ToInt32(Rows["points"])); //Score base.WriteInteger(id++); //Rank base.WriteString(habbo.Username); //Username base.WriteString(habbo.Look); //Figure base.WriteString(habbo.Gender.ToLower()); //Gender .ToLower() } } } base.WriteInteger(0); // base.WriteInteger(GameId); //Game Id? //int count = 0; //if (Game.LeaderBoard.Count() > 5) { count = 5; } else { count = Game.LeaderBoard.Count(); } //base.WriteInteger(2018); //base.WriteInteger(1); //base.WriteInteger(0); //base.WriteInteger(1); //base.WriteInteger(1581); //base.WriteInteger(count);//Count //Console.WriteLine(Game.GameName + ":" + Game.LeaderBoard.Count()); //int id = 0; //foreach (var Data in Game.LeaderBoard) //{ // if(Data.Value.Week != Week) { return; } // id++; // Habbo habbo = RavenEnvironment.GetHabboById(Data.Value.UserId); // base.WriteInteger(habbo.Id);//Id // base.WriteInteger(id);//Rank // base.WriteInteger(Data.Value.Points);//Score // base.WriteString(habbo.Username);//Username // base.WriteString(habbo.Look);//Figure // base.WriteString(habbo.Gender.ToLower());//Gender .ToLower() // if(id == 5) { break; } //} //Used to generate the ranking numbers. //int num = 0; //base.WriteInteger(Habbos.Count);//Count //foreach (Habbo Habbo in Habbos.ToList()) //{ // num++; // base.WriteInteger(Habbo.Id);//Id // base.WriteInteger(Habbo.FastfoodScore);//Score // base.WriteInteger(num);//Rank // base.WriteString(Habbo.Username);//Username // base.WriteString(Habbo.Look);//Figure // base.WriteString(Habbo.Gender.ToLower());//Gender .ToLower() //} //base.WriteInteger(0);// //base.WriteInteger(GameData.GameId);//Game Id? /*base.WriteInteger(5);//Count * * base.WriteInteger(1);//Id * base.WriteInteger(10);//Rank * base.WriteInteger(1);//Score * base.WriteString("Custom - Derecha");//Username * base.WriteString("ch-235-1408.hd-3095-14.lg-3116-85-1408.sh-3115-1408-1408.ca-1805-64.ha-1002-1408");//Figure * base.WriteString("m");//Gender .ToLower() * * base.WriteInteger(2);//Id * base.WriteInteger(19999);//Score * base.WriteInteger(2);//Rank * base.WriteString("Salinas");//Username * base.WriteString("ch-255-96.sh-3115-1408-1408.lg-3116-85-1408.ea-1404-1194.fa-1203-1189.hr-831-1041.hd-3103-1389");//Figure * base.WriteString("m");//Gender .ToLower() * * base.WriteInteger(3);//Id * base.WriteInteger(1232);//Score * base.WriteInteger(3);//Rank * base.WriteString("HiddenKey");//Username * base.WriteString("ch-235-1408.fa-1208-1189.lg-3116-85-1408.cc-886-62.ea-1404-1194.ha-3086-96-1194.sh-3115-1408-1408.hr-100-1041.hd-3103-1389");//Figure * base.WriteString("m");//Gender .ToLower() * * base.WriteInteger(4);//Id * base.WriteInteger(1000);//Score * base.WriteInteger(4);//Rank * base.WriteString("Custom");//Username * base.WriteString("fa-1201-62.sh-6102459-96-62.hr-831-1031.ch-804-1201.lg-281-110.ha-1012-78.hd-180-11");//Figure * base.WriteString("m");//Gender .ToLower() * * base.WriteInteger(5);//Id * base.WriteInteger(1000);//Score * base.WriteInteger(5);//Rank * base.WriteString("Custom");//Username * base.WriteString("hd-180-11.hr-828-55.ch-804-96.sh-3089-1186.lg-281-110");//Figure * base.WriteString("m");//Gender .ToLower()*/ //base.WriteInteger(0);// //base.WriteInteger(Game.GameId);//Game Id? }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) { return; } Room Room = Session.GetHabbo().CurrentRoom; if (Room == null) { return; } int BotId = Packet.PopInt(); int ActionId = Packet.PopInt(); string DataString = Packet.PopString(); if (ActionId < 1 || ActionId > 5) { return; } if (!Room.GetRoomUserManager().TryGetBot(BotId, out RoomUser Bot)) { return; } if ((Bot.BotData.ownerID != Session.GetHabbo().Id&& !Session.GetHabbo().GetPermissions().HasRight("bot_edit_any_override"))) { return; } RoomBot RoomBot = Bot.BotData; if (RoomBot == null) { return; } /* 1 = Copy looks * 2 = Setup Speech * 3 = Relax * 4 = Dance * 5 = Change Name */ switch (ActionId) { #region Copy Looks (1) case 1: { ServerPacket UserChangeComposer = new ServerPacket(ServerPacketHeader.UserChangeMessageComposer); UserChangeComposer.WriteInteger(Bot.VirtualId); UserChangeComposer.WriteString(Session.GetHabbo().Look); UserChangeComposer.WriteString(Session.GetHabbo().Gender); UserChangeComposer.WriteString(Bot.BotData.Motto); UserChangeComposer.WriteInteger(0); Room.SendMessage(UserChangeComposer); //Change the defaults Bot.BotData.Look = Session.GetHabbo().Look; Bot.BotData.Gender = Session.GetHabbo().Gender; using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `bots` SET `look` = @look, `gender` = '" + Session.GetHabbo().Gender + "' WHERE `id` = '" + Bot.BotData.Id + "' LIMIT 1"); dbClient.AddParameter("look", Session.GetHabbo().Look); dbClient.RunQuery(); } //Room.SendMessage(new UserChangeComposer(BotUser.GetClient(), true)); break; } #endregion #region Setup Speech (2) case 2: { string[] ConfigData = DataString.Split(new string[] { ";#;" }, StringSplitOptions.None); string[] SpeechData = ConfigData[0].Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); string AutomaticChat = Convert.ToString(ConfigData[1]); string SpeakingInterval = Convert.ToString(ConfigData[2]); string MixChat = Convert.ToString(ConfigData[3]); if (string.IsNullOrEmpty(SpeakingInterval) || Convert.ToInt32(SpeakingInterval) <= 0 || Convert.ToInt32(SpeakingInterval) < 7) { SpeakingInterval = "7"; } RoomBot.AutomaticChat = Convert.ToBoolean(AutomaticChat); RoomBot.SpeakingInterval = Convert.ToInt32(SpeakingInterval); RoomBot.MixSentences = Convert.ToBoolean(MixChat); using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("DELETE FROM `bots_speech` WHERE `bot_id` = '" + Bot.BotData.Id + "'"); } #region Save Data - TODO: MAKE METHODS FOR THIS. for (int i = 0; i <= SpeechData.Length - 1; i++) { SpeechData[i] = Regex.Replace(SpeechData[i], "<(.|\\n)*?>", string.Empty); using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("INSERT INTO `bots_speech` (`bot_id`, `text`) VALUES (@id, @data)"); dbClient.AddParameter("id", BotId); dbClient.AddParameter("data", SpeechData[i]); dbClient.RunQuery(); dbClient.SetQuery("UPDATE `bots` SET `automatic_chat` = @AutomaticChat, `speaking_interval` = @SpeakingInterval, `mix_sentences` = @MixChat WHERE `id` = @id LIMIT 1"); dbClient.AddParameter("id", BotId); dbClient.AddParameter("AutomaticChat", AutomaticChat.ToLower()); dbClient.AddParameter("SpeakingInterval", Convert.ToInt32(SpeakingInterval)); dbClient.AddParameter("MixChat", NeonEnvironment.BoolToEnum(Convert.ToBoolean(MixChat))); dbClient.RunQuery(); } } #endregion #region Handle Speech RoomBot.RandomSpeech.Clear(); using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `text` FROM `bots_speech` WHERE `bot_id` = @id"); dbClient.AddParameter("id", BotId); DataTable BotSpeech = dbClient.getTable(); List <RandomSpeech> Speeches = new List <RandomSpeech>(); foreach (DataRow Speech in BotSpeech.Rows) { RoomBot.RandomSpeech.Add(new RandomSpeech(Convert.ToString(Speech["text"]), BotId)); } } #endregion break; } #endregion #region Relax (3) case 3: { if (Bot.BotData.WalkingMode == "stand") { Bot.BotData.WalkingMode = "freeroam"; } else { Bot.BotData.WalkingMode = "stand"; } using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE `bots` SET `walk_mode` = '" + Bot.BotData.WalkingMode + "' WHERE `id` = '" + Bot.BotData.Id + "' LIMIT 1"); } break; } #endregion #region Dance (4) case 4: { if (Bot.BotData.DanceId > 0) { Bot.BotData.DanceId = 0; } else { Random RandomDance = new Random(); Bot.BotData.DanceId = RandomDance.Next(1, 4); } Room.SendMessage(new DanceComposer(Bot, Bot.BotData.DanceId)); break; } #endregion #region Change Name (5) case 5: { if (DataString.Length == 0) { Session.SendWhisper("Vamos, ponle algun nombre al bot"); return; } else if (DataString.Length >= 16) { Session.SendWhisper("Vamos.. necesitas un nombre mas corto!"); return; } if (DataString.Contains("<img src") || DataString.Contains("<font ") || DataString.Contains("</font>") || DataString.Contains("</a>") || DataString.Contains("<i>")) { Session.SendWhisper("¿Qué intentas, crack?", 34); return; } Bot.BotData.Name = DataString; using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `bots` SET `name` = @name WHERE `id` = '" + Bot.BotData.Id + "' LIMIT 1"); dbClient.AddParameter("name", DataString); dbClient.RunQuery(); } Room.SendMessage(new UsersComposer(Bot)); break; } #endregion } }
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { int TotalValue = 0; try { DataTable Table = null; using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id` FROM `items` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND (`room_id`= '0' OR `room_id` = '')"); Table = dbClient.getTable(); } if (Table == null) { Session.SendWhisper("Atualmente, não tem itens no seu inventário!"); return; } foreach (DataRow Row in Table.Rows) { Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(Convert.ToInt32(Row[0])); if (Item == null) { continue; } if (!Item.GetBaseItem().ItemName.StartsWith("CF_") && !Item.GetBaseItem().ItemName.StartsWith("CFC_")) { continue; } if (Item.RoomId > 0) { continue; } string[] Split = Item.GetBaseItem().ItemName.Split('_'); int Value = int.Parse(Split[1]); using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("DELETE FROM `items` WHERE `id` = '" + Item.Id + "' LIMIT 1"); } Session.GetHabbo().GetInventoryComponent().RemoveItem(Item.Id); TotalValue += Value; if (Value > 0) { Session.GetHabbo().Credits += Value; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); } } if (TotalValue > 0) { Session.SendNotification("Todos seuscréditos convertido com éxito!\r\r(Valor Total: " + TotalValue + " Créditos!"); } else { Session.SendNotification("Parece que não tem itens intercambiáveis!"); } } catch { Session.SendNotification("ocorreu um erro ao converter seus créditos!"); } }
private void ReloadOffers(GameClient Session) { int MinCost = -1; int MaxCost = -1; string SearchQuery = ""; int FilterMode = 1; DataTable table = null; StringBuilder builder = new StringBuilder(); string str = ""; builder.Append("WHERE state = '1' AND timestamp >= " + PlusEnvironment.GetGame().GetCatalog().GetMarketplace().FormatTimestampString()); if (MinCost >= 0) { builder.Append(" AND total_price > " + MinCost); } if (MaxCost >= 0) { builder.Append(" AND total_price < " + MaxCost); } switch (FilterMode) { case 1: str = "ORDER BY asking_price DESC"; break; default: str = "ORDER BY asking_price ASC"; break; } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `offer_id`,`item_type`,`sprite_id`,`total_price`,`limited_number`,`limited_stack` FROM `catalog_marketplace_offers` " + builder.ToString() + " " + str + " LIMIT 500"); dbClient.AddParameter("search_query", "%" + SearchQuery + "%"); if (SearchQuery.Length >= 1) { builder.Append(" AND `public_name` LIKE @search_query"); } table = dbClient.getTable(); } PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems.Clear(); PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Clear(); if (table != null) { foreach (DataRow row in table.Rows) { if (!PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Contains(Convert.ToInt32(row["offer_id"]))) { MarketOffer item = new MarketOffer(Convert.ToInt32(row["offer_id"]), Convert.ToInt32(row["sprite_id"]), Convert.ToInt32(row["total_price"]), int.Parse(row["item_type"].ToString()), Convert.ToInt32(row["limited_number"]), Convert.ToInt32(row["limited_stack"])); PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Add(Convert.ToInt32(row["offer_id"])); PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems.Add(item); } } } Dictionary <int, MarketOffer> dictionary = new Dictionary <int, MarketOffer>(); Dictionary <int, int> dictionary2 = new Dictionary <int, int>(); foreach (MarketOffer item in PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems) { if (dictionary.ContainsKey(item.SpriteId)) { if (dictionary[item.SpriteId].TotalPrice > item.TotalPrice) { dictionary.Remove(item.SpriteId); dictionary.Add(item.SpriteId, item); } int num = dictionary2[item.SpriteId]; dictionary2.Remove(item.SpriteId); dictionary2.Add(item.SpriteId, num + 1); } else { dictionary.Add(item.SpriteId, item); dictionary2.Add(item.SpriteId, 1); } } Session.SendMessage(new MarketPlaceOffersComposer(MinCost, MaxCost, dictionary, dictionary2)); }
/// <summary> /// Refresh the chats data e.g bans & mutes /// </summary> public void RefreshChatRoomData() { this.ChatValues.Clear(); this.BannedUsers.Clear(); this.MutedUsers.Clear(); this.ChatAdmins.Clear(); DataTable ChatRoomsData; DataRow TheChat; using (IQueryAdapter DB = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { DB.SetQuery("SELECT owner_id, password, locked, admins, gang_id from `rp_chat_rooms` WHERE name = @chatname"); DB.AddParameter("chatname", this.ChatName); TheChat = DB.getRow(); if (TheChat != null) { int OwnerID = Convert.ToInt32(TheChat["owner_id"]); int GangID = Convert.ToInt32(TheChat["gang_id"]); string Password = Convert.ToString(TheChat["password"]); this.ChatAdmins = (!String.IsNullOrEmpty(Convert.ToString(TheChat["admins"])) && Convert.ToString(TheChat["admins"]).Contains(":")) ? (Convert.ToString(TheChat["admins"]).StartsWith(":")) ? Convert.ToString(TheChat["admins"]).Remove(0, 1).Split(':').Select(int.Parse).ToList() : Convert.ToString(TheChat["admins"]).Split(':').Select(int.Parse).ToList() : new List <int>(); bool Locked = PlusEnvironment.EnumToBool(Convert.ToString(TheChat["locked"])); #region Refresh chat admins #endregion #region Refresh chat owner this.ChatOwner = OwnerID; #endregion #region Refresh chat password this.SetChatPassword(Password); #endregion #region Refresh gang id this.SetChatGang(GangID); #endregion #region Refresh locked this.SetLockStatus(Locked); #endregion } } using (IQueryAdapter DB = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { DB.SetQuery("SELECT * from `rp_chat_rooms_data` WHERE chat_name = @chatname"); DB.AddParameter("chatname", this.ChatName); ChatRoomsData = DB.getTable(); if (ChatRoomsData == null) { return; } foreach (DataRow ChatRoomData in ChatRoomsData.Rows) { string DataType = Convert.ToString(ChatRoomData["data_type"]); string DataValue = Convert.ToString(ChatRoomData["data_value"]); double DataExpire = Convert.ToDouble(ChatRoomData["data_timestamp_expire"]); if (DataExpire <= PlusEnvironment.GetUnixTimestamp()) { DB.RunQuery("DELETE FROM rp_chat_rooms_data WHERE data_type = '" + DataType + "' AND data_value = '" + DataValue + "'"); continue; } if (DataType == "ban") { this.InsertBanData(DataValue, DataExpire); } if (DataType == "mute") { this.InsertMuteData(DataValue, DataExpire); } } } }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { #region RETURN VALUES TargetedOffers offer = NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer; HabboHotel.Users.Habbo habbo = Session.GetHabbo(); if (offer == null || habbo == null) { Session.SendMessage(new PurchaseErrorComposer(1)); return; } #endregion #region FIELDS Packet.PopInt(); int amount = Packet.PopInt(); if (amount > offer.Limit) { Session.SendMessage(new PurchaseErrorComposer(1)); return; } int creditsCost = int.Parse(offer.Price[0]) * amount; int extraMoneyCost = int.Parse(offer.Price[1]) * amount; #endregion //#region CREDITS COST //if (creditsCost > 0) //{ // if (habbo.Credits < creditsCost) // { // Session.SendMessage(new PurchaseErrorComposer(1)); // return; // } // habbo.Credits -= creditsCost; // Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits - creditsCost)); //} //#endregion //#region EXTRA MONEY COST //if (extraMoneyCost > 0) //{ // #region GET MONEY TYPE AND DISCOUNT // switch (offer.MoneyType) // { // #region DUCKETS COST // case "duckets": // { // if (habbo.Duckets < extraMoneyCost) // { // Session.SendMessage(new PurchaseErrorComposer(1)); // return; // } // //habbo.Duckets -= extraMoneyCost; // Session.GetHabbo().Duckets -= extraMoneyCost; // Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Duckets)); // break; // } // #endregion // #region DIAMONDS COST // case "diamonds": // { // if (habbo.Diamonds < extraMoneyCost) // { // Session.SendMessage(new PurchaseErrorComposer(1)); // return; // } // //habbo.Diamonds -= extraMoneyCost; // Session.GetHabbo().Diamonds -= extraMoneyCost; // Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); // break; // } // #endregion // //#region OTHER COST // //default: // // goto case "duckets"; // // #endregion // } // #endregion // //habbo.UpdateExtraMoneyBalance(); //} //#endregion #region BUY AND CREATE ITEMS PROGRESS TargetedOffers TargetedOffer = NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer; using (IQueryAdapter dbQuery = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbQuery.SetQuery("SELECT targeted_buy FROM users where id = " + habbo.Id + " LIMIT 1"); DataTable count = dbQuery.getTable(); foreach (DataRow Row in count.Rows) { int offer2 = Convert.ToInt32(Row["targeted_buy"]); if (TargetedOffer.Limit == offer2) { Session.SendMessage(new RoomCustomizedAlertComposer("Ya has pasado el limite de compras de esta Oferta.")); } else { using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE users SET targeted_buy = targeted_buy +1 WHERE id = " + Session.GetHabbo().Id + ";"); } foreach (TargetedItems product in offer.Products) { #region CHECK PRODUCT TYPE switch (product.ItemType) { #region NORMAL ITEMS CASE case "item": { if (!NeonEnvironment.GetGame().GetItemManager().GetItem(int.Parse(product.Item), out ItemData item)) { return; } if (item == null) { return; } Item cItem = ItemFactory.CreateSingleItemNullable(item, Session.GetHabbo(), string.Empty, string.Empty); if (cItem != null) { Session.GetHabbo().GetInventoryComponent().TryAddItem(cItem); Session.SendMessage(new FurniListAddComposer(cItem)); Session.SendMessage(new FurniListUpdateComposer()); } Session.GetHabbo().GetInventoryComponent().UpdateItems(true); break; } #endregion #region BADGE CASE case "badge": { if (habbo.GetBadgeComponent().HasBadge(product.Item)) { //Session.SendMessage(new RoomCustomizedAlertComposer("mira men ahi te pudras joder")); //break; } habbo.GetBadgeComponent().GiveBadge(product.Item, true, Session); break; } #endregion } #endregion } } } } #endregion #region CREDITS COST if (creditsCost > 0) { if (habbo.Credits < creditsCost) { Session.SendMessage(new PurchaseErrorComposer(1)); return; } habbo.Credits -= creditsCost; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits - creditsCost)); } #endregion #region EXTRA MONEY COST if (extraMoneyCost > 0) { #region GET MONEY TYPE AND DISCOUNT switch (offer.MoneyType) { #region DUCKETS COST case "duckets": { if (habbo.Duckets < extraMoneyCost) { Session.SendMessage(new PurchaseErrorComposer(1)); return; } //habbo.Duckets -= extraMoneyCost; Session.GetHabbo().Duckets -= extraMoneyCost; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Duckets)); break; } #endregion #region DIAMONDS COST case "diamonds": { if (habbo.Diamonds < extraMoneyCost) { Session.SendMessage(new PurchaseErrorComposer(1)); return; } //habbo.Diamonds -= extraMoneyCost; Session.GetHabbo().Diamonds -= extraMoneyCost; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); break; } #endregion //#region OTHER COST //default: // goto case "duckets"; // #endregion } #endregion //habbo.UpdateExtraMoneyBalance(); } #endregion #region RE-OPEN TARGETED BOX TargetedOffers TargetedOffer2 = NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer; int offer22 = Session.GetHabbo()._TargetedBuy; if (TargetedOffer2.Limit > offer22) { Session.SendMessage(NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize()); } }