Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptPCH.h"
- static const char* texts[][TOTAL_LOCALES] =
- {
- // {enUS, koKR, frFR, deDE, zhCN, zhTW, esES, esMX, ruRU},
- {"Text 1", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- {"Text 2", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- {"Text 3", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- {"Back..", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- };
- static const uint32 texts_size = sizeof(texts)/sizeof(*texts);
- const char* GetText(Player* player, uint32 id)
- {
- if (id >= texts_size)
- return NULL;
- const char* text = texts[id][player->GetSession()->GetSessionDbcLocale()];
- return text ? text : texts[id][DEFAULT_LOCALE];
- }
- class example_gossip : public CreatureScript
- {
- public:
- example_gossip() : CreatureScript("example_gossip") { }
- bool OnGossipHello(Player* player, Creature* creature)
- {
- player->ADD_GOSSIP_ITEM(0, GetText(player, 0), GOSSIP_SENDER_MAIN, 1);
- player->ADD_GOSSIP_ITEM(0, GetText(player, 1), GOSSIP_SENDER_MAIN, 0);
- // player->ADD_GOSSIP_ITEM_DB(menuId, menuItemId, sender, action); // Or use DB instead like this
- player->SEND_GOSSIP_MENU(40002, creature->GetGUID());
- return true;
- }
- bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
- {
- player->PlayerTalkClass->ClearMenus();
- switch(action)
- {
- case 0:
- player->CLOSE_GOSSIP_MENU();
- break;
- case 1:
- player->ADD_GOSSIP_ITEM(2, GetText(player, 3), GOSSIP_SENDER_MAIN, 0);
- player->ADD_GOSSIP_ITEM(0, GetText(player, 4), GOSSIP_SENDER_MAIN, 0);
- player->SEND_GOSSIP_MENU(1, creature->GetGUID());
- break;
- }
- return true;
- }
- };
- void AddSC_example_gossip()
- {
- new example_gossip();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement