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

[SOLVED] how to create submenus on MultiVendor

Status
Not open for further replies.

savenx

Enthusiast
The title says all, how i can create sub-menus on multivendor?

Example:

[GEMS] -> then open a menu with Red,Blue,Blue and BACK <-
[GLYPHS] -> Paladin, Warrior and <-Back

thanks
 

Tommy

Founder
I'll give you an example showing the gist of setting up submenus in general.

Code:
class example_submenus_gossip : public CreatureScript
{
public:
    example_submenus_gossip() : CreatureScript("example_submenus_gossip") { }

    bool OnGossipHello(Player* player, Creature* creature) override
    {
        // Let's create our menus first
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Test1", 0, 1);
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Nevermind..", 0, 2);
        // Send Gossip menus to the player
        player->SEND_GOSSIP_MENU(1, creature->GetGUID());
        return true;
    }

    bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 actions) override
    {
        player->PlayerTalkClass->ClearMenus();

        switch (actions)
        {
            case 1: // Test1
                // Create our submenus
                // It is best to create a method for submenus for easy handling and editing, especially for bigger scripts
                SendSubMenus(player, creature);                
                break;
            case 2: // Nevermind..
                player->CLOSE_GOSSIP_MENU();
                break;
            case 3: // SendSubMenus '<- Back <-'. Goes to Home
                OnGossipHello(player, creature);
                break;
            case 4: // Submenu 1
                break;
            case 5: // Submenu 2
                break;
            case 6: // Submenu 3
                break;
        }
        return true;
    }

    // SubMenus: Home (OnGossipHello) -> SubMenus
    void SendSubMenus(Player* player, Creature* creature)
    {
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Submenu 1", 0, 4);
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Submenu 2", 0, 5);
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Submenu 3", 0, 6);
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "<- Back <-", 0, 3);
        // Send our submenus to the player
        player->SEND_GOSSIP_MENU(1, creature->GetGUID());
    }
};

Hope this helps you. Note: I didn't use VS or any IDE so beware of potential errors.
 

Rochet2

Moderator / Eluna Dev
Submenu is displayed by simply sending a new menu just like you send the main menu. So simply add the options and call send menu.
The sender and action are both simply numbers that are bound to each gossip option and when clicked are given to the on gossip select function.
They both may be useful in making submenus or simpler code overall. For example in your code you could use sender as the identifier for the options (mainly for identifying what submenu to show next) and if action > 0 then it is assumed to be a vendor to display.
 

savenx

Enthusiast
Is there any way to do this without using c++ ? Only on SQL? i tried to send the menu to another id but didnt work
 

Rochet2

Moderator / Eluna Dev
Sure is.
Just see how the stormwind guard gossip is made.
Basically the submenu's menu_id is in the action_menu_id field in gossip_menu_option table.
 

Rochet2

Moderator / Eluna Dev
No, because your option_id is set to 3. It should be .. 1? This is for the option that opens a submenu.
Otherwise looks fine.

.. If I interpreted it correctly. Ppl keep posting only columns so I have no idea what column is what :D
 
Status
Not open for further replies.
Top