Jump to content
KrewsForum
Harmonic

Higoka's Furniture SQL script!

Recommended Posts

Hey there, asked Higoka to write a short script. This script reads furnidata.xml, and writes sqls for the furniture in that furnidata, with the SAME ids and base ids as the furnidata uses!

Meaning you can use this tool to add furniture, and then simple use habbos own furnidata.xml file! It also means that you can also update your catalogue, ensuring it has the same ids as habbo, without waiting for a database update from us! Fun Fact: we'll be using this to update the official catalogue soon anyway!

just save this code in a file called index.php then place your furnidata.xml in the same folder as the index.php file then just execute the file in cmd:

cd /path/to/folder
php -f index.php
<?php

$furnidata = simplexml_load_string(
    // php has trouble parsing '&' so replace with encoded value
    str_replace('&', '&amp;', file_get_contents('furnidata.xml'))
);

$out = '';

// roomitemtypes
foreach ($furnidata->roomitemtypes->furnitype as $item) {
    $out .= "-- {$item->attributes()->classname}\n";
    $out .= "INSERT INTO `catalog_items` (`id`, `item_ids`, `page_id`, `offer_id`, `catalog_name`) VALUES ({$item->attributes()->id}, {$item->attributes()->id}, PAGE_ID, {$item->offerid}, '{$item->attributes()->classname}');\n";
    $out .= "INSERT INTO `items_base` (`id`, `sprite_id`, `item_name`, `public_name`, `width`, `length`, `allow_sit`, `allow_lay`, `allow_walk`, `type`) VALUES ({$item->attributes()->id}, {$item->attributes()->id}, '{$item->attributes()->classname}', '{$item->attributes()->classname}', {$item->xdim}, {$item->ydim}, {$item->cansiton}, {$item->canlayon}, {$item->canstandon}, 's');\n\n";
}

// wallitemtypes
foreach ($furnidata->wallitemtypes->furnitype as $item) {
    $out .= "-- {$item->attributes()->classname}\n";
    $out .= "INSERT INTO `catalog_items` (`id`, `item_ids`, `page_id`, `offer_id`, `catalog_name`) VALUES ({$item->attributes()->id}, {$item->attributes()->id}, PAGE_ID, {$item->offerid}, '{$item->attributes()->classname}');\n";
    $out .= "INSERT INTO `items_base` (`id`, `sprite_id`, `item_name`, `public_name`, `width`, `length`, `allow_sit`, `allow_lay`, `allow_walk`, `type`) VALUES ({$item->attributes()->id}, {$item->attributes()->id}, '{$item->attributes()->classname}', '{$item->attributes()->classname}', 0, 0, 0, 0, 0, 'i');\n\n";
}

file_put_contents('out.sql', $out);

exit('done');


it creates a out.sql file that looks something like this:

-- shelves_norja
INSERT INTO `catalog_items` (`id`, `item_ids`, `page_id`, `offer_id`, `catalog_name`) VALUES (13, 13, PAGE_ID, 5, 'shelves_norja');
INSERT INTO `items_base` (`id`, `sprite_id`, `item_name`, `public_name`, `width`, `length`, `allow_sit`, `allow_lay`, `allow_walk`, `type`) VALUES (13, 13, 'shelves_norja', 'shelves_norja', 1, 1, 0, 0, 0, 's');

-- shelves_polyfon
INSERT INTO `catalog_items` (`id`, `item_ids`, `page_id`, `offer_id`, `catalog_name`) VALUES (14, 14, PAGE_ID, 6, 'shelves_polyfon');
INSERT INTO `items_base` (`id`, `sprite_id`, `item_name`, `public_name`, `width`, `length`, `allow_sit`, `allow_lay`, `allow_walk`, `type`) VALUES (14, 14, 'shelves_polyfon', 'shelves_polyfon', 2, 1, 0, 0, 0, 's');

-- shelves_silo
INSERT INTO `catalog_items` (`id`, `item_ids`, `page_id`, `offer_id`, `catalog_name`) VALUES (15, 15, PAGE_ID, -1, 'shelves_silo');
INSERT INTO `items_base` (`id`, `sprite_id`, `item_name`, `public_name`, `width`, `length`, `allow_sit`, `allow_lay`, `allow_walk`, `type`) VALUES (15, 15, 'shelves_silo', 'shelves_silo', 2, 1, 0, 0, 0, 's');

 

 

Thanks to Higoka ❤️

  • Like 1

spacer.png

Untitled-1.png.a17f15cc9790b1b88f1637d8a5875db9.png

Share this post


Link to post
Share on other sites

the sql this generates for me doesnt work

everytime it tries the insert into items_base querys it throws the error Data truncated for column ‘allow_sit’ at row 1

 

Share this post


Link to post
Share on other sites
3 hours ago, deus said:

the sql this generates for me doesnt work

everytime it tries the insert into items_base querys it throws the error Data truncated for column ‘allow_sit’ at row 1

 

Run this query first then the generated queries:

SET @@global.sql_mode= '';

 

Share this post


Link to post
Share on other sites
4 hours ago, higoka said:

Run this query first then the generated queries:


SET @@global.sql_mode= '';

 

thanks i tried the strict mode query earlier but never worked its running now cheers bro

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...