User Tag List

Results 1 to 2 of 2

Thread: how to send a inpux box to player?

  1. #1
    Emulation Addict
    Join Date
    Feb 2016
    Posts
    9
    XP
    539
    Level
    5
    Thanks
    0
    Thanked 1 Time in 1 Post

    how to send a inpux box to player?

    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

  2. The Following User Says Thank You to dfdf2015 For This Useful Post:


  3. #2
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Posts
    7,391
    XP
    3,449,104
    Level
    378
    Thanks
    889
    Thanked 1,856 Times in 1,119 Posts
    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
        {
            player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_CHAT, "Input a word.", GOSSIP_SENDER_MAIN, 1, "YOU BETTER INSERT A WORD", 0, true);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Non-code input menu", 0, 2);
            player->SEND_GOSSIP_MENU(1, creature->GetGUID());
            return true;
        }
    
        // For non-code input menus
        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;
        }
    
        // For code input
        // "code" parameter is what the player enters in the box
        bool OnGossipSelectCode(Player* player, Creature* creature, uint32 /*sender*/, uint32 action, const char* code) override
        {
            player->PlayerTalkClass->ClearMenus();
            if (actions == 1)
            {
                ChatHandler(player->GetSession()).PSendSysMessage("You input: %s", code);
                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;'
    }

  4. The Following User Says Thank You to Tommy For This Useful Post:


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •