public void AchievementUnlocked(string achievement, int level) { if (this.AchievementLevels.ContainsKey(achievement)) { this.AchievementLevels[achievement] = level; using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", this.Habbo.ID); dbClient.AddParamWithValue("group", achievement); dbClient.AddParamWithValue("level", level); dbClient.ExecuteQuery("UPDATE user_achievements SET achievement_level = @level WHERE user_id = @userId AND achievement_group = @group LIMIT 1"); } } else { this.AchievementLevels.Add(achievement, level); using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", this.Habbo.ID); dbClient.AddParamWithValue("group", achievement); dbClient.AddParamWithValue("level", level); dbClient.ExecuteQuery("INSERT INTO user_achievements(user_id, achievement_group, achievement_level) VALUES(@userId, @group, @level)"); } } }
public void Handle(GameClient session, ClientMessage message) { Room room = session.GetHabbo().GetRoomSession().GetRoom(); if (room != null) { uint petId = message.PopWiredUInt(); RoomPet pet = room.RoomUserManager.GetPetByID(petId); if (pet != null && pet.PetData != null && session.GetHabbo().GetUserStats().DailyPetRespectPoints > 0) { session.GetHabbo().GetUserStats().DailyPetRespectPoints--; session.GetHabbo().GetUserStats().PetRespectGiven++; pet.OnRespect(); using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", session.GetHabbo().ID); dbClient.AddParamWithValue("petRespect", session.GetHabbo().GetUserStats().DailyPetRespectPoints); dbClient.AddParamWithValue("petRespectGiven", session.GetHabbo().GetUserStats().PetRespectGiven); dbClient.ExecuteQuery("UPDATE user_stats SET daily_pet_respect_points = @petRespect, pet_respect_given = @petRespectGiven WHERE user_id = @userId LIMIT 1"); } session.GetHabbo().GetUserAchievements().CheckAchievement("PetRespectGiven"); } } }
public void PushRoomChatlogToDB() { if (this.RoomMessagesInsertNeeded.Count > 0) { StringBuilder query = new StringBuilder(); using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { int i = 0; RoomMessage message; while (this.RoomMessagesInsertNeeded.TryDequeue(out message)) { i++; //needed so params works correctly dbClient.AddParamWithValue("userId" + i, message.UserID); dbClient.AddParamWithValue("userName" + i, message.Username); dbClient.AddParamWithValue("roomId" + i, message.RoomID); dbClient.AddParamWithValue("timestamp" + i, message.Timestamp); dbClient.AddParamWithValue("message" + i, message.Message); dbClient.AddParamWithValue("userSessionId" + i, message.UserSessionID); query.Append("INSERT INTO chatlogs_rooms(user_id, user_name, room_id, timestamp, message, user_session_id) VALUES(@userId" + i + ", @userName" + i + ", @roomId" + i + ", @timestamp" + i + ", @message" + i + ", @userSessionId" + i + "); "); } if (query.Length > 0) { dbClient.ExecuteQuery(query.ToString()); } } } }
public void LoadMore() { this.RoomSession = new RoomSession(this.ID, this); this.CommandCache = new CommandCache(this.ID, this); this.UserStats = new UserStats(this.ID); if (!this.UserStats.Fill(this.GetUserDataFactory().GetUserStats())) { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", this.ID); dbClient.ExecuteQuery("INSERT INTO user_stats(user_id) VALUES(@userId)"); } } this.UserAchievements = new UserAchievements(this); this.InventoryManager = new InventoryManager(this.GetSession(), this.GetUserDataFactory()); this.SubscriptionManager = new SubscriptionManager(this.ID, this, this.GetUserDataFactory()); this.WardrobeManager = new WardrobeManager(this.ID, this, this.GetUserDataFactory()); this.BadgeManager = new BadgeManager(this.ID, this, this.GetUserDataFactory()); this.LoadFavouriteRooms(); this.LoadRooms(); this.LoadTags(); this.LoadIgnores(); this.LoadPets(); }
public override void OnPlace(GameClient session) { DataRow dataRow = null; using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("itemId", this.ID); dataRow = dbClient.ReadDataRow("SELECT data FROM items_data WHERE item_id = @itemId LIMIT 1"); } if (dataRow != null) { if (!int.TryParse((string)dataRow["data"], out this.Charges)) { this.Charges = 0; } } if (this.Charges > 0) { this.ExtraData = "1"; } else { this.ExtraData = "0"; } }
public ServerMessage SerializeUserInfo(uint userId) { DataRow dataRow = null; GameClient target = Skylight.GetGame().GetGameClientManager().GetGameClientById(userId); if (target != null && target.GetHabbo() != null) { dataRow = target.GetHabbo().GetUserDataFactory().GetUserData(); } else { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", userId); dataRow = dbClient.ReadDataRow("SELECT username, account_created, last_online, ip_last FROM users WHERE id = @userId LIMIT 1"); } } ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message.Init(r63aOutgoing.ModToolUserInfo); message.AppendUInt(userId); message.AppendString((string)dataRow["username"]); message.AppendInt32((int)Math.Ceiling((TimeUtilies.GetUnixTimestamp() - (double)dataRow["account_created"]) / 60.0)); //minutes since account created message.AppendInt32((int)Math.Ceiling((TimeUtilies.GetUnixTimestamp() - (double)dataRow["last_online"]) / 60.0)); //minutes since last login message.AppendBoolean(target != null); message.AppendInt32(this.SupportTickets.Values.Where(t => t.SenderID == userId).Count()); //cfhs message.AppendInt32(this.SupportTickets.Values.Where(t => t.Status == SupportTicketStatus.Abusive && t.SenderID == userId).Count()); //cfhs abusive message.AppendInt32(Skylight.GetGame().GetCautionManager().GetCauctionsByUserID(userId)); //cauctions message.AppendInt32(Skylight.GetGame().GetBanManager().GetBanCountByUserID(userId)); //bans return(message); }
public void SaveAll() { StringBuilder query = new StringBuilder(); using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { foreach (RoomPet pet in this.RoomUsers.Get(typeof(RoomPet))) { if (pet.PetData.NeedUpdate) { dbClient.AddParamWithValue("petId" + pet.PetData.ID, pet.PetData.ID); dbClient.AddParamWithValue("roomId" + pet.PetData.ID, this.Room.ID); dbClient.AddParamWithValue("expirience" + pet.PetData.ID, pet.PetData.Expirience); dbClient.AddParamWithValue("energy" + pet.PetData.ID, pet.PetData.Energy); dbClient.AddParamWithValue("happiness" + pet.PetData.ID, pet.PetData.Happiness); dbClient.AddParamWithValue("respect" + pet.PetData.ID, pet.PetData.Respect); dbClient.AddParamWithValue("x" + pet.PetData.ID, pet.X); dbClient.AddParamWithValue("y" + pet.PetData.ID, pet.Y); dbClient.AddParamWithValue("z" + pet.PetData.ID, pet.Z); query.Append("UPDATE user_pets SET room_id = @roomId" + pet.PetData.ID + ", expirience = @expirience" + pet.PetData.ID + ", energy = @energy" + pet.PetData.ID + ", happiness = @happiness" + pet.PetData.ID + ", respect = @respect" + pet.PetData.ID + ", x = @x" + pet.PetData.ID + ", y = @y" + pet.PetData.ID + ", z = @z" + pet.PetData.ID + " WHERE id = @petId" + pet.PetData.ID + " LIMIT 1; "); } } if (query.Length > 0) { dbClient.ExecuteQuery(query.ToString()); } } }
public void AddSubscription(string subscription, double secounds) { //pretty sure we don't want do that on here if (secounds <= 0) { return; } if (this.Subscriptions.ContainsKey(subscription)) { foreach (Subscription subscription_ in this.Subscriptions[subscription]) { if (subscription_.IsActive()) { subscription_.Expand(secounds); using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("id", subscription_.ID); dbClient.AddParamWithValue("expires", subscription_.GetExpires()); dbClient.ExecuteQuery("UPDATE user_subscriptions SET subscription_expires = @expires WHERE id = @id LIMIT 1;"); } return; } } } //it we didint found active sub int id = 0; double started = TimeUtilies.GetUnixTimestamp(); double expires = started + secounds; using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", this.ID); dbClient.AddParamWithValue("subscription", subscription); dbClient.AddParamWithValue("started", started); dbClient.AddParamWithValue("expires", expires); id = (int)dbClient.ExecuteQuery("INSERT INTO user_subscriptions(user_id, subscription_name, subscription_started, subscription_expires) VALUES(@userId, @subscription, @started, @expires)"); } if (id > 0) //lets do it for sure :/ { Subscription newSub = new Subscription(id, subscription, started, expires); if (!this.Subscriptions.ContainsKey(subscription)) { this.Subscriptions.Add(subscription, new List <Subscription> { newSub }); } else { this.Subscriptions[subscription].Add(newSub); } } }
public void PushRoomvisitsToDB() { StringBuilder query = new StringBuilder(); using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { int i = 0; Roomvisit roomvisit; while (this.RoomvisitsInsertNeeded.TryDequeue(out roomvisit)) { i++; //needed so params works correctly dbClient.AddParamWithValue("userId" + i, roomvisit.UserID); dbClient.AddParamWithValue("roomId" + i, roomvisit.RoomID); dbClient.AddParamWithValue("entryTimestamp" + i, roomvisit.EntryTimestamp); query.Append("INSERT INTO user_roomvisits(user_id, room_id, entry_timestamp) VALUES(@userId" + i + ", @roomId" + i + ", @entryTimestamp" + i + "); "); } if (query.Length > 0) { dbClient.ExecuteQuery(query.ToString()); } } }
public void Handle(GameClient session, ClientMessage message) { uint roomId = message.PopWiredUInt(); Room room = session.GetHabbo().GetRoomSession().GetRoom(); if (room != null && room.HaveOwnerRights(session)) { Skylight.GetGame().GetRoomManager().UnloadRoom(room); using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("roomId", room.ID); dbClient.ExecuteQuery("DELETE FROM rooms WHERE id = @roomId LIMIT 1"); dbClient.ExecuteQuery("DELETE FROM user_favorites WHERE room_id = @roomId"); dbClient.ExecuteQuery("DELETE FROM room_rights WHERE room_id = @roomId"); dbClient.ExecuteQuery("UPDATE items SET room_id = '0' WHERE room_id = @roomId"); dbClient.ExecuteQuery("UPDATE users SET home_room = '0' WHERE home_room = @roomId"); dbClient.ExecuteQuery("UPDATE users SET newbie_status = '2', newbie_room = '0' WHERE newbie_room = @roomId"); dbClient.ExecuteQuery("UPDATE user_pets SET room_id = '0' WHERE room_id = @roomId"); } session.GetHabbo().LoadRooms(); session.GetHabbo().GetInventoryManager().UpdateInventoryItems(true); session.GetHabbo().GetInventoryManager().UpdateInventryPets(true); session.SendMessage(Skylight.GetGame().GetNavigatorManager().GetMyRooms(session)); } }
public List <Roomvisit> GetRoomvisits(uint userId) { List <Roomvisit> roomvisits = null; if (!this.Roomvisits.TryGetValue(userId, out roomvisits)) { //not even loaded roomvisits = new List <Roomvisit>(); DataTable visits = null; using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", userId); visits = dbClient.ReadDataTable("SELECT user_id, room_id, entry_timestamp FROM user_roomvisits ORDER BY entry_timestamp DESC LIMIT 50"); } if (visits != null && visits.Rows.Count > 0) { foreach (DataRow dataRow in visits.Rows) { roomvisits.Add(new Roomvisit((uint)dataRow["user_id"], (uint)dataRow["room_id"], (double)dataRow["entry_timestamp"])); } } this.Roomvisits.TryAdd(userId, roomvisits); } return(roomvisits); }
public void UpdateActivityPoints(int type, bool save) { if (type == -1) { foreach (int id in this.ActivityPoints.Keys.ToList()) { this.HandleActivityPointsUpdate(id); } } else { this.HandleActivityPointsUpdate(type); } if (save) { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("activityPoints", CurrenceUtilies.ActivityPointsToString(this.ActivityPoints)); dbClient.AddParamWithValue("userId", this.ID); dbClient.ExecuteQuery("UPDATE users SET activity_points = @activityPoints WHERE id = @userId LIMIT 1"); } } }
public void HandleDisconnection() { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", this.ID); dbClient.AddParamWithValue("timestamp", TimeUtilies.GetUnixTimestamp()); dbClient.AddParamWithValue("activityPointsUpdate", this.ActivityPointsLastUpdate); dbClient.AddParamWithValue("volume", string.Join(",", this.UserSettings.Volume)); dbClient.AddParamWithValue("preferOldChat", this.GetUserSettings().PreferOldChat ? "1" : "0"); dbClient.AddParamWithValue("blockRoomInvites", this.GetUserSettings().BlockRoomInvites ? "1" : "0"); dbClient.AddParamWithValue("blockCameraFollow", this.GetUserSettings().BlockCameraFollow ? "1" : "0"); dbClient.AddParamWithValue("chatColor", this.GetUserSettings().ChatColor); dbClient.AddParamWithValue("look", this.Look); dbClient.AddParamWithValue("gender", this.Gender); dbClient.AddParamWithValue("guideEnrollmentTimestamp", this.GuideEnrollmentTimestamp); dbClient.ExecuteQuery("UPDATE users SET online = '0', last_online = @timestamp, activity_points_lastupdate = @activityPointsUpdate, volume = @volume, prefer_old_chat = @preferOldChat, block_room_invites = @blockRoomInvites, block_camera_follow = @blockCameraFollow, chat_color = @chatColor, look = @look, gender = @gender, guide_enrollment_timestamp = @guideEnrollmentTimestamp WHERE id = @userId"); } this.UserStats?.Disconnect(); this.RoomSession?.HandleDisconnection(); this.HabboMessenger?.UpdateAllFriends(true); this.InventoryManager?.SavePetData(); Skylight.GetGame().GetGuideManager().Disconnect(this.Session); }
public void Handle(GameClient session, ClientMessage message) { if (session != null && session.GetHabbo() != null) { RoomUnit roomUser = session.GetHabbo().GetRoomSession().GetRoomUser(); if (roomUser != null) { string motto = TextUtilies.FilterString(message.PopFixedString()); if (!TextUtilies.HaveBlacklistedWords(motto)) { session.GetHabbo().Motto = motto; using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", session.GetHabbo().ID); dbClient.AddParamWithValue("motto", motto); dbClient.ExecuteQuery("UPDATE users SET motto = @motto WHERE id = @userId LIMIT 1"); if (session.GetHabbo().GetUserSettings().FriendStream) { dbClient.ExecuteQuery("INSERT INTO user_friend_stream(type, user_id, timestamp, extra_data) VALUES('3', @userId, UNIX_TIMESTAMP(), @motto)"); } } session.SendMessage(OutgoingPacketsEnum.UpdateUser, new ValueHolder("VirtualID", -1, "Look", session.GetHabbo().Look, "Gender", session.GetHabbo().Gender, "Motto", session.GetHabbo().Motto, "AchievementPoints", session.GetHabbo().GetUserStats().AchievementPoints)); roomUser.Room.SendToAll(OutgoingPacketsEnum.UpdateUser, new ValueHolder("VirtualID", roomUser.VirtualID, "Look", session.GetHabbo().Look, "Gender", session.GetHabbo().Gender, "Motto", session.GetHabbo().Motto, "AchievementPoints", session.GetHabbo().GetUserStats().AchievementPoints)); Skylight.GetGame().GetAchievementManager().AddAchievement(session, "ChangeMotto", 1); } } } }
public uint GetIDByUsername(string username) { if (this.CachedIDs.ContainsKey(username)) { return(this.CachedIDs[username]); } else { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("username", username); DataRow idRow = dbClient.ReadDataRow("SELECT id FROM users WHERE username = @username LIMIT 1"); if (idRow != null) { uint id = (uint)idRow["id"]; this.UpdateCachedID(id, username); this.UpdateCachedUsername(id, username); return(id); } else { return(0); } } } }
public void Handle(GameClient session, ClientMessage message) { if (session != null && session.GetHabbo() != null) { List <uint> redeemOffers = new List <uint>(); int credits = 0; foreach (MarketplaceOffer offer in Skylight.GetGame().GetCatalogManager().GetMarketplaceManager().GetOffersByUserID(session.GetHabbo().ID)) { if (!offer.Redeem && offer.Sold) { offer.Redeem = true; credits += offer.Price; redeemOffers.Add(offer.ID); } } using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.ExecuteQuery("UPDATE catalog_marketplace_offers SET redeem = '1' WHERE id IN(" + string.Join(",", redeemOffers) + ") LIMIT " + redeemOffers.Count); } session.GetHabbo().Credits += credits; session.GetHabbo().UpdateCredits(true); } }
public string GetUsernameByID(uint id) { if (this.CachedUsernames.ContainsKey(id)) { return(this.CachedUsernames[id]); } else { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userid", id); DataRow usernameRow = dbClient.ReadDataRow("SELECT username FROM users WHERE id = @userid LIMIT 1"); if (usernameRow != null) { string username = (string)usernameRow["username"]; this.UpdateCachedUsername(id, username); this.UpdateCachedID(id, username); return(username); } else { return(null); } } } }
public override bool OnUse(GameClient session, string[] args) { if (session.GetHabbo().HasPermission("cmd_update_catalog")) { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { Skylight.GetGame().GetCatalogManager().LoadCatalogItems(dbClient); Skylight.GetGame().GetCatalogManager().LoadCatalogPages(dbClient); Skylight.GetGame().GetCatalogManager().LoadPetRaces(dbClient); Skylight.GetGame().GetCatalogManager().LoadPresents(dbClient); } ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message.Init(r63aOutgoing.UpdateCatalog); byte[] data = message.GetBytes(); foreach (GameClient session_ in Skylight.GetGame().GetGameClientManager().GetClients()) { session_.SendData(data); } return(true); } else { return(false); } }
public void SavePetData() { string query = ""; using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { foreach (Pet pet in this.Pets.Values.ToList()) { if (pet.NeedUpdate) { dbClient.AddParamWithValue("petId" + pet.ID, pet.ID); dbClient.AddParamWithValue("expirience" + pet.ID, pet.Expirience); dbClient.AddParamWithValue("energy" + pet.ID, pet.Energy); dbClient.AddParamWithValue("happiness" + pet.ID, pet.Happiness); dbClient.AddParamWithValue("respect" + pet.ID, pet.Respect); query += "UPDATE user_pets SET room_id = '0', expirience = @expirience" + pet.ID + ", energy = @energy" + pet.ID + ", happiness = @happiness" + pet.ID + ", respect = @respect" + pet.ID + ", x = '0', y = '0', z = '0' WHERE id = @petId" + pet.ID + " LIMIT 1; "; } if (query.Length > 0) { dbClient.ExecuteQuery(query); } } } }
public void Handle(GameClient session, ClientMessage message) { Room room = session.GetHabbo().GetRoomSession().GetRoom(); if (room != null) { string username = message.PopFixedString(); RoomUnitUser user = room.RoomUserManager.GetUserByName(username); if (user != null && !user.Session.GetHabbo().HasPermission("acc_unignorable")) { uint userId = user.Session.GetHabbo().ID; if (!session.GetHabbo().IgnoredUsers.Contains(userId)) { session.GetHabbo().IgnoredUsers.Add(userId); using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", session.GetHabbo().ID); dbClient.AddParamWithValue("targetId", userId); dbClient.ExecuteQuery("INSERT INTO user_ignores(user_id, ignored_id) VALUES(@userId, @targetId)"); } ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.IgnoreStatus); message_.AppendInt32(1); session.SendMessage(message_); } } } }
public void LoadItems() { DataTable inventoryItems = null; using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userid", this.Session.GetHabbo().ID); inventoryItems = dbClient.ReadDataTable("SELECT id, base_item, extra_data FROM items WHERE room_id = 0 AND user_id = @userid"); } this.FloorItems.Clear(); this.WallItems.Clear(); if (inventoryItems != null && inventoryItems.Rows.Count > 0) { foreach (DataRow dataRow in inventoryItems.Rows) { InventoryItem item = new InventoryItem((uint)dataRow["id"], (uint)dataRow["base_item"], (string)dataRow["extra_data"]); if (item.GetItem().IsWallItem) { this.WallItems.Add(item.ID, item); } else { this.FloorItems.Add(item.ID, item); } } } }
public void CallForHelp(GameClient session, string issue, int topic, uint reportedId) { uint roomId = session.GetHabbo().GetRoomSession().CurrentRoomID; string roomName = ""; if (roomId > 0) { roomName = session.GetHabbo().GetRoomSession().CurrentRoomRoomUser.Room.RoomData.Name; } double timestamp = TimeUtilies.GetUnixTimestamp(); uint ticketId = 0; using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("score", 1); dbClient.AddParamWithValue("type", topic); dbClient.AddParamWithValue("senderId", session.GetHabbo().ID); dbClient.AddParamWithValue("reportedId", reportedId); dbClient.AddParamWithValue("message", issue); dbClient.AddParamWithValue("roomId", roomId); dbClient.AddParamWithValue("roomName", roomName); dbClient.AddParamWithValue("timestamp", timestamp); ticketId = (uint)dbClient.ExecuteQuery("INSERT INTO moderation_tickets(score, type, status, sender_id, reported_id, picker_id, message, room_id, room_name, timestamp) VALUES(@score, @type, 'open', @senderId, @reportedId, '0', @message, @roomId, @roomName, @timestamp)"); } if (ticketId > 0) { SupportTicket ticket = new SupportTicket(ticketId, 1, topic, SupportTicketStatus.Open, session.GetHabbo().ID, reportedId, 0, issue, roomId, roomName, timestamp); this.SupportTickets.Add(ticketId, ticket); this.SerializeSupportTicketToMods(ticket); } }
public void UpdateSlot(int slotID, string gender, string look) { WardrobeSlot slot = this.TryGetSlot(slotID); if (slot != null) { slot.Gender = gender; slot.Look = look; using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", this.HabboID); dbClient.AddParamWithValue("slotId", slotID); dbClient.AddParamWithValue("gender", gender); dbClient.AddParamWithValue("look", look); dbClient.ExecuteQuery("UPDATE user_wardrobe SET gender = @gender, look = @look WHERE user_id = @userId AND slot_id = @slotId LIMIT 1"); } } else { this.WardrobeItems.Add(slotID, new WardrobeSlot(slotID, gender, look)); using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", this.HabboID); dbClient.AddParamWithValue("slotId", slotID); dbClient.AddParamWithValue("gender", gender); dbClient.AddParamWithValue("look", look); dbClient.ExecuteQuery("INSERT INTO user_wardrobe(user_id, slot_id, gender, look) VALUES(@userId, @slotId, @gender, @look)"); } } }
public void PushPrivateChatlogToDB() { if (this.PrivateMessagesInsertNeeded.Count > 0) { StringBuilder query = new StringBuilder(); using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { int i = 0; PrivateMessage message; while (this.PrivateMessagesInsertNeeded.TryDequeue(out message)) { i++; //needed so params works correctly dbClient.AddParamWithValue("senderId" + i, message.SenderID); dbClient.AddParamWithValue("senderUsername" + i, message.SenderUsername); dbClient.AddParamWithValue("receiverId" + i, message.ReceiverID); dbClient.AddParamWithValue("receiverUsername" + i, message.ReceiverUsername); dbClient.AddParamWithValue("timestamp" + i, message.Timestamp); dbClient.AddParamWithValue("message" + i, message.Message); dbClient.AddParamWithValue("senderSessionId" + i, message.SenderSessionID); dbClient.AddParamWithValue("receiverSessionId" + i, message.ReceiverSessionID); dbClient.AddParamWithValue("extraData" + i, message.ExtraData); query.Append("INSERT INTO chatlogs_private(sender_id, sender_name, receiver_id, receiver_name, timestamp, message, sender_session_id, receiver_session_id, extra_data) VALUES(@senderId" + i + ", @senderUsername" + i + ", @receiverId" + i + ", @receiverUsername" + i + ", @timestamp" + i + ", @message" + i + ", @senderSessionId" + i + ", @receiverSessionId" + i + ", @extraData" + i + "); "); } if (query.Length > 0) { dbClient.ExecuteQuery(query.ToString()); } } } }
public virtual void Handle(GameClient session, ClientMessage message) { if (session?.GetHabbo()?.GetMessenger() != null) { uint adderId = session.GetHabbo().ID; bool adderFriendStreamEnabled = session.GetHabbo().GetUserSettings().FriendStream; StringBuilder query = new StringBuilder(); foreach (uint userId in this.FriendRequests) { session.GetHabbo().GetMessenger().AddFriendToBoth(userId); query.Append("DELETE FROM messenger_requests WHERE (to_id = '" + adderId + "' AND from_id = '" + userId + "') OR (to_id = '" + userId + "' AND from_id = '" + adderId + "') LIMIT 2; "); query.Append("INSERT INTO messenger_friends (user_one_id,user_two_id) VALUES (" + adderId + "," + userId + "); "); query.Append("INSERT INTO user_friend_stream(type, user_id, timestamp, extra_data) SELECT '0', '" + userId + "', UNIX_TIMESTAMP(), '" + adderId + "' FROM users WHERE id = '" + userId + "' AND friend_stream = '1'; "); if (adderFriendStreamEnabled) { query.Append("INSERT INTO user_friend_stream(type, user_id, timestamp, extra_data) VALUES('0', " + adderId + ", UNIX_TIMESTAMP(), " + userId + "); "); } } if (query.Length > 0) { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.ExecuteQuery(query.ToString()); } } } }