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 void Handle(GameClient session, ClientMessage message) { string name = message.PopFixedString(); int type = message.PopWiredInt32(); if (name.Length >= 2) { if (name.Length <= 16) { Regex regex = new Regex(@"^[A-Z0-9_-]+$", RegexOptions.IgnoreCase); foreach (char char_ in name) { if (!regex.IsMatch(char_.ToString())) { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidatePetNameResult); message_.AppendInt32(3); //0 = valid, 1 = too long, 2 = too short, 3 = forbidden cheracters, 4 = forbidden words message_.AppendString(char_.ToString()); session.SendMessage(message_); return; //we don't want continue :( } } if (TextUtilies.HaveBlacklistedWords(name)) { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidatePetNameResult); message_.AppendInt32(4); //0 = valid, 1 = too long, 2 = too short, 3 = forbidden cheracters, 4 = forbidden words message_.AppendString(""); //show the forbidden word session.SendMessage(message_); } else //let the user buy it { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidatePetNameResult); message_.AppendInt32(0); //0 = valid, 1 = too long, 2 = too short, 3 = forbidden cheracters, 4 = forbidden words message_.AppendString(""); //show the forbidden word session.SendMessage(message_); } } else { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidatePetNameResult); message_.AppendInt32(1); //0 = valid, 1 = too long, 2 = too short, 3 = forbidden cheracters, 4 = forbidden words message_.AppendString("16"); session.SendMessage(message_); } } else { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidatePetNameResult); message_.AppendInt32(2); //0 = valid, 1 = too long, 2 = too short, 3 = forbidden cheracters, 4 = forbidden words message_.AppendString("2"); session.SendMessage(message_); } }
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)"); } } ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.UpdateUser); message_.AppendInt32(-1); message_.AppendString(session.GetHabbo().Look); message_.AppendString(session.GetHabbo().Gender.ToLower()); message_.AppendString(session.GetHabbo().Motto); message_.AppendInt32(session.GetHabbo().GetUserStats().AchievementPoints); session.SendMessage(message_); ServerMessage message_2 = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_2.Init(r63aOutgoing.UpdateUser); message_2.AppendInt32(roomUser.VirtualID); message_2.AppendString(session.GetHabbo().Look); message_2.AppendString(session.GetHabbo().Gender.ToLower()); message_2.AppendString(session.GetHabbo().Motto); message_2.AppendInt32(session.GetHabbo().GetUserStats().AchievementPoints); roomUser.Room.SendToAll(message_2); Skylight.GetGame().GetAchievementManager().AddAchievement(session, "ChangeMotto", 1); } } } }
public void Handle(GameClient session, ClientMessage message) { if (session.FlagmeCommandUsed) { if (session.GetHabbo().HasPermission("cmd_flagme")) { string username = TextUtilies.FilterString(message.PopFixedString()); if (username.Length < 3) //to short { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidUsername); message_.AppendInt32(2); //result message_.AppendString(username); message_.AppendInt32(0); //suggested names session.SendMessage(message_); } else if (username.Length > 15) // too long { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidUsername); message_.AppendInt32(3); //result message_.AppendString(username); message_.AppendInt32(0); //suggested names session.SendMessage(message_); } else if (username.Contains(" ") || !Regex.IsMatch(username, "^[-a-zA-Z0-9._:,]+$") || TextUtilies.HaveBlacklistedWords(username)) //invalid name { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidUsername); message_.AppendInt32(4); //result message_.AppendString(username); message_.AppendInt32(0); //suggested names session.SendMessage(message_); } else if (Skylight.GetGame().GetGameClientManager().UsernameExits(username)) //name already exits { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidUsername); message_.AppendInt32(5); //result message_.AppendString(username); message_.AppendInt32(0); //suggested names session.SendMessage(message_); } else { //CHANGE THE DAMN NAME session.FlagmeCommandUsed = false; using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", session.GetHabbo().ID); dbClient.AddParamWithValue("userName", session.GetHabbo().Username); dbClient.AddParamWithValue("command", "flagme"); dbClient.AddParamWithValue("extraData", "Old username: "******" | New username: "******"timestamp", TimeUtilies.GetUnixTimestamp()); dbClient.AddParamWithValue("userSessionId", session.SessionID); dbClient.ExecuteQuery("INSERT INTO cmdlogs(user_id, user_name, command, extra_data, timestamp, user_session_id) VALUES (@userId, @userName, @command, @extraData, @timestamp, @userSessionId)"); dbClient.AddParamWithValue("newUserName", username); dbClient.ExecuteQuery("UPDATE users SET username = @newUserName WHERE id = @userId LIMIT 1"); } foreach (Room room in Skylight.GetGame().GetRoomManager().GetLoadedRooms()) { if (room.RoomData.OwnerID == session.GetHabbo().ID) { Skylight.GetGame().GetRoomManager().UnloadRoom(room); } } session.GetHabbo().Username = username; Skylight.GetGame().GetAchievementManager().AddAchievement(session, "ChangeName", 1); session.Stop("Name changed"); } } } else { } }
public void BuyItem(GameClient session, int pageId, uint itemId, string extraData, int amountMultiplayer, bool asGift, string receiverUsername = "", string giftMessage = "", int giftSpriteId = 0, int giftBoxId = 0, int giftRibbonId = 0) { CatalogPage page = this.GetCatalogPage(pageId); if (page != null && page.Visible & page.Enabled && page.MinRank <= session.GetHabbo().Rank) { CatalogItem item = page.GetItem(itemId); if (item != null) { if (item.IsDeal) { if (amountMultiplayer > 1) { session.SendNotif("You can't buy multiple deals at once!"); return; } } Tuple <Item, int>[] products = item.GetItems(); uint giftReceiverId = 0; if (asGift) { foreach (Tuple <Item, int> data in products) { if (!data.Item1.AllowGift) { return; } } giftReceiverId = Skylight.GetGame().GetGameClientManager().GetIDByUsername(receiverUsername); if (giftReceiverId == 0) //not valid user { ServerMessage receiverNotFound = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); receiverNotFound.Init(r63aOutgoing.GiftReceiverNotFound); session.SendMessage(receiverNotFound); return; } } if (amountMultiplayer > 1 && products[0].Item2 * amountMultiplayer > 100) { session.SendNotif("You can't buy more then 100 at once with the buy command"); return; } int finalCredits = item.CostCredits * amountMultiplayer; int finalPixels = item.CostActivityPoints * amountMultiplayer; if (asGift && giftSpriteId > 0) //special gifts costs one credit more { finalCredits++; } bool noCredits = false; bool noActivityPoints = false; if (session.GetHabbo().Credits < finalCredits) { noCredits = true; } if (session.GetHabbo().TryGetActivityPoints(item.ActivityPointsType) < finalPixels) { noActivityPoints = true; } if (noCredits || noActivityPoints) { ServerMessage noEnoughtCash = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); noEnoughtCash.Init(r63aOutgoing.NoEnoughtCash); noEnoughtCash.AppendBoolean(noCredits); noEnoughtCash.AppendBoolean(noActivityPoints); session.SendMessage(noEnoughtCash); } else { if (asGift) { foreach (Tuple <Item, int> data in products) { if (data.Item1.Type == "e") { session.SendNotif("You can not send this item as a gift."); return; } } } if (!item.IsDeal) { switch (products[0].Item1.InteractionType.ToLower()) { case "pet": { string[] data = extraData.Split('\n'); string petName = data[0]; int petRace = int.Parse(data[1]); string color = data[2]; Regex regex = new Regex(@"^[A-Z0-9_-]+$", RegexOptions.IgnoreCase); if (petName.Length >= 2 && petName.Length <= 16 && regex.IsMatch(petName) && !TextUtilies.HaveBlacklistedWords(petName)) { //buy } else { return; } if (color.Length != 6) { return; } break; } case "roomeffect": { extraData = TextUtilies.DoubleWithDotDecimal(double.Parse(extraData)); } break; case "postit": { extraData = "FFFF33"; //if you leave extra data empty same result, but for sure } break; case "dimmer": { extraData = "1,1,1,#000000,255"; //current mode } break; case "trophy": { extraData = session.GetHabbo().ID.ToString() + (char)9 + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + (char)9 + TextUtilies.FilterString(extraData, false, true); } break; default: { extraData = ""; break; } } } if (finalCredits > 0) { session.GetHabbo().Credits -= finalCredits; session.GetHabbo().UpdateCredits(true); } if (finalPixels > 0) { session.GetHabbo().RemoveActivityPoints(item.ActivityPointsType, finalPixels); session.GetHabbo().UpdateActivityPoints(item.ActivityPointsType, true); } session.SendMessage(BasicUtilies.GetRevisionPacketManager(session.Revision).GetOutgoing(OutgoingPacketsEnum.BuyInfo).Handle(new ValueHolder("Item", item, "Products", products, "Credits", finalCredits, "Pixels", finalPixels))); if (asGift) { Item gift = this.GetGiftLook(giftSpriteId); using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { string giftData = TextUtilies.FilterString(giftMessage, false, true) + (char)9 + session.GetHabbo().ID + (char)9 + giftBoxId + (char)9 + giftRibbonId; dbClient.AddParamWithValue("giftData", giftData); dbClient.AddParamWithValue("receiverId", giftReceiverId); dbClient.AddParamWithValue("giftBaseItem", gift.ID); uint giftItemId = (uint)dbClient.ExecuteQuery("INSERT INTO items(user_id, base_item, extra_data) VALUES(@receiverId, @giftBaseItem, @giftData)"); string baseItems = ""; string amounts = ""; foreach (Tuple <Item, int> data in products) { if (baseItems.Length > 0) { baseItems += ","; amounts += ","; } baseItems += data.Item1.ID; amounts += data.Item2 * amountMultiplayer; } dbClient.AddParamWithValue("itemId", giftItemId); dbClient.AddParamWithValue("baseItems", baseItems); dbClient.AddParamWithValue("amounts", amounts); dbClient.AddParamWithValue("extraData", extraData); dbClient.ExecuteQuery("INSERT INTO items_presents(item_id, base_ids, amounts, extra_data) VALUES(@itemId, @baseItems, @amounts, @extraData)"); GameClient receiver = Skylight.GetGame().GetGameClientManager().GetGameClientById(giftReceiverId); if (receiver != null) { if (giftReceiverId != session.GetHabbo().ID) //do achievement progress { receiver.GetHabbo().GetUserStats().GiftsReceived++; receiver.GetHabbo().GetUserAchievements().CheckAchievement("GiftReceiver"); } receiver.GetHabbo().GetInventoryManager().AddItem(giftItemId, gift.ID, giftData, false); //add it to inventory first session.SendMessage(BasicUtilies.GetRevisionPacketManager(session.Revision).GetOutgoing(OutgoingPacketsEnum.UnseenItem).Handle(new ValueHolder("Type", 1, "ID", giftItemId))); //receiver one item in this case the gift //receiver.GetHabbo().GetInventoryManager().UpdateInventoryItems(true); //update inv } else { if (giftReceiverId != session.GetHabbo().ID) //do achievement progress { dbClient.ExecuteQuery("UPDATE user_stats SET gifts_received = gifts_received + 1 WHERE user_id = @receiverId LIMIT 1"); } } } if (giftReceiverId != session.GetHabbo().ID) //do achievement progress { session.GetHabbo().GetUserStats().GiftsGived++; session.GetHabbo().GetUserAchievements().CheckAchievement("GiftGiver"); } } else { session.GetHabbo().GetInventoryManager().SetQueueBytes(true); foreach (Tuple <Item, int> data in products) { this.AddItem(session, data.Item1, data.Item2 * amountMultiplayer, extraData, true, false); } session.GetHabbo().GetInventoryManager().SetQueueBytes(false); } } } } }
public void Handle(GameClient session, ClientMessage message) { if (session.FlagmeCommandUsed) { if (session.GetHabbo().HasPermission("cmd_flagme")) { string username = TextUtilies.FilterString(message.PopFixedString()); if (username.Length < 3) //to short { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidUsername); message_.AppendInt32(2); //result message_.AppendString(username); message_.AppendInt32(0); //suggested names session.SendMessage(message_); } else if (username.Length > 15) // too long { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidUsername); message_.AppendInt32(3); //result message_.AppendString(username); message_.AppendInt32(0); //suggested names session.SendMessage(message_); } else if (username.Contains(" ") || !Regex.IsMatch(username, "^[-a-zA-Z0-9._:,]+$") || TextUtilies.HaveBlacklistedWords(username)) //invalid name { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidUsername); message_.AppendInt32(4); //result message_.AppendString(username); message_.AppendInt32(0); //suggested names session.SendMessage(message_); } else if (Skylight.GetGame().GetGameClientManager().UsernameExits(username)) //name already exits { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidUsername); message_.AppendInt32(5); //result message_.AppendString(username); message_.AppendInt32(0); //suggested names session.SendMessage(message_); } else { ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.ValidUsername); message_.AppendInt32(0); //result message_.AppendString(username); message_.AppendInt32(0); //suggested names session.SendMessage(message_); } } } else { } }