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

TrinityCore 3.3.5 how to send a inpux box to player?

dfdf2015

Emulation Addict
eg: player click a npc`s menu,then open a input box,player can input something in it,and click 'OK' to submit,then handle this field in core.
how to handle the progress.

thans very much
 

Tommy

Founder
That would be the OnGossipSelectCode CreatureScript hook to handle the action and "player->ADD_GOSSIP_ITEM_EXTENDED" to handle the prompt that goes to OnGossipSelectCode hook.

Code:
bool OnGossipSelectCode(Player* player, Creature* creature, uint32 /*sender*/, uint32 action, const char* code) override

I'm going to take a simple template from this thread and edit it & show you how to do it.

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

    bool OnGossipHello(Player* player, Creature* creature) override
    {
        [COLOR="#00FF00"]player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_CHAT, "Input a word.", GOSSIP_SENDER_MAIN, 1, "YOU BETTER INSERT A WORD", 0, true);[/COLOR]
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Non-code input menu", 0, 2);
        player->SEND_GOSSIP_MENU(1, creature->GetGUID());
        return true;
    }

    [COLOR="#00FF00"]// For non-code input menus[/COLOR]
    bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
    {
        player->PlayerTalkClass->ClearMenus();
        if (actions == 2)
        {
            player->GetSession()->SendAreaTriggerMessage("Non-code input menu");
            player->CLOSE_GOSSIP_MENU();
        }
        return true;
    }
[COLOR="#00FF00"]
    // For code input
    // "code" parameter is what the player enters in the box[/COLOR]
    [COLOR="#00FF00"]bool OnGossipSelectCode(Player* player, Creature* creature, uint32 /*sender*/, uint32 action, const char* code) override[/COLOR]
    {
        player->PlayerTalkClass->ClearMenus();
        if (actions == 1)
        {
            [COLOR="#00FF00"]ChatHandler(player->GetSession()).PSendSysMessage("You input: %s", code);[/COLOR]
            player->CLOSE_GOSSIP_MENU();
        }
        return true;
    }
};

void AddSC_tutorial() // This is your ScriptLoader.cpp setup function
{
    new npc_tut; // Call any new classes here as 'new classname;'
}
 
Top