hospital bed code?

xxfanywe

Member
Mar 25, 2015
40
3
hey everyone i am looking to program a mini game for my upcoming hotel and when you die in the mini game you are sent to a room with a hospital bed but i do not know the code to make them go straight to the bed and be stuck on the bed till the timer is finished can anyone help please
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
Well... You would need to code in the room entry class to test a variable to see if their dead.. Then in the room user class to allow them to move or do anything that you want blocked you just put a return statement if the boolean is true.
 

xxfanywe

Member
Mar 25, 2015
40
3
Well... You would need to code in the room entry class to test a variable to see if their dead.. Then in the room user class to allow them to move or do anything that you want blocked you just put a return statement if the boolean is true.
i am just looking for the code which makes them go straight to the bed
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
i am just looking for the code which makes them go straight to the bed
Okay? I just fucking told you how to do it. If you think we are going to code it for you; you're out of your mind?

1) Create a boolean in the Habbo class to determine if they are "dead"
2) Whereever you update their "health" if health hits 0 -> assign true to the boolean and send the user to the room of the hospital
3) In the ROOMENTRY method test if boolean is true. If the boolean is true loop through all of the floor items in the room and determine if the interaction type is bed. Create an array of all of the items (Or a list !) and then use a random number method to grab a random index between 0 and the array length.
4) Get the coordinates of the bed and put the user there! (You will have to force them to lay down, reference :lay)

Done.
 
May 1, 2015
467
152
I'm not sure if you still need this but, just create a boolean for "SentToHospital" and set it to true in your commands when the user's health is 0.
The following should work to send them straight to the bed.
Code:
if (_room.RoomId == 3 && Habbo.SentToHospital)
                    {
                        List<Item> Beds = new List<Item>();
                        foreach (Item Items in _room.GetRoomItemHandler().GetFloor.ToArray())
                        {
                            if (Items.GetBaseItem().InteractionType == InteractionType.BED)
                                Beds.Add(Items);
                            else
                                continue;
                        }
                        Random GrabBed = new Random();
                        Item Bed = Beds[GrabBed.Next(1, Beds.Count + 1)];

                        User.SetPos(Bed.GetX, Bed.GetY, _room.GetGameMap().Model.SqFloorHeight[Bed.GetX, Bed.GetY]);
                        if (!User.Statusses.ContainsKey("lay"))
                        {
                            User.Statusses.Add("lay", Bed.GetBaseItem().Height.ToString().Replace(',', '.'));
                        }
                        User.Z = Bed.GetZ;
                        User.RotBody = Bed.Rotation;
                        User.RotHead = Bed.Rotation;
                        User.UpdateNeeded = true;

                        Habbo.SentToHospital = false;
                    }
 

xxfanywe

Member
Mar 25, 2015
40
3
I'm not sure if you still need this but, just create a boolean for "SentToHospital" and set it to true in your commands when the user's health is 0.
The following should work to send them straight to the bed.
Code:
if (_room.RoomId == 3 && Habbo.SentToHospital)
                    {
                        List<Item> Beds = new List<Item>();
                        foreach (Item Items in _room.GetRoomItemHandler().GetFloor.ToArray())
                        {
                            if (Items.GetBaseItem().InteractionType == InteractionType.BED)
                                Beds.Add(Items);
                            else
                                continue;
                        }
                        Random GrabBed = new Random();
                        Item Bed = Beds[GrabBed.Next(1, Beds.Count + 1)];

                        User.SetPos(Bed.GetX, Bed.GetY, _room.GetGameMap().Model.SqFloorHeight[Bed.GetX, Bed.GetY]);
                        if (!User.Statusses.ContainsKey("lay"))
                        {
                            User.Statusses.Add("lay", Bed.GetBaseItem().Height.ToString().Replace(',', '.'));
                        }
                        User.Z = Bed.GetZ;
                        User.RotBody = Bed.Rotation;
                        User.RotHead = Bed.Rotation;
                        User.UpdateNeeded = true;

                        Habbo.SentToHospital = false;
                    }

why thank you where would iadd this
 

KieranX

New Member
Oct 8, 2016
1
0
I'm not sure if you still need this but, just create a boolean for "SentToHospital" and set it to true in your commands when the user's health is 0.
The following should work to send them straight to the bed.
Code:
if (_room.RoomId == 3 && Habbo.SentToHospital)
                    {
                        List<Item> Beds = new List<Item>();
                        foreach (Item Items in _room.GetRoomItemHandler().GetFloor.ToArray())
                        {
                            if (Items.GetBaseItem().InteractionType == InteractionType.BED)
                                Beds.Add(Items);
                            else
                                continue;
                        }
                        Random GrabBed = new Random();
                        Item Bed = Beds[GrabBed.Next(1, Beds.Count + 1)];

                        User.SetPos(Bed.GetX, Bed.GetY, _room.GetGameMap().Model.SqFloorHeight[Bed.GetX, Bed.GetY]);
                        if (!User.Statusses.ContainsKey("lay"))
                        {
                            User.Statusses.Add("lay", Bed.GetBaseItem().Height.ToString().Replace(',', '.'));
                        }
                        User.Z = Bed.GetZ;
                        User.RotBody = Bed.Rotation;
                        User.RotHead = Bed.Rotation;
                        User.UpdateNeeded = true;

                        Habbo.SentToHospital = false;
                    }

You should cache the spawn points of the beds. That way they can be loaded when the room is loaded and you don't have to iterate through all the items each time a user enters the room.
 

xxfanywe

Member
Mar 25, 2015
40
3
You should cache the spawn points of the beds. That way they can be loaded when the room is loaded and you don't have to iterate through all the items each time a user enters the room.

Do you know where abouts to add this and in what section of code of roomusermanager , idk about caching but ill attempt that after
 
 

xxfanywe

Member
Mar 25, 2015
40
3
Do you have it so that the users health goes down? Do you ever set that boolean to false or are you just fucking expecting this to work?

Theres no health added atm im just testing it basically it's a simple command like :slap and the user then gets sent to a room once slapped and goes to a bed , i want to make sure the bed code works before going further
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
Theres no health added atm im just testing it basically it's a simple command like :slap and the user then gets sent to a room once slapped and goes to a bed , i want to make sure the bed code works before going further
Okay well first of all; You have to make the command that will hit the user then send them to the room and set the boolean to true. This boolean only controls ENTRY of the room.
 

Users who are viewing this thread

Top