Experienced Elementalist
- Joined
- Aug 26, 2012
- Messages
- 248
- Reaction score
- 49
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.
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
3.
then go to ChatCommandRegister.cs
and add
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!!
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:
#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
2. In ChatCommandHandleing (where all the other commands are)
add
PHP:
#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:
case 169:
commandHandler.sellroom();
break;
case 170:
commandHandler.buyroom();
break;
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!!