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
:Floor Plan Problem
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="habpoppw" data-source="post: 458939" data-attributes="member: 92512"><p>hi, thanks for replying. we found it and tried to maximize the 64 numbers but when we save it.. it still says invalid</p><p>[automerge]1587028028[/automerge]</p><p></p><p></p><p>here's our code</p><p></p><p>[SPOILER="SaveFloorPlanModelEvent:"]</p><p>using System;</p><p>using System.Linq;</p><p>using System.Text;</p><p>using System.Data;</p><p>using System.Collections.Generic;</p><p></p><p>using Plus.HabboHotel.Rooms;</p><p>using Plus.Communication.Packets.Outgoing.Rooms.Session;</p><p>using Plus.Communication.Packets.Outgoing.Rooms.Notifications;</p><p>using Plus.Database.Interfaces;</p><p>using Plus.HabboHotel.Items;</p><p></p><p>namespace Plus.Communication.Packets.Incoming.Rooms.FloorPlan</p><p>{</p><p> class SaveFloorPlanModelEvent : IPacketEvent</p><p> {</p><p> public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)</p><p> {</p><p> if (!Session.GetHabbo().InRoom)</p><p> return;</p><p></p><p> Room Room = Session.GetHabbo().CurrentRoom;</p><p> if (Room == null || Session.GetHabbo().CurrentRoomId != Room.Id || !Room.CheckRights(Session, true))</p><p> return;</p><p></p><p> char[] validLetters =</p><p> {</p><p> '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g',</p><p> 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', '\r'</p><p> };</p><p></p><p> string Map = Packet.PopString().ToLower().TrimEnd();</p><p></p><p> if (Map.Length > 4159) //4096 + New Lines = 4159</p><p> {</p><p> Session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "(%%%general%%%): %%%too_large_area%%% (%%%max%%% 2048 %%%tiles%%%)"));</p><p> return;</p><p> }</p><p></p><p> if(Map.Any(letter => !validLetters.Contains(letter)) || String.IsNullOrEmpty(Map))</p><p> {</p><p> Session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "Oops, it appears that you have entered an invalid floor map!"));</p><p> return;</p><p> }</p><p></p><p> var modelData = Map.Split('\r');</p><p></p><p> int SizeY = modelData.Length;</p><p> int SizeX = modelData[0].Length;</p><p></p><p> if (SizeY > 100 || SizeX > 100)</p><p> {</p><p> Session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "The maximum height and width of a model is 64x64!"));</p><p> return;</p><p> }</p><p></p><p> int lastLineLength = 0;</p><p> bool isValid = true;</p><p></p><p> for (int i = 0; i < modelData.Length; i++)</p><p> {</p><p> if (lastLineLength == 0)</p><p> {</p><p> lastLineLength = modelData<em>.Length;</em></p><p><em> continue;</em></p><p><em> }</em></p><p><em></em></p><p><em> if (lastLineLength != modelData<em>.Length)</em></em></p><p><em><em> {</em></em></p><p><em><em> isValid = false;</em></em></p><p><em><em> }</em></em></p><p><em><em> }</em></em></p><p><em><em></em></em></p><p><em><em> if (!isValid)</em></em></p><p><em><em> {</em></em></p><p><em><em> Session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "Oops, it appears that you have entered an invalid floor map!"));</em></em></p><p><em><em> return;</em></em></p><p><em><em> }</em></em></p><p><em><em></em></em></p><p><em><em> int DoorX = Packet.PopInt();</em></em></p><p><em><em> int DoorY = Packet.PopInt();</em></em></p><p><em><em> int DoorDirection = Packet.PopInt();</em></em></p><p><em><em> int WallThick = Packet.PopInt();</em></em></p><p><em><em> int FloorThick = Packet.PopInt();</em></em></p><p><em><em> int WallHeight = Packet.PopInt();</em></em></p><p><em><em></em></em></p><p><em><em> int DoorZ = 0;</em></em></p><p><em><em></em></em></p><p><em><em> try</em></em></p><p><em><em> {</em></em></p><p><em><em> DoorZ = parse(modelData[DoorY][DoorX]);</em></em></p><p><em><em> }</em></em></p><p><em><em> catch { }</em></em></p><p><em><em></em></em></p><p><em><em> if (WallThick > 1)</em></em></p><p><em><em> WallThick = 1;</em></em></p><p><em><em></em></em></p><p><em><em> if (WallThick < -2)</em></em></p><p><em><em> WallThick = -2;</em></em></p><p><em><em></em></em></p><p><em><em> if (FloorThick > 1)</em></em></p><p><em><em> FloorThick = 1;</em></em></p><p><em><em></em></em></p><p><em><em> if (FloorThick < -2)</em></em></p><p><em><em> WallThick = -2;</em></em></p><p><em><em></em></em></p><p><em><em> if (WallHeight < 0)</em></em></p><p><em><em> WallHeight = 0;</em></em></p><p><em><em></em></em></p><p><em><em> if (WallHeight > 15)</em></em></p><p><em><em> WallHeight = 15;</em></em></p><p><em><em></em></em></p><p><em><em> string ModelName = "model_bc_" + Room.Id;</em></em></p><p><em><em></em></em></p><p><em><em> Map += '\r' + new string('x', SizeX);</em></em></p><p><em><em></em></em></p><p><em><em> DataRow Row = null;</em></em></p><p><em><em> using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</em></em></p><p><em><em> {</em></em></p><p><em><em> dbClient.SetQuery("SELECT * FROM `room_models` WHERE `id` = @model AND `custom` = '1' LIMIT 1");</em></em></p><p><em><em> dbClient.AddParameter("model", "model_bc_" + Room.Id);</em></em></p><p><em><em> Row = dbClient.GetRow();</em></em></p><p><em><em></em></em></p><p><em><em> if (Row == null)//The row is still null, let's insert instead.</em></em></p><p><em><em> {</em></em></p><p><em><em> dbClient.SetQuery("INSERT INTO `room_models` (`id`,`door_x`,`door_y`, `door_z`, `door_dir`,`heightmap`,`custom`,`wall_height`) VALUES (@ModelName, @DoorX, @DoorY, @DoorZ, @DoorDirection, @Map,'1',@WallHeight)");</em></em></p><p><em><em> dbClient.AddParameter("ModelName", "model_bc_" + Room.Id);</em></em></p><p><em><em> dbClient.AddParameter("DoorX", DoorX);</em></em></p><p><em><em> dbClient.AddParameter("DoorY", DoorY);</em></em></p><p><em><em> dbClient.AddParameter("DoorDirection", DoorDirection);</em></em></p><p><em><em> dbClient.AddParameter("DoorZ", DoorZ);</em></em></p><p><em><em> dbClient.AddParameter("Map", Map);</em></em></p><p><em><em> dbClient.AddParameter("WallHeight", WallHeight);</em></em></p><p><em><em> dbClient.RunQuery();</em></em></p><p><em><em> }</em></em></p><p><em><em> else</em></em></p><p><em><em> {</em></em></p><p><em><em> dbClient.SetQuery("UPDATE `room_models` SET `heightmap` = @Map, `door_x` = @DoorX, `door_y` = @DoorY, `door_z` = @DoorZ, `door_dir` = @DoorDirection, `wall_height` = @WallHeight WHERE `id` = @ModelName LIMIT 1");</em></em></p><p><em><em> dbClient.AddParameter("ModelName", "model_bc_" + Room.Id);</em></em></p><p><em><em> dbClient.AddParameter("Map", Map);</em></em></p><p><em><em> dbClient.AddParameter("DoorX", DoorX);</em></em></p><p><em><em> dbClient.AddParameter("DoorY", DoorY);</em></em></p><p><em><em> dbClient.AddParameter("DoorZ", DoorZ);</em></em></p><p><em><em> dbClient.AddParameter("DoorDirection", DoorDirection);</em></em></p><p><em><em> dbClient.AddParameter("WallHeight", WallHeight);</em></em></p><p><em><em> dbClient.RunQuery();</em></em></p><p><em><em> }</em></em></p><p><em><em></em></em></p><p><em><em> dbClient.SetQuery("UPDATE `rooms` SET `model_name` = @ModelName, `wallthick` = @WallThick, `floorthick` = @FloorThick WHERE `id` = @roomId LIMIT 1");</em></em></p><p><em><em> dbClient.AddParameter("roomId", Room.Id);</em></em></p><p><em><em> dbClient.AddParameter("ModelName", "model_bc_" + Room.Id);</em></em></p><p><em><em> dbClient.AddParameter("WallThick", WallThick);</em></em></p><p><em><em> dbClient.AddParameter("FloorThick", FloorThick);</em></em></p><p><em><em> dbClient.RunQuery();</em></em></p><p><em><em> }</em></em></p><p><em><em></em></em></p><p><em><em> Room.RoomData.ModelName = ModelName;</em></em></p><p><em><em> Room.RoomData.WallThickness = WallThick;</em></em></p><p><em><em> Room.RoomData.FloorThickness = FloorThick;</em></em></p><p><em><em></em></em></p><p><em><em> List<RoomUser> UsersToReturn = Room.GetRoomUserManager().GetRoomUsers().ToList();</em></em></p><p><em><em></em></em></p><p><em><em> PlusEnvironment.GetGame().GetRoomManager().ReloadModel(ModelName);</em></em></p><p><em><em> PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(Room);</em></em></p><p><em><em></em></em></p><p><em><em></em></em></p><p><em><em> foreach (RoomUser User in UsersToReturn)</em></em></p><p><em><em> {</em></em></p><p><em><em> if (User == null || User.GetClient() == null)</em></em></p><p><em><em> continue;</em></em></p><p><em><em></em></em></p><p><em><em> User.GetClient().SendPacket(new RoomForwardComposer(Room.Id));</em></em></p><p><em><em> }</em></em></p><p><em><em> }</em></em></p><p><em><em></em></em></p><p><em><em> public static short parse(char input)</em></em></p><p><em><em> {</em></em></p><p><em><em></em></em></p><p><em><em> switch (input)</em></em></p><p><em><em> {</em></em></p><p><em><em> default:</em></em></p><p><em><em> case '0':</em></em></p><p><em><em> return 0;</em></em></p><p><em><em> case '1':</em></em></p><p><em><em> return 1;</em></em></p><p><em><em> case '2':</em></em></p><p><em><em> return 2;</em></em></p><p><em><em> case '3':</em></em></p><p><em><em> return 3;</em></em></p><p><em><em> case '4':</em></em></p><p><em><em> return 4;</em></em></p><p><em><em> case '5':</em></em></p><p><em><em> return 5;</em></em></p><p><em><em> case '6':</em></em></p><p><em><em> return 6;</em></em></p><p><em><em> case '7':</em></em></p><p><em><em> return 7;</em></em></p><p><em><em> case '8':</em></em></p><p><em><em> return 8;</em></em></p><p><em><em> case '9':</em></em></p><p><em><em> return 9;</em></em></p><p><em><em> case 'a':</em></em></p><p><em><em> return 10;</em></em></p><p><em><em> case 'b':</em></em></p><p><em><em> return 11;</em></em></p><p><em><em> case 'c':</em></em></p><p><em><em> return 12;</em></em></p><p><em><em> case 'd':</em></em></p><p><em><em> return 13;</em></em></p><p><em><em> case 'e':</em></em></p><p><em><em> return 14;</em></em></p><p><em><em> case 'f':</em></em></p><p><em><em> return 15;</em></em></p><p><em><em> case 'g':</em></em></p><p><em><em> return 16;</em></em></p><p><em><em> case 'h':</em></em></p><p><em><em> return 17;</em></em></p><p><em><em> case 'i':</em></em></p><p><em><em> return 18;</em></em></p><p><em><em> case 'j':</em></em></p><p><em><em> return 19;</em></em></p><p><em><em> case 'k':</em></em></p><p><em><em> return 20;</em></em></p><p><em><em> case 'l':</em></em></p><p><em><em> return 21;</em></em></p><p><em><em> case 'm':</em></em></p><p><em><em> return 22;</em></em></p><p><em><em> case 'n':</em></em></p><p><em><em> return 23;</em></em></p><p><em><em> case 'o':</em></em></p><p><em><em> return 24;</em></em></p><p><em><em> case 'p':</em></em></p><p><em><em> return 25;</em></em></p><p><em><em> case 'q':</em></em></p><p><em><em> return 26;</em></em></p><p><em><em> case 'r':</em></em></p><p><em><em> return 27;</em></em></p><p><em><em> case 's':</em></em></p><p><em><em> return 28;</em></em></p><p><em><em> case 't':</em></em></p><p><em><em> return 29;</em></em></p><p><em><em> case 'u':</em></em></p><p><em><em> return 30;</em></em></p><p><em><em> case 'v':</em></em></p><p><em><em> return 31;</em></em></p><p><em><em> case 'w':</em></em></p><p><em><em> return 32;</em></em></p><p><em><em> }</em></em></p><p><em><em> }</em></em></p><p><em><em> }</em></em></p><p><em><em>}</em></em></p><p><em><em></em></em>[/SPOILER]</p></blockquote><p></p>
[QUOTE="habpoppw, post: 458939, member: 92512"] hi, thanks for replying. we found it and tried to maximize the 64 numbers but when we save it.. it still says invalid [automerge]1587028028[/automerge] here's our code [SPOILER="SaveFloorPlanModelEvent:"] using System; using System.Linq; using System.Text; using System.Data; using System.Collections.Generic; using Plus.HabboHotel.Rooms; using Plus.Communication.Packets.Outgoing.Rooms.Session; using Plus.Communication.Packets.Outgoing.Rooms.Notifications; using Plus.Database.Interfaces; using Plus.HabboHotel.Items; namespace Plus.Communication.Packets.Incoming.Rooms.FloorPlan { class SaveFloorPlanModelEvent : IPacketEvent { public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) return; Room Room = Session.GetHabbo().CurrentRoom; if (Room == null || Session.GetHabbo().CurrentRoomId != Room.Id || !Room.CheckRights(Session, true)) return; char[] validLetters = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', '\r' }; string Map = Packet.PopString().ToLower().TrimEnd(); if (Map.Length > 4159) //4096 + New Lines = 4159 { Session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "(%%%general%%%): %%%too_large_area%%% (%%%max%%% 2048 %%%tiles%%%)")); return; } if(Map.Any(letter => !validLetters.Contains(letter)) || String.IsNullOrEmpty(Map)) { Session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "Oops, it appears that you have entered an invalid floor map!")); return; } var modelData = Map.Split('\r'); int SizeY = modelData.Length; int SizeX = modelData[0].Length; if (SizeY > 100 || SizeX > 100) { Session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "The maximum height and width of a model is 64x64!")); return; } int lastLineLength = 0; bool isValid = true; for (int i = 0; i < modelData.Length; i++) { if (lastLineLength == 0) { lastLineLength = modelData[i].Length; continue; } if (lastLineLength != modelData[i].Length) { isValid = false; } } if (!isValid) { Session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "Oops, it appears that you have entered an invalid floor map!")); return; } int DoorX = Packet.PopInt(); int DoorY = Packet.PopInt(); int DoorDirection = Packet.PopInt(); int WallThick = Packet.PopInt(); int FloorThick = Packet.PopInt(); int WallHeight = Packet.PopInt(); int DoorZ = 0; try { DoorZ = parse(modelData[DoorY][DoorX]); } catch { } if (WallThick > 1) WallThick = 1; if (WallThick < -2) WallThick = -2; if (FloorThick > 1) FloorThick = 1; if (FloorThick < -2) WallThick = -2; if (WallHeight < 0) WallHeight = 0; if (WallHeight > 15) WallHeight = 15; string ModelName = "model_bc_" + Room.Id; Map += '\r' + new string('x', SizeX); DataRow Row = null; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `room_models` WHERE `id` = @model AND `custom` = '1' LIMIT 1"); dbClient.AddParameter("model", "model_bc_" + Room.Id); Row = dbClient.GetRow(); if (Row == null)//The row is still null, let's insert instead. { dbClient.SetQuery("INSERT INTO `room_models` (`id`,`door_x`,`door_y`, `door_z`, `door_dir`,`heightmap`,`custom`,`wall_height`) VALUES (@ModelName, @DoorX, @DoorY, @DoorZ, @DoorDirection, @Map,'1',@WallHeight)"); dbClient.AddParameter("ModelName", "model_bc_" + Room.Id); dbClient.AddParameter("DoorX", DoorX); dbClient.AddParameter("DoorY", DoorY); dbClient.AddParameter("DoorDirection", DoorDirection); dbClient.AddParameter("DoorZ", DoorZ); dbClient.AddParameter("Map", Map); dbClient.AddParameter("WallHeight", WallHeight); dbClient.RunQuery(); } else { dbClient.SetQuery("UPDATE `room_models` SET `heightmap` = @Map, `door_x` = @DoorX, `door_y` = @DoorY, `door_z` = @DoorZ, `door_dir` = @DoorDirection, `wall_height` = @WallHeight WHERE `id` = @ModelName LIMIT 1"); dbClient.AddParameter("ModelName", "model_bc_" + Room.Id); dbClient.AddParameter("Map", Map); dbClient.AddParameter("DoorX", DoorX); dbClient.AddParameter("DoorY", DoorY); dbClient.AddParameter("DoorZ", DoorZ); dbClient.AddParameter("DoorDirection", DoorDirection); dbClient.AddParameter("WallHeight", WallHeight); dbClient.RunQuery(); } dbClient.SetQuery("UPDATE `rooms` SET `model_name` = @ModelName, `wallthick` = @WallThick, `floorthick` = @FloorThick WHERE `id` = @roomId LIMIT 1"); dbClient.AddParameter("roomId", Room.Id); dbClient.AddParameter("ModelName", "model_bc_" + Room.Id); dbClient.AddParameter("WallThick", WallThick); dbClient.AddParameter("FloorThick", FloorThick); dbClient.RunQuery(); } Room.RoomData.ModelName = ModelName; Room.RoomData.WallThickness = WallThick; Room.RoomData.FloorThickness = FloorThick; List<RoomUser> UsersToReturn = Room.GetRoomUserManager().GetRoomUsers().ToList(); PlusEnvironment.GetGame().GetRoomManager().ReloadModel(ModelName); PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(Room); foreach (RoomUser User in UsersToReturn) { if (User == null || User.GetClient() == null) continue; User.GetClient().SendPacket(new RoomForwardComposer(Room.Id)); } } public static short parse(char input) { switch (input) { default: case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; case 'a': return 10; case 'b': return 11; case 'c': return 12; case 'd': return 13; case 'e': return 14; case 'f': return 15; case 'g': return 16; case 'h': return 17; case 'i': return 18; case 'j': return 19; case 'k': return 20; case 'l': return 21; case 'm': return 22; case 'n': return 23; case 'o': return 24; case 'p': return 25; case 'q': return 26; case 'r': return 27; case 's': return 28; case 't': return 29; case 'u': return 30; case 'v': return 31; case 'w': return 32; } } } } [/i][/i][/SPOILER][i][i][/i][/i] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
:Floor Plan Problem
Top