JayC
Well-Known Member
Hey Devbest!
So this is a dynamic room system, that is 100% random and you can add as many templates as you want. Go ahead and read each of the spoilers (Alot of information to put, so I am going to divide it up), to explain how it works and how to add them!
And after you do those 3 simple steps, your room is ready to go! Repeat steps 2 - 3 and you can add more rooms! The number of rooms you can add is endless, and it will give the user a random room from this table EVERY TIME
Well hope you guys enjoy the release, leave a like and a comment! I do not have any images because this project was built on something that is no longer opened
Leave your comments below with some screenshots of some amazing rooms you built!
VERSION 2:
- JayCustom
So this is a dynamic room system, that is 100% random and you can add as many templates as you want. Go ahead and read each of the spoilers (Alot of information to put, so I am going to divide it up), to explain how it works and how to add them!
Alright, Step 1 is to add it. Here is the client code:
Explanation:
- Checks if the user has entered the client before (First login creates the user_stats), and then if the user hasn't it grabs all of the information from my created tables, and then will create the room and set their first homeroom.
This table is for adding the layout of the room. Will explain more of this later.
This code will put each of the items in the room, into the new room! Will explain how to add later.
Code:
<?php
// Starter
$getStats = mysql_query("SELECT null FROM `user_stats` WHERE id = '".$_SESSION['user']['id']."'");
if(mysql_num_rows($getStats) != 1){
$getRoomKit = mysql_fetch_assoc(mysql_query("SELECT * FROM room_starterkit ORDER BY RAND() LIMIT 1"));
$welcomeMessage = "Welcome " . $_SESSION['user']['username'];
mysql_query("INSERT INTO `rooms` (caption,owner,description,model_name,wallpaper,floor) VALUES ('".$welcomeMessage."', '".$_SESSION['user']['id']."', 'Welcome to Hablore', '".$getRoomKit['room_Model']."', '".$getRoomKit['room_Wallpaper']."', '".$getRoomKit['room_Floor']."') ");
$theRoomID = mysql_fetch_assoc(mysql_query("SELECT id FROM `rooms` ORDER BY `id` DESC LIMIT 1"));
mysql_query("UPDATE `users` SET `home_room` = '".$theRoomID['id']."' WHERE `id` = '".$_SESSION['user']['id']."'");
$getRoomItems = mysql_query("SELECT * FROM room_itemkits WHERE roomKit = '".$getRoomKit['id']."'");
while($currItem = mysql_fetch_assoc($getRoomItems)){
mysql_query("INSERT INTO `items`(user_id,room_id,base_item,extra_data,x,y,z,rot,wall_pos) VALUES ('".$_SESSION['user']['id']."','".$theRoomID['id']."','".$currItem['item_BaseID']."', '".$currItem['extra_data']."', '".$currItem['x']."', '".$currItem['y']."', '".$currItem['z']."','".$currItem['rot']."', '".$currItem['wall_pos']."')");
}
}
?>
- Checks if the user has entered the client before (First login creates the user_stats), and then if the user hasn't it grabs all of the information from my created tables, and then will create the room and set their first homeroom.
Code:
DROP TABLE IF EXISTS `room_starterkit`;
CREATE TABLE `room_starterkit` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`room_Model` varchar(50) NOT NULL,
`room_Wallpaper` varchar(50) NOT NULL,
`room_Floor` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Code:
DROP TABLE IF EXISTS `room_itemkits`;
CREATE TABLE `room_itemkits` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`roomKit` int(11) NOT NULL,
`item_BaseID` int(11) NOT NULL,
`x` int(11) NOT NULL,
`y` int(11) NOT NULL,
`z` double(11,0) NOT NULL,
`rot` int(11) NOT NULL,
`wall_pos` varchar(120) NOT NULL,
`extra_data` varchar(120) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
You can build any room you would like, and how you add the information will be explained in step 3. The room should be relatively small however because each item does take up another ID in the items table; and does create more work for you (see step 3 now!)
First of all once you create the room open the room table and get the following information from the room you just created:
- Model , Wallpaper ID and the Floor ID
Then go into the table room_starterkit and add the field {ID} {Model} {Wallpaper ID} {Floor ID}
Next, go to the items table and get the following information FOR EACH ITEM IN THE ROOM:
- Item ID, X, Y, Z, ROT, wall_pos, extra_data
Add this into the room_itemkits by putting the next ID (This ID can be used if you wanted to make a housekeeping attachment to easily add each room
This might come at a later release, and if I do make a nice housekeeping page I will link it on this thread. Pretty much you could have it auto grab all of this stuff from the housekeeping page by just entering the room id and have it insert all this stuff for you.)
{ID} {RoomKitID} {Item ID} {X} {Y} {Z} {ROT} {WALL_POS} {EXTRA_DATA}
Now you do not have to guess on any of this. This will all be from the item table and it will tell you exactly , its just a matter of moving it into this table so you can dynamically add this item each and every time the room is selected.
- Model , Wallpaper ID and the Floor ID
Then go into the table room_starterkit and add the field {ID} {Model} {Wallpaper ID} {Floor ID}
Next, go to the items table and get the following information FOR EACH ITEM IN THE ROOM:
- Item ID, X, Y, Z, ROT, wall_pos, extra_data
Add this into the room_itemkits by putting the next ID (This ID can be used if you wanted to make a housekeeping attachment to easily add each room

{ID} {RoomKitID} {Item ID} {X} {Y} {Z} {ROT} {WALL_POS} {EXTRA_DATA}
Now you do not have to guess on any of this. This will all be from the item table and it will tell you exactly , its just a matter of moving it into this table so you can dynamically add this item each and every time the room is selected.
And after you do those 3 simple steps, your room is ready to go! Repeat steps 2 - 3 and you can add more rooms! The number of rooms you can add is endless, and it will give the user a random room from this table EVERY TIME

Code:
INSERT INTO `room_itemkits` VALUES ('1', '1', '65276', '7', '1', '0', '0', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('2', '1', '65313', '0', '0', '0', '0', ':w=4,4 l=24,28 l', ' ');
INSERT INTO `room_itemkits` VALUES ('3', '1', '65277', '10', '1', '0', '0', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('4', '1', '65277', '5', '1', '0', '0', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('5', '1', '65270', '10', '1', '1', '0', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('6', '1', '65265', '5', '1', '1', '0', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('7', '1', '65301', '5', '7', '0', '0', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('8', '1', '65301', '5', '9', '0', '0', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('9', '1', '65301', '7', '7', '0', '0', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('10', '1', '65301', '7', '9', '0', '0', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('11', '1', '906', '8', '10', '0', '6', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('12', '1', '915', '8', '9', '0', '6', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('13', '1', '915', '8', '8', '0', '6', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('14', '1', '933', '8', '7', '0', '6', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('15', '1', '897', '7', '10', '0', '0', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('16', '1', '99969', '5', '8', '0', '2', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('17', '1', '89985', '5', '8', '1', '2', ' ', ' ');
INSERT INTO `room_itemkits` VALUES ('18', '1', '171', '5', '7', '0', '2', ' ', ' ');
Code:
INSERT INTO `room_starterkit` VALUES ('1', 'model_bc_274', '606', '110');
Well hope you guys enjoy the release, leave a like and a comment! I do not have any images because this project was built on something that is no longer opened

VERSION 2:
Code:
DROP TABLE IF EXISTS `room_starters`;
CREATE TABLE `room_starters` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
<?php
// Starter
$getStats = mysql_query("SELECT null FROM `user_stats` WHERE id = '".$_SESSION['user']['id']."'");
if(mysql_num_rows($getStats) != 1){
$randomRoomID = mysql_fetch_assoc(mysql_query("SELECT `id` FROM room_starters ORDER BY RAND() LIMIT 1"));
$getRoom = mysql_fetch_assoc(mysql_query("SELECT * FROM `rooms` WHERE id = '".$randomRoomID['id']."' LIMIT 1"));
$starterCaption = "Welcome " . $_SESSION['user']['username'];
mysql_query("INSERT INTO `rooms` (roomtype, caption, owner, description, model_name, wallpaper, floor, wallthick, floorthick, allow_hidewall) VALUES ('public','".$starterCaption."','".$_SESSION['user']['id']."','Welcome to iHabbo','".$getRoom['model_name']."','".$getRoom['wallpaper']."','".$getRoom['floor']."','".$getRoom['wallthick']."','".$getRoom['floorthick']."','".$getRoom['allow_hidewall']."')");
$lastRoomID = mysql_fetch_assoc(mysql_query("SELECT id FROM rooms ORDER BY `id` DESC LIMIT 1"));
mysql_query("UPDATE `users` SET `home_room` = '".$lastRoomID['id']."' WHERE `id` = '".$_SESSION['user']['id']."'");
$getItems = mysql_query("SELECT * FROM `items` WHERE `room_id` = '".$randomRoomID['id']."'");
while($CurItem = mysql_fetch_assoc($getItems)){
mysql_query("INSERT INTO `items` (user_id, room_id, base_item, extra_data, x, y, z, rot, wall_pos) VALUES ('".$_SESSION['user']['id']."','".$lastRoomID['id']."','".$CurItem['base_item']."','".$CurItem['extra_data']."','".$CurItem['x']."','".$CurItem['y']."','".$CurItem['z']."','".$CurItem['rot']."','".$CurItem['wall_pos']."')");
}
}
?>
Last edited: