[BC Storm/Swift Emu] Sellroom and buyroom command

Results 1 to 21 of 21
  1. #1
    DO YOU HAVE THE POWER? Power is offline
    MemberRank
    Aug 2012 Join Date
    Haverhill, SuffLocation
    248Posts

    thumbs up [BC Storm/Swift Emu] Sellroom and buyroom command

    Hello Ragezone, This is my first Release.

    All Works (but you need to reload emu for room owner to change anyone can fix that would help alot)

    This code is Messy i know but no hate please. Also Sorry about my English my spelling and Grammar are Crap.

    1.

    Find (CTRL F) "internal void AppendPetsUpdateString(IQueryAdapter dbClient)" in RoomUserManger And Add Above it.
    PHP Code:
    #region Check Sell
                
    int Sale;
                
    int price;
                  
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    
                {
                    
    adapter.setQuery("SELECT room_sell FROM rooms WHERE id =" this.room.RoomId);
                   
                    
    Sale adapter.getInteger();

                }

                
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    
    adapter.setQuery("SELECT room_price FROM rooms WHERE id = "this.room.RoomId);
                   
                    
    price adapter.getInteger();
                }
                if (
    Sale == 1)
                {
                    
    Session.SendNotifWithScroll("This Room is For sale at " price "  Type :buyroom");
                }
                
            }
                
    #endregion 
    What this does is When you enter the room it will alert you if the room is for sale and how much

    2. In ChatCommandHandleing (where all the other commands are)
    add
    PHP Code:
    #region Buyroom
            
    internal void buyroom()
            {
                
    int Price;
                
    uint user;
                
    string owner;
                
    int sale;
                
    int Credits;
                
    int OwnerCredits;
                
    string caption;
                
    string model;
                
    user this.Session.GetHabbo().Id;
                
    string user1 this.Session.GetHabbo().Username;
                
    uint currentRoom1 this.Session.GetHabbo().CurrentRoomId;
                
    Room currentRoom this.Session.GetHabbo().CurrentRoom;
                
    Room ownercurrentRoom this.Session.GetHabbo().CurrentRoom;
                
    currentRoom ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
                
                
    GameClient roomowner null;

                
    // querys to get data
                
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    {
                        
    adapter.setQuery("SELECT owner FROM rooms WHERE id ="+currentRoom1);
                        
                        
    owner adapter.getString();
                    }
                    
                }

                
                 
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                 {
                
    roomowner ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(owner);
                    
    uint owner2 roomowner.GetHabbo().Id;
                    {
                        
    adapter.setQuery("SELECT credits FROM users WHERE id ="+user);
                       
                        
    Credits adapter.getInteger();
                    }
                    {
                        
    adapter.setQuery("SELECT credits FROM users WHERE id ="+owner2);
                        
                        
    OwnerCredits adapter.getInteger();
                    }
                    {
                        
    adapter.setQuery("SELECT room_price FROM rooms WHERE id =" +currentRoom1);
                        
                        
    Price adapter.getInteger();
                    }
                    {
                        
    adapter.setQuery("SELECT room_sell FROM rooms WHERE id ="+currentRoom1);
                      
                        
    sale adapter.getInteger();
                    }
                      {
                        
    adapter.setQuery("SELECT caption FROM rooms WHERE id ="+currentRoom1);
                      
                        
    caption adapter.getString();
                    }
                        {
                        
    adapter.setQuery("SELECT model_name FROM rooms WHERE id ="+currentRoom1);
                      
                        
    model adapter.getString();
                    }
                }
            
                
    roomowner ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(owner);
                
    ownercurrentRoom ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(roomowner.GetHabbo().CurrentRoomId);
                if (
    sale == 0// check to see if room for sale.
                
    {
                   
    this.Session.SendNotifWithScroll("Not For Sale Sorry.");
                }
                    
    //check to see if owners in room.
                
    else if (currentRoom != ownercurrentRoom)
                    
                {
                    
    this.Session.SendNotifWithScroll("Sorry the room owner isnt in the room.");
                    
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {

                        
    adapter.runFastQuery("UPDATE rooms SET room_sell = '0' WHERE id = " currentRoom);


                    }
                }
                else
                {

                    if (
    user == roomowner.GetHabbo().Id// Cancells Sell
                    
    {
                        
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {

                            
    adapter.runFastQuery("UPDATE rooms SET room_sell = '0' WHERE id = " currentRoom1);


                        }
                        
    //
                        // alerts room 
                        
    this.Session.SendNotifWithScroll("You Have Cancelled The Room Being Sold");
                        
    string s "The Owner Has Cancelled The Room being sold";
                        
    ServerMessage message = new ServerMessage();
                        
    message.Init(Outgoing.SendNotif);
                        
    message.AppendString(s);
                        
    message.AppendString("");
                        
    currentRoom.QueueRoomMessage(message);
                    }
                    else
                    {
                        if (
    Credits >= Price// check credits
                        
    {

                            
    // Updates Room Owner And Updates The Room Sell
                            
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                
    adapter.runFastQuery(string.Concat(new object[] {"UPDATE rooms SET room_sell = '0' WHERE id = " currentRoom1}));
                                
    adapter.runFastQuery("UPDATE rooms SET owner = '" +this.Session.GetHabbo().Username"'  WHERE id = " currentRoom1);


                            }
                            
    //


                            // update prices 
                            
    Session.GetHabbo().Credits -= Price;
                            
    Session.GetHabbo().UpdateCreditsBalance();
                            
    roomowner.GetHabbo().Credits += Price;
                            
    roomowner.GetHabbo().UpdateCreditsBalance();
                            
    //
                            

                            // Alerts Room
                            
    string s "This Room Has Been Bought by:" user1;
                            
    Thread.Sleep(1000);
                            
    ServerMessage message = new ServerMessage(2);
                            
    message.Init(Outgoing.SendNotif);
                            
    message.AppendString(s);
                            
    message.AppendString("");
                            
    currentRoom.QueueRoomMessage(message);
                            
    //


                            
                            // adds new room to users room And removes it from old users room
                            
    RoomData item ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData(currentRoom1);
                            
    Session.GetHabbo().UsersRooms.Add(item);
                            
    roomowner.GetHabbo().UsersRooms.Remove(item);
                           
    //

               
                            // unloads the room
                           
    ButterflyEnvironment.GetGame().GetRoomManager().UnloadRoom(currentRoom);
                            
    //
           
                          
                        
    }
                        else
                        {
                          
    this.Session.SendNotifWithScroll("Sorry you dont have enough for the rooms D:");
                        }
                        
                    }
                }
            }
    #endregion
            #region Sellroom

            
    internal void sellroom()
            {


                
    int num 1;
                
    string user;
                
    string owner;
                
    int Price;
                
    user this.Session.GetHabbo().Username;
                
    uint currentRoom this.Session.GetHabbo().CurrentRoomId;
                
    Room currentRoom2 ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
                
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    
    adapter.setQuery("SELECT owner FROM rooms WHERE id =" currentRoom);
                    
                    
    owner adapter.getString();
                }
                if (
    int.TryParse(this.Params[1], out Price))
                {
                    if (
    owner != user)
                    {
                        
    Session.SendNotifWithScroll("Sorry You Do Not Own This Room");
                    }
                    else
                    {
                        
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            
    adapter.runFastQuery(string.Concat(new object[] {"UPDATE rooms SET room_sell = ",num ," WHERE id = "currentRoom}));
                            
    adapter.runFastQuery(string.Concat(new object[] {"UPDATE rooms SET room_price = "Price " WHERE id = "currentRoom}));

                        }
                        
    this.Session.SendNotifWithScroll("You have put your room for sale");
                        
    string s "this Room Is For Sale /n Amount:" Price " Credits.";
                        
    ServerMessage message = new ServerMessage(2);
                        
    message.Init(Outgoing.SendNotif);
                        
    message.AppendString(s);
                        
    message.AppendString("");
                        
    currentRoom2.QueueRoomMessage(message);
                    }
                }
                else
                {
                    
    this.Session.SendNotifWithScroll(" Sorry There Was a Error ");
                }
            }
            
    #endregion 
    3.
    then go to ChatCommandRegister.cs
    and add

    PHP Code:
                    case 169:
                        
    commandHandler.sellroom();
                        break;
                    case 
    170:
                        
    commandHandler.buyroom();
                        break; 
    4. Then Add it to your Commands and command Register In the emu bin file.

    5. go to database and run this 2

    ALTER TABLE `rooms` ADD `room_sell` INT(9)
    ALTER TABLE `rooms` ADD `room_price` INT(9)



    If You can help with updating Owner with out reloading Emu i Would Be Very Thankfull!!


  2. #2
    Zephyr Studios PRIZM is offline
    MemberRank
    Feb 2012 Join Date
    DenmarkLocation
    2,291Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Nice idea, It's a really nice idea!
    I apreciate your work man, thank you

  3. #3
    Enthusiast xLiionel is offline
    MemberRank
    Sep 2010 Join Date
    36Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    This can be done very well without querying the database, so you do not get many ...

  4. #4
    DO YOU HAVE THE POWER? Power is offline
    MemberRank
    Aug 2012 Join Date
    Haverhill, SuffLocation
    248Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Quote Originally Posted by xLiionel View Post
    This can be done very well without querying the database, so you do not get many ...
    If i Can Fix The Room Owner Updating Then i will fix up and make the code alot neater and faster.
    Quote Originally Posted by PRIZM View Post
    Nice idea, It's a really nice idea!
    I apreciate your work man, thank you
    Thanks Dude.

  5. #5
    Gaby is offline
    MemberRank
    Apr 2013 Join Date
    Viva HollandiaLocation
    1,607Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    That is one cool idea! Thanks for this!

  6. #6
    DO YOU HAVE THE POWER? Power is offline
    MemberRank
    Aug 2012 Join Date
    Haverhill, SuffLocation
    248Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Quote Originally Posted by BaasHotel View Post
    That is one cool idea! Thanks for this!
    Your Welcome

  7. #7
    Valued Member TheFlamingo is offline
    MemberRank
    May 2013 Join Date
    123Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    I would use a query for the update room owner, I don't know if it fix your problem there. Well anyways good release ;) I'm a fan of command releases :)

  8. #8
    DO YOU HAVE THE POWER? Power is offline
    MemberRank
    Aug 2012 Join Date
    Haverhill, SuffLocation
    248Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Quote Originally Posted by TheFlamingo View Post
    I would use a query for the update room owner, I don't know if it fix your problem there. Well anyways good release ;) I'm a fan of command releases :)
    It updates the room owner on database fine, just not on client till the emu reload which means i have to find away off completely reloading the room with all info (cant find away off doing it)

  9. #9
    Account Upgraded | Title Enabled! Kristopher is offline
    MemberRank
    Sep 2011 Join Date
    266Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    try :unload to unload the room and see. If that works just call the command after each :buy

  10. #10
    DO YOU HAVE THE POWER? Power is offline
    MemberRank
    Aug 2012 Join Date
    Haverhill, SuffLocation
    248Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Quote Originally Posted by Kristopher View Post
    try :unload to unload the room and see. If that works just call the command after each :buy
    I have Already Tried That "
    // unloads the room
    ButterflyEnvironment.GetGame().GetRoomManager().UnloadRoom(currentRoom);
    // "
    it make no diffrence.

  11. #11
    Enthusiast JakeA is offline
    MemberRank
    May 2013 Join Date
    London, UKLocation
    33Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    @Ben - Use
    Room Room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoom.RoomId);
    Room.OwnerId = Session.GetHabbo().Id;

  12. #12
    DO YOU HAVE THE POWER? Power is offline
    MemberRank
    Aug 2012 Join Date
    Haverhill, SuffLocation
    248Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Quote Originally Posted by JakeA View Post
    @Ben - Use
    No difference, Still not updating room owner still have to reload emu for it to update :(

  13. #13
    Banned Divide is offline
    BannedRank
    Aug 2011 Join Date
    British CoderLocation
    1,013Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Do this for live updating the room owner:
    Code:
    Room.ownerId = Session.GetHabbo().Id;

  14. #14
    DO YOU HAVE THE POWER? Power is offline
    MemberRank
    Aug 2012 Join Date
    Haverhill, SuffLocation
    248Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Quote Originally Posted by Divide View Post
    Do this for live updating the room owner:
    Code:
    Room.ownerId = Session.GetHabbo().Id;
    Thank you also had to do
    Room.owner = Session.GetHabbo().username;

    and did a little bit more editing to get the bugs out.

    ill Release the fixed code when i recode the items so you can keep all items inside

  15. #15
    Enthusiast hedapepa is offline
    MemberRank
    Jan 2012 Join Date
    Barinitas, BariLocation
    47Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    could do that can be sold in the catalog

  16. #16
    DO YOU HAVE THE POWER? Power is offline
    MemberRank
    Aug 2012 Join Date
    Haverhill, SuffLocation
    248Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Quote Originally Posted by hedapepa View Post
    could do that can be sold in the catalog
    Love That Idea ill work on Furni then im gunna work on your idea there!

  17. #17
    Alpha Member Twan is offline
    MemberRank
    Jun 2010 Join Date
    1,961Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Quote Originally Posted by Ben Owen View Post
    Love That Idea ill work on Furni then im gunna work on your idea there!
    I think its a great idea to. Like the release btw. Maybe im going to add it to test it, i think i'll do that :)

  18. #18
    DO YOU HAVE THE POWER? Power is offline
    MemberRank
    Aug 2012 Join Date
    Haverhill, SuffLocation
    248Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Quote Originally Posted by Twan View Post
    I think its a great idea to. Like the release btw. Maybe im going to add it to test it, i think i'll do that :)
    If you wait a Couple of hours ill Update this Thread With Fully fixed, Neater code + It updates furni to your name.

  19. #19
    Alpha Member Twan is offline
    MemberRank
    Jun 2010 Join Date
    1,961Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Quote Originally Posted by Ben Owen View Post
    If you wait a Couple of hours ill Update this Thread With Fully fixed, Neater code + It updates furni to your name.
    Nice :) Gonna wait first then add it. I have some testers so it will be great!

  20. #20
    Enthusiast LensFlare is offline
    MemberRank
    Nov 2012 Join Date
    27Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Have you an idea on how we could ever duplicate a room? It seems quite hard but it would be really interesting for selling purposes (hard because we also need to duplicate the items inside, from different tables)

  21. #21
    DO YOU HAVE THE POWER? Power is offline
    MemberRank
    Aug 2012 Join Date
    Haverhill, SuffLocation
    248Posts

    Re: [BC Storm/Swift Emu] Sellroom and buyroom command

    Quote Originally Posted by LensFlare View Post
    Have you an idea on how we could ever duplicate a room? It seems quite hard but it would be really interesting for selling purposes (hard because we also need to duplicate the items inside, from different tables)
    havent Tested but
    PHP Code:
     internal void cloneroom()
        {
            
    Room currentRoom this.Session.GetHabbo().CurrentRoom;
            
    currentRoom ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            
    int Roomid;
            
    uint Roomid3;
            
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())

            
                {
                    
    adapter.setQuery("SELECT MAX(id) FROM rooms");




                     
    Roomid adapter.getInteger();
                }
                
    int RoomId2 Roomid 1;
                
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    
    adapter.setQuery("SELECT * FROM rooms WHERE id =" currentRoom);
                    
    DataTable table adapter.getTable();
                    foreach (
    DataRow row in table.Rows)
                    {
                        
    adapter.setQuery(string.Concat(new object[] { "INSERT INTO rooms VALUES ("RoomId2","row["roomtype"], ","row["caption"], ","row["owner"], ","row["description"], ","row["category"], ","row["state"], ","row["users_now"], ","row["users_max"], ","row["model_name"], ","row["public_ccts"], ","row["score"], ","row["tags"], ","row["icon_bg"], ","row["icon_fg"], ","row["icon_items"], ","row["password"], ","row["wallpaper"], ","row["floor"], ","row["landscape"], ","row["allow_pets"], ","row["allow_pets_eat"], ","row["allow_walkthrough"], ","row["allow_hidewall"], ","row["allow_rightsoverride"], ","row["floorthickness"], ","row["wallthickness"], ","row["groupId"], ","row["room_sell"], ","row["room_price"], ")" }));


                    }
                }
                
    using (IQueryAdapter adapter ButterflyEnvironment.GetDatabaseManager().getQueryreactor())

                {
                
    adapter.setQuery("SELECT * FROM item_rooms WHERE room_id =" currentRoom);
                
    DataTable table adapter.getTable();
                foreach (
    DataRow row in table.Rows)
                {
                    
    adapter.setQuery(string.Concat(new object[] { "INSERT INTO items_rooms VALUES ("row["Item_id"], ","RoomId2","row["x"], ","row["y"], ","row["n"], ","row["guids_data"], ")" }));
                         

                }
              
    Roomid3 Convert.ToUInt32(RoomId2);
                
    RoomData item ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData(Roomid3);
                
    Session.GetHabbo().UsersRooms.Add(item);
            }        
        } 
    Not 100% it work but it worth a try also you need to add the command to commandhandelregister (think that what it called) and your emu command file and command regester (make sure the number are the same)

    Quote Originally Posted by Twan View Post
    Nice :) Gonna wait first then add it. I have some testers so it will be great!
    Sorry dude The command a dead end because you cant update the users items to the new owner xD ill keep working on it but it doesnt look likely
    Last edited by Power; 13-06-13 at 11:57 PM. Reason: New Info



Advertisement