internal static UInt32 GetTeleRoomId(UInt32 TeleId, Room pRoom) { if (pRoom.GetRoomItemHandler().GetItem(TeleId) != null) return pRoom.RoomId; using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT room_id FROM items WHERE id = " + TeleId + " LIMIT 1"); DataRow Row = dbClient.getRow(); if (Row == null) { return 0; } return Convert.ToUInt32(Row[0]); } }
internal static bool IsTeleLinked(UInt32 TeleId, Room pRoom) { uint LinkId = GetLinkedTele(TeleId, pRoom); if (LinkId == 0) { return false; } RoomItem item = pRoom.GetRoomItemHandler().GetItem(LinkId); if (item != null && item.GetBaseItem().InteractionType == Silverwave.HabboHotel.Items.InteractionType.teleport) return true; uint RoomId = GetTeleRoomId(LinkId, pRoom); if (RoomId == 0) { return false; } return true; }
/* internal void OpenPresent() { Room Room = SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (Room == null || !Room.CheckRights(Session, true)) { return; } uint ItemId = Request.PopWiredUInt(); RoomItem Present = Room.GetRoomItemHandler().GetItem(ItemId); if (Present == null) { return; } if (SilverwaveEnvironment.GetDBConfig().DBData["gifts_enabled"] != "1") { Session.SendNotif("The hotel managers have disabled gifting"); return; } DataRow Data = null; using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT base_id,amount,extra_data FROM user_presents WHERE item_id = " + Present.Id + ""); Data = dbClient.getRow(); } if (Data == null) { Room.GetRoomItemHandler().RemoveFurniture(Session, Present.Id); return; } Item BaseItem = SilverwaveEnvironment.GetGame().GetItemManager().GetItem(Convert.ToUInt32(Data["base_id"])); if (BaseItem == null) { Room.GetRoomItemHandler().RemoveFurniture(Session, Present.Id); return; } uint PurchaserId = (uint)int.Parse(Present.ExtraData.Split(';')[0]); Habbo Purchaser = SilverwaveEnvironment.getHabboForId(PurchaserId); Response.Init(Outgoing.UpdateFloorItemExtraData); Response.AppendString(ItemId.ToString()); Response.AppendInt32(1); Response.AppendInt32(6); Response.AppendString("EXTRA_PARAM"); Response.AppendString(""); Response.AppendString("MESSAGE"); Response.AppendString(Present.ExtraData.Split(';')[1].Split((char)5)[0]); Response.AppendString("PURCHASER_NAME"); Response.AppendString(Purchaser.Username); Response.AppendString("PURCHASER_FIGURE"); Response.AppendString(Purchaser.Look); Response.AppendString("PRODUCT_CODE"); Response.AppendString("A1 KUMIANKKA"); Response.AppendString("state"); Response.AppendString("1"); Room.SendMessage(Response); Present.ReqUpdate(5, true); Thread thread = new Thread(() => FinishOpenGift(BaseItem, Present, Room, Data)); thread.Start(); }*/ private void FinishOpenGift(Item BaseItem, RoomItem Present, Room Room, DataRow Data) { Thread.Sleep(3000); try { if (BaseItem == null || Present == null || Room == null || Data == null) return; if (BaseItem.Type.ToString().ToLower().Equals("s") && BaseItem.InteractionType != InteractionType.teleport) { Room.GetRoomItemHandler().RemoveFurniture(Session, Present.Id); using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("DELETE FROM items WHERE id=" + Present.Id + " LIMIT 1;"); dbClient.setQuery("UPDATE items SET extra_data = @Edata WHERE id = " + Present.Id + " LIMIT 1"); dbClient.addParameter("edata", Data["extra_data"]); dbClient.runQuery(); dbClient.runFastQuery("DELETE FROM user_presents WHERE item_id = " + Present.Id + " LIMIT 1"); } string type = Present.GetBaseItem().Type.ToString().ToLower(); string ExtraData = Present.ExtraData; Present.BaseItem = Convert.ToUInt32(Data["base_id"]); Present.refreshItem(); Present.ExtraData = ""; if ((int)Data["amount"] == 1) { if (!Room.GetRoomItemHandler().SetFloorItem(Session, Present, Present.GetX, Present.GetY, Present.Rot, true, false, true)) { SilverwaveEnvironment.GetGame().GetCatalog().DeliverItems(Session, BaseItem, (int)Data["amount"], (String)Data["extra_data"], 0, 0); Session.GetHabbo().GetInventoryComponent().UpdateItems(true); } } else { SilverwaveEnvironment.GetGame().GetCatalog().DeliverItems(Session, BaseItem, (int)Data["amount"], (String)Data["extra_data"], 0, 0); Session.GetHabbo().GetInventoryComponent().UpdateItems(true); } Response.Init(Outgoing.OpenGift); Response.AppendString(BaseItem.Type.ToString()); Response.AppendInt32(BaseItem.SpriteId); Response.AppendString(BaseItem.Name); Response.AppendInt32(Present.Id); Response.AppendString(type); Response.AppendBoolean(false); Response.AppendString(ExtraData); //SendResponse(); } else { Room.GetRoomItemHandler().RemoveFurniture(Session, Present.Id); using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("DELETE FROM items WHERE id=" + Present.Id + " LIMIT 1;"); dbClient.runFastQuery("DELETE FROM user_presents WHERE item_id = " + Present.Id); } Session.GetMessageHandler().GetResponse().Init(Outgoing.SendPurchaseAlert); Session.GetMessageHandler().GetResponse().AppendInt32(1); // items int Type = 2; if (BaseItem.Type.ToString().ToLower().Equals("s")) { if (BaseItem.InteractionType == InteractionType.pet) Type = 3; else Type = 1; } Session.GetMessageHandler().GetResponse().AppendInt32(Type); List<UserItem> items = SilverwaveEnvironment.GetGame().GetCatalog().DeliverItems(Session, BaseItem, (int)Data["amount"], (String)Data["extra_data"], 0, 0); Session.GetMessageHandler().GetResponse().AppendInt32(items.Count); foreach (UserItem u in items) Session.GetMessageHandler().GetResponse().AppendInt32(u.Id); Session.GetMessageHandler().SendResponse(); Session.GetHabbo().GetInventoryComponent().UpdateItems(true); } } catch { } }