treebeard
Member
- Jan 16, 2018
- 317
- 173
Hello everyone,
Title is pretty self-explanatory; I'm working on adding close and roll to my hotel but I get a stack overflow exception error when trying :close in the hotel.
I added this to GameMap.cs
Then I added this to RoomUser.cs
& last but not least the actual command for close
This is mostly copy/paste code which is why I'm having issues because I don't actually know everything that's being done here, so it makes debugging exceptionally harder
As always I appreciate your time, energy, and help!
I fixed this issue by changing
to
Title is pretty self-explanatory; I'm working on adding close and roll to my hotel but I get a stack overflow exception error when trying :close in the hotel.
You must be registered for see links
I added this to GameMap.cs
Code:
public static bool TilesTouching(Point p1, Point p2)
{
return TilesTouching(p1.X, p1.Y, p2.X, p2.Y);
}
Then I added this to RoomUser.cs
Code:
public Point Point => new Point(Point.X, Point.Y);
& last but not least the actual command for close
Code:
using System.Collections.Generic;
using System.Linq;
namespace Plus.HabboHotel.Rooms.Chat.Commands.User
{
class CloseDiceCommand : IChatCommand
{
public string PermissionRequired
{
get { return ""; }
}
public string Parameters
{
get { return ""; }
}
public string Description
{
get { return "Closes your dice automatically."; }
}
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
{
RoomUser roomUser = Room?.GetRoomUserManager()?.GetRoomUserByHabbo(Session.GetHabbo().Id);
if (roomUser == null)
{
return;
}
if (Params.Length > 1)
{
if (int.TryParse(Params[1], out int Amount))
{
List<Items.Item> userBoothAmount = Room.GetRoomItemHandler().GetFloor.Where(x => x != null && Gamemap.TilesTouching(
x.Coordinate, roomUser.Point) && x.Data.InteractionType == Items.InteractionType.DICE).Take(Amount).ToList();
userBoothAmount.ForEach(x =>
{
x.ExtraData = "0";
x.UpdateState();
});
Session.SendWhisper("Your booth dices have been closed");
}
}
else
{
List<Items.Item> userBooth = Room.GetRoomItemHandler().GetFloor.Where(x => x != null && Gamemap.TilesTouching(
x.Coordinate, roomUser.Point) && x.Data.InteractionType == Items.InteractionType.DICE).ToList();
if (userBooth.Count != 5)
{
Session.SendWhisper("You must be in a booth with 5 dice.");
return;
}
userBooth.ForEach(x =>
{
x.ExtraData = "0";
x.UpdateState();
});
Session.SendWhisper("Your booth dices have been closed");
}
}
}
}
This is mostly copy/paste code which is why I'm having issues because I don't actually know everything that's being done here, so it makes debugging exceptionally harder
As always I appreciate your time, energy, and help!
I fixed this issue by changing
Code:
public Point Point => new Point(Point.X, Point.Y);
Code:
public Point Point => new Point(X, Y);