View Single Post
  #6  
Old 05-29-2008, 11:14 AM
ndnet
Hill Giant
 
Join Date: Oct 2003
Posts: 105
Default

Did you run the whole query in the last code block? There was a lot there which set up and populated a temporary table to be used for sticking stuff back into the merchantlist table.

I'll go through it line by line and explain the reasoning:
Code:
DROP TABLE IF EXISTS merchantlist_tskills;
This I just added because I was debugging the script a lot so I wanted to ensure some cleanup was done no matter if it finished or not.

Code:
CREATE TABLE IF NOT EXISTS
merchantlist_tskills
(slot INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, itemid INTEGER);
This creates the table merchantlist_tskills for our temporary storage. If doing this one line at a time to find where it's stopping, make sure the table exists after this query or the rest is just going to bomb out.

Code:
INSERT INTO merchantlist_tskills (itemid) (
SELECT 
	tradeskill_recipe_entries.item_id
FROM
	tradeskill_recipe,
	tradeskill_recipe_entries
WHERE
	tradeskill_recipe.id = tradeskill_recipe_entries.recipe_id AND
	tradeskill_recipe.tradeskill = TRADESKILLNUMBER AND
	tradeskill_recipe_entries.successcount = 1
);
This populates the temporary table we just made with item IDs and slot numbers to get it ready to be shoved into the merchantlist table.

Code:
INSERT INTO merchantlist (merchantid, slot, item)
(SELECT 'MERCHANTID', slot, itemid FROM merchantlist_tskills);
This grabs the data from our temporary table, adds an extra field (the merchantid), and throws it all into the merchantlist table, creating the merchant's inventory data. In your response, this doesn't appear to have been run because there were no entries with that merchantid.

Code:
DROP TABLE merchantlist_tskills;
This is to clean up the temporary table we made since we no longer need it.

Code:
INSERT INTO npc_types (name, level, race, class, gender, texture, merchant_id) VALUES ('MERCHANT_NAME00', 1, 1, 41, 0, 0, MERCHANTID);
And finally this creates a new npc_types entry for the NPC with class of merchant and connected to the right merchant ID from the merchantlist table. This query apparently worked as you were able to spawn the NPC? But I suppose it failed for you somewhere prior to that.

Make sure that you're running everything, though, as starting in the middle will wind up with some odd stuffs.
Reply With Quote