• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Vendor

Status
Not open for further replies.

Rochet2

Moderator / Eluna Dev
You shouldnt actually change the items in a vendor on the fly.
Basically you can make a normal vendor through DB and then you can make him show the window with player:SendVendorWindow(unit) when you want to.
By making a vendor through DB I mean adding the items in DB and NPC flags for example.
You can also script it all, except NPC vendor flag. It needs to be already set to be able to use the global method to add items to a vendor.

Here is an example. Note that it is a test script and you should only add the items once on startup.
Code:
local function Test(event, player, msg, Type, lang)
	if(msg == "test") then
        local unit = player:GetSelection() -- just to test, get the selected unit (needs vendor flags set in DB)
        
        -- This code should be run only on startup. You may also change the items on the fly,
        -- but you should not try to show 2 different vendors to 2 players at the same time from one NPC.
            VendorRemoveAllItems(unit:GetEntry(), false) -- Remove all previous items
            -- Add our items to the vendor:
            AddVendorItem(unit:GetEntry(), 25, 0, 0, 0, false)
            AddVendorItem(unit:GetEntry(), 35, 0, 0, 0, false)
            AddVendorItem(unit:GetEntry(), 36, 0, 0, 0, false)
            AddVendorItem(unit:GetEntry(), 37, 0, 0, 0, false)
            AddVendorItem(unit:GetEntry(), 38, 0, 0, 0, false)
            AddVendorItem(unit:GetEntry(), 39, 0, 0, 0, false)
            AddVendorItem(unit:GetEntry(), 40, 0, 0, 0, false)
            AddVendorItem(unit:GetEntry(), 43, 0, 0, 0, false)
        --
        
        player:SendVendorWindow(unit) -- show vendor to player
        return false
	end
end
RegisterServerHook(18, Test)

The VendorRemoveAllItems was coded badly and crashes. Fixed it now.
It is not required if the vendor is empty in the beginning or you dont want to remove old items or you can use the other method to remove the old items.
 
Last edited:

Come2WoW

Respected Member
tanks , sorry how add this on npc ?:D
and
How can a Multi Vendor on gosip menu language Eluna to make?
 

Tommy

Founder
tanks , sorry how add this on npc ?:D
and
How can a Multi Vendor on gosip menu language Eluna to make?

Well Rochet2 used a command you could use to prompt you with the gossip menu by typing "test" (without quotations). If you want it on a NPC as gossip, you will need to use the 'RegisterCreatureGossipEvent(NPC_ID, EVENTID, function)'. You can find all you need on here about CreatureGossip hook: http://wiki.emudevs.com/doku.php?id=eluna_hooks_registercreaturegossipevent and here's what you use for the player gossip methods:

player:GossipMenuAddItem(icon, msg, sender, intid[, code, popup, money]) - Adds a new gossip option to the player's gossip menu.

player:GossipSendMenu(npc_text, unit[, menu_id]) - Sends a gossip menu from a world object to the player

player:GossipComplete() - Closes the gossip menu

player:GossipClearMenu() - Clears the gossip menu of options. Need to use before creating a new menu for the player


Your last question, are you talking about making the NPC a Vendor + Gossip? If so, set the NpcFlag of the NPC to 129.
 
Status
Not open for further replies.
Top