Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
[PlusEMU] Trouble with roll and close dice commands
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="treebeard" data-source="post: 429900" data-attributes="member: 79259"><p>Hello everyone,</p><p></p><p>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. </p><p><a href="https://imgur.com/5izWdgx" target="_blank">https://imgur.com/5izWdgx</a></p><p></p><p>I added this to GameMap.cs</p><p>[CODE]public static bool TilesTouching(Point p1, Point p2)</p><p> {</p><p> return TilesTouching(p1.X, p1.Y, p2.X, p2.Y);</p><p> }[/CODE]</p><p></p><p>Then I added this to RoomUser.cs</p><p>[CODE]public Point Point => new Point(Point.X, Point.Y);[/CODE]</p><p></p><p>& last but not least the actual command for close</p><p>[CODE]using System.Collections.Generic;</p><p>using System.Linq;</p><p></p><p>namespace Plus.HabboHotel.Rooms.Chat.Commands.User</p><p>{</p><p> class CloseDiceCommand : IChatCommand</p><p> {</p><p> public string PermissionRequired</p><p> {</p><p> get { return ""; }</p><p> }</p><p></p><p> public string Parameters</p><p> {</p><p> get { return ""; }</p><p> }</p><p></p><p> public string Description</p><p> {</p><p> get { return "Closes your dice automatically."; }</p><p> }</p><p></p><p> public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)</p><p> {</p><p> RoomUser roomUser = Room?.GetRoomUserManager()?.GetRoomUserByHabbo(Session.GetHabbo().Id);</p><p> if (roomUser == null)</p><p> {</p><p> return;</p><p> }</p><p></p><p> if (Params.Length > 1)</p><p> {</p><p></p><p> if (int.TryParse(Params[1], out int Amount))</p><p> {</p><p> List<Items.Item> userBoothAmount = Room.GetRoomItemHandler().GetFloor.Where(x => x != null && Gamemap.TilesTouching(</p><p> x.Coordinate, roomUser.Point) && x.Data.InteractionType == Items.InteractionType.DICE).Take(Amount).ToList();</p><p></p><p> userBoothAmount.ForEach(x =></p><p> {</p><p> x.ExtraData = "0";</p><p> x.UpdateState();</p><p> });</p><p> Session.SendWhisper("Your booth dices have been closed");</p><p> }</p><p></p><p> }</p><p> else</p><p> {</p><p> List<Items.Item> userBooth = Room.GetRoomItemHandler().GetFloor.Where(x => x != null && Gamemap.TilesTouching(</p><p> x.Coordinate, roomUser.Point) && x.Data.InteractionType == Items.InteractionType.DICE).ToList();</p><p></p><p> if (userBooth.Count != 5)</p><p> {</p><p> Session.SendWhisper("You must be in a booth with 5 dice.");</p><p> return;</p><p> }</p><p></p><p> userBooth.ForEach(x =></p><p> {</p><p> x.ExtraData = "0";</p><p> x.UpdateState();</p><p> });</p><p></p><p> Session.SendWhisper("Your booth dices have been closed");</p><p> }</p><p> }</p><p> }</p><p>}[/CODE]</p><p></p><p>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 <img src="/styles/default/xenforo/smilies/emojione/tongue.png" class="smilie" loading="lazy" alt=":p" title="Stick Out Tongue :p" data-shortname=":p" /></p><p></p><p>As always I appreciate your time, energy, and help!</p><p>[doublepost=1520360476,1520357625][/doublepost]I fixed this issue by changing</p><p>[CODE]public Point Point => new Point(Point.X, Point.Y);[/CODE]</p><p>to</p><p>[CODE]public Point Point => new Point(X, Y);[/CODE]</p></blockquote><p></p>
[QUOTE="treebeard, post: 429900, member: 79259"] 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. [URL]https://imgur.com/5izWdgx[/URL] 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); }[/CODE] Then I added this to RoomUser.cs [CODE]public Point Point => new Point(Point.X, Point.Y);[/CODE] & 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"); } } } }[/CODE] 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 :P As always I appreciate your time, energy, and help! [doublepost=1520360476,1520357625][/doublepost]I fixed this issue by changing [CODE]public Point Point => new Point(Point.X, Point.Y);[/CODE] to [CODE]public Point Point => new Point(X, Y);[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
[PlusEMU] Trouble with roll and close dice commands
Top