C++ - Add 3 Gossip Menus to 1 NPC

Hi, i’m stuck on this and i need help. I want an NPC to have 3 Gossip Options. If you click npc, you’d see the first Options. Then you click on 1 Option, see even more Options, but all only for Option x. Then in second Options you’d see a few more Options, but those are the Same for every second Option…

IE - Menu Main:

“Start 1” – Option1
“Start 2” – Option2

“Start 3” – Option3

“Start 4” – Option4

“Start 5” – Option5

Menu Start 1:

“Start_start 1” – Secondary Option1

“Start_start 2” – Secondary Option2

“Start_start 3” – Secondary Option3

Menu Start_start 1:

“Finally Start 1” – Final Option 1

“Finally Start 2” – Final Option 2
“Finally Start 3” – Final Option 3

So i don’t really know, how to do that… For ex i’d take the example_gossip.cpp

player->ADD_GOSSIP_ITEM_EXTENDED(0, NAME_TO_2nd_GOSSIP, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, “”, 0, true);
What do i have to put in there now?

Like this?

player->ADD_GOSSIP_ITEM_EXTENDED(NAME_TO_2nd_GOSSIP, GOSSIP_SECOND_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);

http://www.trinitycore.org/f/forum/9-custom-code-and-requests/

Sorry i thought this was the right forum…

Decided to reply here since a new thread was not created and this wasnt moved … yet?

Here is an example:

#include "ScriptPCH.h"

class example_gossip_custom : public CreatureScript
{
public:

    example_gossip_custom() : CreatureScript("example_gossip_custom")
    {
    }

    // Main menu
    bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
    {
        // arguments: icon, label, **sender**, **action**, popup, cost, codebox
        // sender and action are sent directly as they are to the OnGossipSelect(Code) Hook(s)
        // They do not affect anything and you can freely choose them. They are never sent to the client!
        player->ADD_GOSSIP_ITEM_EXTENDED(0, "Start 1", 1, 0, "", 0, false);
        player->ADD_GOSSIP_ITEM_EXTENDED(0, "Start 2", 0, 0, "", 0, false);
        player->ADD_GOSSIP_ITEM_EXTENDED(0, "Start 3", 0, 0, "", 0, false);
        player->ADD_GOSSIP_ITEM_EXTENDED(0, "Start 4", 0, 0, "", 0, false);
        player->ADD_GOSSIP_ITEM_EXTENDED(0, "Start 5", 0, 0, "", 0, false);
        player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
        return true;
    }

    bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) OVERRIDE
    {
        player->PlayerTalkClass->ClearMenus();

        switch (sender) // Show a menu by sender (menu ID)
        {
        case 0: // main menu
            OnGossipHello(player, creature);
            break;
        case 1: // Start 1
            // notice how using sender (variable) shows the same menu again
            player->ADD_GOSSIP_ITEM_EXTENDED(0, "Start_start 1", 2, 0, "", 0, false);
            player->ADD_GOSSIP_ITEM_EXTENDED(0, "Start_start 2", sender, 0, "", 0, false);
            player->ADD_GOSSIP_ITEM_EXTENDED(0, "Start_start 3", sender, 0, "", 0, false);
            player->ADD_GOSSIP_ITEM_EXTENDED(0, "Back..", 9999, 0, "", 0, false);
            player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
            break;
        case 2: // Start_start 1
            // notice that I used 2 as sender and 1 as action here, so I show menu 2 (same menu again)
            // and take action 1, so I have a coded action executed
            player->ADD_GOSSIP_ITEM_EXTENDED(0, "Finally Start 1", sender, 1, "", 0, false);
            player->ADD_GOSSIP_ITEM_EXTENDED(0, "Finally Start 2", sender, 0, "", 0, false);
            player->ADD_GOSSIP_ITEM_EXTENDED(0, "Finally Start 3", sender, 0, "", 0, false);
            player->ADD_GOSSIP_ITEM_EXTENDED(0, "Back..", 1, 0, "", 0, false);
            player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
            break;
        default: // no coded menu (error?) close.
            player->CLOSE_GOSSIP_MENU();
        }

        switch (action) // do some action by action ID
        {
        case 1: // the coded action
            player->GetSession()->SendNotification("You clicked an option with a scripted action!");
            break;
        }
        return true;
    }
};

void AddSC_example_gossip_custom()
{
    new example_gossip_custom();
}

— Canned message start —

This thread is not related to the official Trinity codebase and was moved to the Custom Code section.

Please read the stickies next time.

— Canned message end —