Hi people. I think that I created two commands that, maybe, are useful.
So, I advice you that I'm italian and the sentences are in italian, but I'll explain how they work.
The first command allow the admin to copy room items that you select by the parameter in the command.
So I explain how to add it, maybe you can provide a better way of this command, I'm not really good.
However, go in your habbo.cs and add this public bool:
then, go into your roomitemhandling, search for
and replace with that:
Ok, now we can go into our commandmanager.cs and add the command:
now, create a new class "copyroom.cs" into your command's folder, and paste:
Oh, I used the parameter "command_give" because I won't to create anothe row in permissions_commands. Obviously, you can change that. You can change all the command too :laugh:.
However, the command check two things:
1) the items in the current room, they must be 0, or the command will return a whisper that say "you can use the command because there is some item";
2) check the modeldata. Yeah, if the room_1_model != room_2_model it doesn't work, so I created a second command "copymodel" (what a fantasy!)
So, going into our commandmanager, add that
then, create a class "copiamodel.cs", or how you call that and paste:
Perfect, now all is done.
I've some examples.
Instead, I need to copy this room
The id is 13112, then I go in my room and copy the model:
and, finally, I use the copy command, and the result is that:
I think that a problem is that I use the INSERT query to duplicate the items. I think that it's wrong. But I don't have any other idea ^-^. If you can advice me something I will love u <3
oh I forgot that u can use the command in this way:
"copiaroom %ROOMID%
"copiamodel %ROOMID%
happy new yearrrrr!
So, I advice you that I'm italian and the sentences are in italian, but I'll explain how they work.
The first command allow the admin to copy room items that you select by the parameter in the command.
So I explain how to add it, maybe you can provide a better way of this command, I'm not really good.
However, go in your habbo.cs and add this public bool:
PHP:
public bool copy = false;
then, go into your roomitemhandling, search for
Code:
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) {
dbClient.RunQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "' WHERE `id` = '" + Item.Id + "' LIMIT 1");
}
and replace with that:
Code:
if(!Session.GetHabbo().copy) using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.RunQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "' WHERE `id` = '" + Item.Id + "' LIMIT 1");
}
else
{
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.SetQuery("INSERT INTO `items` (base_item,user_id,room_id,x,y,z,wall_pos,rot,extra_data,`limited_number`,`limited_stack`) VALUES (@did,@uid,@rid,@x,@y,@z @[I][B][URL="http://forum.ragezone.com/members/1333411810.html"]WAL[/URL][/B][/I]l_pos @[I][B][URL="http://forum.ragezone.com/members/2000143930.html"]rot[/URL][/B][/I] @[I][B][URL="http://forum.ragezone.com/members/424837.html"]eXtra[/URL][/B][/I]_data, @[I][B][URL="http://forum.ragezone.com/members/1333415425.html"]Limited[/URL][/B][/I]_number, @[I][B][URL="http://forum.ragezone.com/members/1333415425.html"]Limited[/URL][/B][/I]_stack)");
dbClient.AddParameter("did", Item.BaseItem);
dbClient.AddParameter("uid", Session.GetHabbo().Id);
dbClient.AddParameter("rid", Session.GetHabbo().CurrentRoomId);
dbClient.AddParameter("x", Item.GetX);
dbClient.AddParameter("y", Item.GetY);
dbClient.AddParameter("z", Item.GetZ);
dbClient.AddParameter("wall_pos", Item.wallCoord);
dbClient.AddParameter("rot", Item.Rotation);
dbClient.AddParameter("extra_data", Item.ExtraData);
dbClient.AddParameter("limited_number", Item.LimitedNo);
dbClient.AddParameter("limited_stack", Item.LimitedTot);
Item.Id = Convert.ToInt32(dbClient.InsertQuery());
}
}
Ok, now we can go into our commandmanager.cs and add the command:
Code:
this.Register("copiaroom", new CopyRoom());
now, create a new class "copyroom.cs" into your command's folder, and paste:
Code:
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plus.HabboHotel.GameClients;
using Plus.HabboHotel.Items;
using Plus.Database.Interfaces;
using System.Data;
using Plus.HabboHotel.Rooms;
using Plus.Communication.Packets.Outgoing.Rooms.Session;
namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
{
class CopyRoom : IChatCommand
{
public string Description
{
get
{
return "Copia una stanza";
}
}
public string Parameters
{
get
{
return "%id%";
}
}
public string PermissionRequired
{
get
{
return "command_massgive";
}
}
public void Execute(GameClient Session, Room Room, string[] Params)
{
if (Params.Length == 1)
{
Session.SendWhisper("Inserisci l'ID della stanza!");
return;
}
Room _room = Session.GetHabbo().CurrentRoom;
Room room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(Convert.ToInt32(Params[1]));
if (_room.GetRoomItemHandler().GetWallAndFloor.Count() > 0)
{
Session.SendWhisper("Per poter copiare una stanza bisogna che in questa stanza non ci siano furni.");
return;
}
else if(_room.Model != room.Model)
{
Session.SendWhisper("Non puoi copiare due stanze con model diversi. Digita :copiamodel %roomid% per copiarne il model");
return;
}
else
{
Session.GetHabbo().copy = true;
foreach(Item item in room.GetRoomItemHandler().GetFloor)
{
_room.GetRoomItemHandler().SetFloorItem(Session, item, item.GetX, item.GetY, item.Rotation, true, false, false, false, false);
}
foreach(Item item2 in room.GetRoomItemHandler().GetWall)
{
_room.GetRoomItemHandler().SetWallItem(Session, item2);
}
List<RoomUser> UsersToReturn = Room.GetRoomUserManager().GetRoomUsers().ToList();
PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(_room, true);
PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(Room, true);
foreach (RoomUser User in UsersToReturn)
{
if (User == null || User.GetClient() == null)
continue;
User.GetClient().SendMessage(new RoomForwardComposer(_room.Id));
}
// u20 :-( I'm in your heart
}
Session.GetHabbo().copy = false;
}
}
}
Oh, I used the parameter "command_give" because I won't to create anothe row in permissions_commands. Obviously, you can change that. You can change all the command too :laugh:.
However, the command check two things:
1) the items in the current room, they must be 0, or the command will return a whisper that say "you can use the command because there is some item";
2) check the modeldata. Yeah, if the room_1_model != room_2_model it doesn't work, so I created a second command "copymodel" (what a fantasy!)
So, going into our commandmanager, add that
Code:
this.Register("copiamodel", new CopiaModel());
then, create a class "copiamodel.cs", or how you call that and paste:
Code:
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plus.HabboHotel.GameClients;
using Plus.Database.Interfaces;
using Plus.Communication.Packets.Outgoing.Rooms.Session;
namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
{
class CopiaModel : IChatCommand
{
public string Description
{
get
{
return "Copia il model di una stana";
}
}
public string Parameters
{
get
{
return "%roomdi%";
}
}
public string PermissionRequired
{
get
{
return "command_massgive";
}
}
public void Execute(GameClient Session, Room Room, string[] Params)
{
if (Params.Length == 1)
{
Session.SendWhisper("Inserisci l'ID della stanza!");
return;
}
Room _room = Session.GetHabbo().CurrentRoom;
Room room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(Convert.ToInt32(Params[1]));
if(_room.Model != room.Model)
{
using(IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.SetQuery("UPDATE rooms SET model_name = @[I][B][URL="http://forum.ragezone.com/members/1333478952.html"]model[/URL][/B][/I] WHERE id = @[I][B][URL="http://forum.ragezone.com/members/19862.html"]id[/URL][/B][/I] LIMIT 1;");
dbClient.AddParameter( @[I][B][URL="http://forum.ragezone.com/members/1333478952.html"]model[/URL][/B][/I]", room.ModelName);
dbClient.AddParameter( @[I][B][URL="http://forum.ragezone.com/members/19862.html"]id[/URL][/B][/I]", _room.Id);
dbClient.RunQuery();
}
}
PlusEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName);
List<RoomUser> UsersToReturn = Room.GetRoomUserManager().GetRoomUsers().ToList();
PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(_room, true);
PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(Room, true);
foreach (RoomUser User in UsersToReturn)
{
if (User == null || User.GetClient() == null)
continue;
User.GetClient().SendMessage(new RoomForwardComposer(_room.Id));
}
}
}
}
Perfect, now all is done.
I've some examples.
Instead, I need to copy this room
The id is 13112, then I go in my room and copy the model:
and, finally, I use the copy command, and the result is that:
oh I forgot that u can use the command in this way:
"copiaroom %ROOMID%
"copiamodel %ROOMID%
happy new yearrrrr!
Attachments
You must be registered for see attachments list
Last edited: