Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
Pets in inventorty [?]
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="logretroservista" data-source="post: 455256" data-attributes="member: 75113"><p>[CODE]using System;</p><p>using System.Linq;</p><p>using System.Text;</p><p>using System.Collections.Generic;</p><p></p><p>using Plus.HabboHotel.Rooms.AI;</p><p>using Plus.HabboHotel.Rooms;</p><p>using Plus.Communication.Packets.Outgoing.Inventory.Pets;</p><p></p><p>using System.Drawing;</p><p>using Plus.HabboHotel.GameClients;</p><p>using Plus.Communication.Packets.Outgoing.Rooms.Engine;</p><p>using Plus.Database.Interfaces;</p><p></p><p>namespace Plus.Communication.Packets.Incoming.Rooms.AI.Pets</p><p>{</p><p> class PickUpPetEvent : IPacketEvent</p><p> {</p><p> public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)</p><p> {</p><p> if (!Session.GetHabbo().InRoom)</p><p> return;</p><p></p><p> if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetInventoryComponent() == null)</p><p> return;</p><p></p><p> Room Room;</p><p></p><p> if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))</p><p> return;</p><p></p><p> int PetId = Packet.PopInt();</p><p></p><p> RoomUser Pet = null;</p><p> if (!Room.GetRoomUserManager().TryGetPet(PetId, out Pet))</p><p> {</p><p> //Check kick rights, just because it seems most appropriate.</p><p> if ((!Room.CheckRights(Session) && Room.WhoCanKick != 2 && Room.Group == null) || (Room.Group != null && !Room.CheckRights(Session, false, true)))</p><p> return;</p><p></p><p> //Okay so, we've established we have no pets in this room by this virtual Id, let us check out users, maybe they're creeping as a pet?!</p><p> RoomUser TargetUser = Session.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(PetId);</p><p> if (TargetUser == null)</p><p> return;</p><p></p><p> //Check some values first, please!</p><p> if (TargetUser.GetClient() == null || TargetUser.GetClient().GetHabbo() == null)</p><p> return;</p><p></p><p> //Update the targets PetId.</p><p> TargetUser.GetClient().GetHabbo().PetId = 0;</p><p></p><p> //Quickly remove the old user instance.</p><p> Room.SendPacket(new UserRemoveComposer(TargetUser.VirtualId));</p><p></p><p> //Add the new one, they won't even notice a thing!!11 8-)</p><p> Room.SendPacket(new UsersComposer(TargetUser));</p><p> return;</p><p> }</p><p></p><p> if (Session.GetHabbo().Id != Pet.PetData.OwnerId && !Room.CheckRights(Session, true, false))</p><p> {</p><p> Session.SendWhisper("You can only pickup your own pets, to kick a pet you must have room rights.");</p><p> return;</p><p> }</p><p></p><p> if (Pet.RidingHorse)</p><p> {</p><p> RoomUser UserRiding = Room.GetRoomUserManager().GetRoomUserByVirtualId(Pet.HorseID);</p><p> if (UserRiding != null)</p><p> {</p><p> UserRiding.RidingHorse = false;</p><p> UserRiding.ApplyEffect(-1);</p><p> UserRiding.MoveTo(new Point(UserRiding.X + 1, UserRiding.Y + 1));</p><p> }</p><p> else</p><p> Pet.RidingHorse = false;</p><p> }</p><p></p><p> Pet.PetData.RoomId = 0;</p><p> Pet.PetData.PlacedInRoom = false;</p><p></p><p> Pet pet = Pet.PetData;</p><p> if (pet != null)</p><p> {</p><p> using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.RunQuery("UPDATE `bots` SET `room_id` = '0', `x` = '0', `Y` = '0', `Z` = '0' WHERE `id` = '" + pet.PetId + "' LIMIT 1");</p><p> dbClient.RunQuery("UPDATE `bots_petdata` SET `experience` = '" + pet.experience + "', `energy` = '" + pet.Energy + "', `nutrition` = '" + pet.Nutrition + "', `respect` = '" + pet.Respect + "' WHERE `id` = '" + pet.PetId + "' LIMIT 1");</p><p> }</p><p> }</p><p></p><p> if (pet.OwnerId != Session.GetHabbo().Id)</p><p> {</p><p> GameClient Target = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(pet.OwnerId);</p><p> if (Target != null)</p><p> {</p><p> Target.GetHabbo().GetInventoryComponent().TryAddPet(Pet.PetData);</p><p> Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false);</p><p></p><p> Target.SendPacket(new PetInventoryComposer(Target.GetHabbo().GetInventoryComponent().GetPets()));</p><p> return;</p><p> }</p><p> }</p><p> </p><p> Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false);</p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p><p>[USER=77990]@Pollak[/USER]</p></blockquote><p></p>
[QUOTE="logretroservista, post: 455256, member: 75113"] [CODE]using System; using System.Linq; using System.Text; using System.Collections.Generic; using Plus.HabboHotel.Rooms.AI; using Plus.HabboHotel.Rooms; using Plus.Communication.Packets.Outgoing.Inventory.Pets; using System.Drawing; using Plus.HabboHotel.GameClients; using Plus.Communication.Packets.Outgoing.Rooms.Engine; using Plus.Database.Interfaces; namespace Plus.Communication.Packets.Incoming.Rooms.AI.Pets { class PickUpPetEvent : IPacketEvent { public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) return; if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetInventoryComponent() == null) return; Room Room; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room)) return; int PetId = Packet.PopInt(); RoomUser Pet = null; if (!Room.GetRoomUserManager().TryGetPet(PetId, out Pet)) { //Check kick rights, just because it seems most appropriate. if ((!Room.CheckRights(Session) && Room.WhoCanKick != 2 && Room.Group == null) || (Room.Group != null && !Room.CheckRights(Session, false, true))) return; //Okay so, we've established we have no pets in this room by this virtual Id, let us check out users, maybe they're creeping as a pet?! RoomUser TargetUser = Session.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(PetId); if (TargetUser == null) return; //Check some values first, please! if (TargetUser.GetClient() == null || TargetUser.GetClient().GetHabbo() == null) return; //Update the targets PetId. TargetUser.GetClient().GetHabbo().PetId = 0; //Quickly remove the old user instance. Room.SendPacket(new UserRemoveComposer(TargetUser.VirtualId)); //Add the new one, they won't even notice a thing!!11 8-) Room.SendPacket(new UsersComposer(TargetUser)); return; } if (Session.GetHabbo().Id != Pet.PetData.OwnerId && !Room.CheckRights(Session, true, false)) { Session.SendWhisper("You can only pickup your own pets, to kick a pet you must have room rights."); return; } if (Pet.RidingHorse) { RoomUser UserRiding = Room.GetRoomUserManager().GetRoomUserByVirtualId(Pet.HorseID); if (UserRiding != null) { UserRiding.RidingHorse = false; UserRiding.ApplyEffect(-1); UserRiding.MoveTo(new Point(UserRiding.X + 1, UserRiding.Y + 1)); } else Pet.RidingHorse = false; } Pet.PetData.RoomId = 0; Pet.PetData.PlacedInRoom = false; Pet pet = Pet.PetData; if (pet != null) { using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE `bots` SET `room_id` = '0', `x` = '0', `Y` = '0', `Z` = '0' WHERE `id` = '" + pet.PetId + "' LIMIT 1"); dbClient.RunQuery("UPDATE `bots_petdata` SET `experience` = '" + pet.experience + "', `energy` = '" + pet.Energy + "', `nutrition` = '" + pet.Nutrition + "', `respect` = '" + pet.Respect + "' WHERE `id` = '" + pet.PetId + "' LIMIT 1"); } } if (pet.OwnerId != Session.GetHabbo().Id) { GameClient Target = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(pet.OwnerId); if (Target != null) { Target.GetHabbo().GetInventoryComponent().TryAddPet(Pet.PetData); Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false); Target.SendPacket(new PetInventoryComposer(Target.GetHabbo().GetInventoryComponent().GetPets())); return; } } Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false); } } } [/CODE] [USER=77990]@Pollak[/USER] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Pets in inventorty [?]
Top