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 Releases
[Script] Catalogue Search Fix for ALL retros [Script]
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="Bop" data-source="post: 484355" data-attributes="member: 94210"><p>If you are searching a furniture and clicking an item but it shows a wall item type. This fix is for you!</p><p></p><p>First, run this query </p><p>[CODE=sql]</p><p>UPDATE catalog_items</p><p>SET offer_id = CASE</p><p> WHEN item_ids LIKE '%;%' AND SUBSTRING_INDEX(item_ids, ';', 1) REGEXP '^[0-9]+$' THEN CAST(SUBSTRING_INDEX(item_ids, ';', 1) AS UNSIGNED)</p><p> WHEN item_ids LIKE '%:%' AND SUBSTRING_INDEX(item_ids, ':', 1) REGEXP '^[0-9]+$' THEN CAST(SUBSTRING_INDEX(item_ids, ':', 1) AS UNSIGNED)</p><p> WHEN item_ids REGEXP '^[0-9]+$' THEN CAST(item_ids AS UNSIGNED)</p><p> ELSE 0 -- or another appropriate default value</p><p>END;[/CODE]</p><p>This will match all id's in the offer_item column to the item_ids column</p><p></p><p>Second, after running this query, you will need to install NodeJS, if it's already than no need to install it again</p><p><a href="https://nodejs.org/en" target="_blank">NodeJS Installation</a></p><p></p><p>Third step, place this file/script inside gamedata folder where your FurnitureData.json is located and edit the database credentials to match your current database credentials</p><p></p><p>RECOMMENDED: Make a backup of your FurnitureData.json</p><p></p><p>[CODE=javascript]</p><p>const fs = require('fs');</p><p>const mysql = require('mysql2');</p><p>const { performance } = require('perf_hooks');</p><p></p><p>// Database connection configuration</p><p>const dbConfig = {</p><p> host: 'localhost',</p><p> user: 'root',</p><p> password: 'PASSWORD',</p><p> database: 'DBNAME'</p><p>};</p><p></p><p>const connection = mysql.createConnection(dbConfig);</p><p></p><p>function updateOfferIdsForSection(furniTypes, callback) {</p><p> let completed = 0;</p><p> furniTypes.forEach((furniture, index) => {</p><p> const query = 'SELECT offer_id FROM catalog_items WHERE catalog_name = ?';</p><p> connection.query(query, [furniture.classname], (error, results) => {</p><p> if (error) {</p><p> console.error('Error querying database:', error);</p><p> return callback(error);</p><p> }</p><p> if (results.length > 0) {</p><p> furniture.offerid = results[0].offer_id;</p><p> console.log(`Updated offerid for ${furniture.classname} to ${results[0].offer_id}`);</p><p> } else {</p><p> console.log(`No matching record found for ${furniture.classname}`);</p><p> }</p><p> completed++;</p><p> if (completed === furniTypes.length) {</p><p> callback();</p><p> }</p><p> });</p><p> });</p><p>}</p><p></p><p>const start = performance.now();</p><p></p><p>fs.readFile('FurnitureData.json', 'utf8', (err, data) => {</p><p> if (err) {</p><p> console.error('Error reading file:', err);</p><p> return;</p><p> }</p><p></p><p> const furnitureData = JSON.parse(data);</p><p></p><p> updateOfferIdsForSection(furnitureData.wallitemtypes.furnitype, (error) => {</p><p> if (error) {</p><p> console.error('Error updating wall item types:', error);</p><p> return;</p><p> }</p><p></p><p> updateOfferIdsForSection(furnitureData.roomitemtypes.furnitype, (error) => {</p><p> if (error) {</p><p> console.error('Error updating room item types:', error);</p><p> return;</p><p> }</p><p></p><p> const updatedJSONData = JSON.stringify(furnitureData, null, 2);</p><p> fs.writeFile('FurnitureData.json', updatedJSONData, (err) => {</p><p> if (err) {</p><p> console.error('Error writing file:', err);</p><p> return;</p><p> }</p><p> console.log('FurnitureData.json updated successfully');</p><p></p><p> connection.end((err) => {</p><p> if (err) {</p><p> console.error('Error closing connection:', err);</p><p> return;</p><p> }</p><p> const end = performance.now();</p><p> console.log(`Script took ${(end - start) / 1000} seconds to finish`);</p><p> });</p><p> });</p><p> });</p><p> });</p><p>});</p><p>[/CODE]</p><p></p><p>Final Step:</p><p>Use your favorite terminal</p><p>Run "npm i" or "npm install" to install the dependencies/packages</p><p>Run "npm SCRIPTFILENAME.js"</p></blockquote><p></p>
[QUOTE="Bop, post: 484355, member: 94210"] If you are searching a furniture and clicking an item but it shows a wall item type. This fix is for you! First, run this query [CODE=sql] UPDATE catalog_items SET offer_id = CASE WHEN item_ids LIKE '%;%' AND SUBSTRING_INDEX(item_ids, ';', 1) REGEXP '^[0-9]+$' THEN CAST(SUBSTRING_INDEX(item_ids, ';', 1) AS UNSIGNED) WHEN item_ids LIKE '%:%' AND SUBSTRING_INDEX(item_ids, ':', 1) REGEXP '^[0-9]+$' THEN CAST(SUBSTRING_INDEX(item_ids, ':', 1) AS UNSIGNED) WHEN item_ids REGEXP '^[0-9]+$' THEN CAST(item_ids AS UNSIGNED) ELSE 0 -- or another appropriate default value END;[/CODE] This will match all id's in the offer_item column to the item_ids column Second, after running this query, you will need to install NodeJS, if it's already than no need to install it again [URL='https://nodejs.org/en']NodeJS Installation[/URL] Third step, place this file/script inside gamedata folder where your FurnitureData.json is located and edit the database credentials to match your current database credentials RECOMMENDED: Make a backup of your FurnitureData.json [CODE=javascript] const fs = require('fs'); const mysql = require('mysql2'); const { performance } = require('perf_hooks'); // Database connection configuration const dbConfig = { host: 'localhost', user: 'root', password: 'PASSWORD', database: 'DBNAME' }; const connection = mysql.createConnection(dbConfig); function updateOfferIdsForSection(furniTypes, callback) { let completed = 0; furniTypes.forEach((furniture, index) => { const query = 'SELECT offer_id FROM catalog_items WHERE catalog_name = ?'; connection.query(query, [furniture.classname], (error, results) => { if (error) { console.error('Error querying database:', error); return callback(error); } if (results.length > 0) { furniture.offerid = results[0].offer_id; console.log(`Updated offerid for ${furniture.classname} to ${results[0].offer_id}`); } else { console.log(`No matching record found for ${furniture.classname}`); } completed++; if (completed === furniTypes.length) { callback(); } }); }); } const start = performance.now(); fs.readFile('FurnitureData.json', 'utf8', (err, data) => { if (err) { console.error('Error reading file:', err); return; } const furnitureData = JSON.parse(data); updateOfferIdsForSection(furnitureData.wallitemtypes.furnitype, (error) => { if (error) { console.error('Error updating wall item types:', error); return; } updateOfferIdsForSection(furnitureData.roomitemtypes.furnitype, (error) => { if (error) { console.error('Error updating room item types:', error); return; } const updatedJSONData = JSON.stringify(furnitureData, null, 2); fs.writeFile('FurnitureData.json', updatedJSONData, (err) => { if (err) { console.error('Error writing file:', err); return; } console.log('FurnitureData.json updated successfully'); connection.end((err) => { if (err) { console.error('Error closing connection:', err); return; } const end = performance.now(); console.log(`Script took ${(end - start) / 1000} seconds to finish`); }); }); }); }); }); [/CODE] Final Step: Use your favorite terminal Run "npm i" or "npm install" to install the dependencies/packages Run "npm SCRIPTFILENAME.js" [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
[Script] Catalogue Search Fix for ALL retros [Script]
Top