Item on Gossip

Im looking to add an NPC that gives an item to you upon speaking with them, but only if you have a specific quest. Can someone point me in the right direction, thanks.


Upon talking to him… You mean when you click a gossip option or when you click the NPC to talk to him?

Why not take a look at the example script for gossip and try to use player->IsActiveQuest(entry) in combination with player->AddItem(entry, count); or what was it…

Either. Simply clicking on him and having him say hello would be fine.

Cant get any simpler.

class AddItemOnTalkIfQuest : public CreatureScript
    AddItemOnTalkIfQuest() : CreatureScript("AddItemOnTalkIfQuest") {}

    bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
        if (player->IsActiveQuest(entry))
            player->AddItem(entry, count);
        return false;

void AddSC_AddItemOnTalkIfQuest()
    new AddItemOnTalkIfQuest();

Does this have to be done with C++ or can it be done in db?

You should be able to use conditions on a gossip option to show if you have the quest and then on click sai gives item.

but why do it in db, this tiny c++ is much more user friendly