(Beginner Tutorial) - How to create a vendor

ExO

Admin
5,084
2014
1,442
This is a share by Valkryst, I have asked him if I was allowed to share it and got his permission:

Before you decide to make a vendor there are a few important things that you need to figure out. These important bits of information include:

  • What items will the vendor sell.
  • Are any of the items rare or available in limited quantity?
  • If any of the items are rare or available in limited quantity, how often should the vendor restock those items?
  • In what order should the items be displayed in the vendor panel?
  • Are any of the items being sold custom?

Although these are all quite obvious, the last point did manage to throw me for a loop momentarily. If you're using custom items and you've edited the item.dbc file, placed it within an MPQ in your data folder, and they still show up as red question marks in the vendor panel; then you need to upload the item.dbc file into /bin/data/dbc/ on your server and restart worldserver.


Just in case anyone wants to know what I’m running:


  • Windows 8, x64 — Home
  • Debian 7 x32 — Server
  • TrinityCore — Latest version as of 18/August/2014
  • WoTLK 3.3.5a




Assuming that you already have both the NPC you'll be using as a vendor and the items that the vendor will be selling created and ready-to-use, we can begin.

You will first need to run SELECT * FROM creature_template WHERE entry=vendorNPCEntryID; on your database to view the data for the vendor NPC. Now that the record for the vendor NPC is up, you only need to edit the npcflag field and set it to 128. The NPC will now be recognized as a vendor. Now use the following query to add an item to the vendor NPC's vendor panel.
Code:

/* To insert a single item into the vendor's vendor panel use this query.*/INSERT INTO npc_vendor (entry, slot, item, maxcount, incrtime, ExtendedCost) VALUES (0, 0, 0, 0, 0);
Code:

/* To insert multiple items at once, just chain the values together as seen below. This example allows for two items to be added to the vendor's vendor panel. */INSERT INTO npc_vendor (entry, slot, item, maxcount, incrtime, ExtendedCost) VALUES (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0);
Now that you've created a vendor NPC and populated it's vendor panel with items to sell, you'll need to restartworldserver then you're ready to go!



Field Explanations:

  • entry - The entry ID of the vendor NPC. This is under the entry field of the creature_template table.
  • slot - The position in the vendor panel where this item will be located. As you can see in the image below, the slots are numbered left-to-right and top-to-bottom. This pattern repeats over all pages, but the numbers will continue incrementing.
  • item - The entry ID of the item being sold. This is under the entry field of the item_template table.
  • maxcount - The maximum number of items carried by the vendor at any time. If you want the vendor to carry an unlimited number of the item then set this to 0 else set it to any positive number. In the image below the maxcount value is circled.

  • incrtime - The time, in seconds (not milliseconds!), between restocks. As an example of how this is used... If maxcount is set to 4, incrtime set to 30, and the BuyCount field on the item in the item_template table is set to 2 then the vendor restocks 2 of the item every 30 seconds up to a total of4 items.
  • ExtendedCost - The value here corresponds to the ID in ItemExtendedCost.dbc and that ID controls the item's non monetary price, be it honor points, arena points, different types of badges or any combination of the above. (Taken from the TrinityCore documentation)




If you want to stay up-to-date with my latest tutorials or if you just want an easier way to view all of my tutorials and releases in one place then take a look at my blog.
 

Sethargo

Trial Member
1
2014
0
Hi,

in the multiple Values, you have one "0" too much.
VALUES (0, 0, 0, 0, 0, 0, 0), should be 6 numbers
like this (0, 0, 0, 0, 0, 0);

Thx much for the tutorial, works great.

Greetings Seth
 

ExO

Admin
5,084
2014
1,442
Hi,

in the multiple Values, you have one "0" too much.
VALUES (0, 0, 0, 0, 0, 0, 0), should be 6 numbers
like this (0, 0, 0, 0, 0, 0);

Thx much for the tutorial, works great.

Greetings Seth

Hey there! Great to know, glad to hear it helped you out!
 

ExO

Admin
5,084
2014
1,442
Nice post, detailed, could this work on 5.4.8?

I haven't checked how it's handled on 5.4.8, the database colums etc however it should work just fine, yes.

Otherwise post your issues, and I'll help you out!
 
Top