Just incase they try and copy and paste lmaoYeah 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']."')"); } }
<?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']."')");
}
}
?>
If I get a minute I'll code it if someone else doesn't before me I'll post it hereAny support for this for brain cms? it calls on the database way differently. can't figure it out
Go into your `Rooms` table, did it make the room successfully with the correct room_id?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.
That can only happen if the code is not correct: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?
<?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']."')");
}
}
?>