PDA

View Full Version : TrinityCore 3.3.5 how to send a inpux box to player?



dfdf2015
07-20-2016, 02:15 AM
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
07-20-2016, 03:44 AM
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.



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 (http://emudevs.com/showthread.php/58-Basic-Intermediate-Scripting-Templates) and edit it & show you how to do it.



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;'
}