[Release] Room On Register

Joe

Well-Known Member
Jun 10, 2012
4,090
1,918
Yeah, just make an enum and when the room is made set noob=0 instead of 1 or something a long those lines.
 

MadMonsterMan

Member
Mar 25, 2016
202
13
Yeah the 2nd code was not tested though, I just coded it in notepad.
 
OH ON THE 2ND CODE THERE ISN'T A TEST TO SEE IF THERE IS A NEW USER OR NOT! TAKE THAT FROM EXAMPLE #1 OTHERWISE IT WILL MAKE A NEW ROOM EVERYTIME :)
 
Fixed The Code:

Code:
// 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']."')");
    }

}
Just incase they try and copy and paste lmao
PHP:
<?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']."')");
    }

}
?>
 

anthonyy

Member
Dec 23, 2014
127
10
Okay, so I have my hotel on local host it's just for me to learn new stuff, and i've had my hotel working and i've been on the client for most of the day.

then i followed your tutorial...
and everything was fine, i just had a black room, so i thought to myself, i'll do everyone again just to double check. Next thing you know i'm unable to get onto my client it's stuck at 76% I've deleted the code that was added from the client but for some reason it's still stuck at 76% so i'm a little confused. my emu has come up with no errors and so have the mod tools on google chrome. If anyone has any ideas or has come across this themselves then please let me know how to fix thank you. :up:
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
Okay, so I have my hotel on local host it's just for me to learn new stuff, and i've had my hotel working and i've been on the client for most of the day.

then i followed your tutorial...
and everything was fine, i just had a black room, so i thought to myself, i'll do everyone again just to double check. Next thing you know i'm unable to get onto my client it's stuck at 76% I've deleted the code that was added from the client but for some reason it's still stuck at 76% so i'm a little confused. my emu has come up with no errors and so have the mod tools on google chrome. If anyone has any ideas or has come across this themselves then please let me know how to fix thank you. :up:
Go into your `Rooms` table, did it make the room successfully with the correct room_id?
 

anthonyy

Member
Dec 23, 2014
127
10
this works great release! but unfortunately every time a user who already has a welcome room enters it creates a new welcome room for them. for example 1 user has 4 rooms, how to stop this from happening?
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
this works great release! but unfortunately every time a user who already has a welcome room enters it creates a new welcome room for them. for example 1 user has 4 rooms, how to stop this from happening?
That can only happen if the code is not correct:

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']."')");
  }

}
?>


$getStats = mysql_query("SELECT null FROM `user_stats` WHERE id = '".$_SESSION['user']['id']."'");
if(mysql_num_rows($getStats) != 1){

This will test if they have ever entered the client before, because on first login you get a row created for your user stats
 

anthonyy

Member
Dec 23, 2014
127
10
does anyone know how to remove this from my hotel? I've deleted the code from the client.php and truncate all the tables in navicat but it's still creating rooms for users.
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
does anyone know how to remove this from my hotel? I've deleted the code from the client.php and truncate all the tables in navicat but it's still creating rooms for users.
Make sure you deleted the client code under the right skin.
 

Users who are viewing this thread

Top