Advertisement
Rochet2

locale gossip

Jan 30th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2.  
  3. static const char* texts[][TOTAL_LOCALES] =
  4. {
  5. //  {enUS, koKR, frFR, deDE, zhCN, zhTW, esES, esMX, ruRU},
  6.     {"Text 1", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
  7.     {"Text 2", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
  8.     {"Text 3", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
  9.     {"Back..", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
  10. };
  11. static const uint32 texts_size = sizeof(texts)/sizeof(*texts);
  12.  
  13. const char* GetText(Player* player, uint32 id)
  14. {
  15.     if (id >= texts_size)
  16.         return NULL;
  17.     const char* text = texts[id][player->GetSession()->GetSessionDbcLocale()];
  18.     return text ? text : texts[id][DEFAULT_LOCALE];
  19. }
  20.  
  21. class example_gossip : public CreatureScript
  22. {
  23. public:
  24.     example_gossip() : CreatureScript("example_gossip") { }
  25.  
  26.     bool OnGossipHello(Player* player, Creature* creature)
  27.     {
  28.         player->ADD_GOSSIP_ITEM(0, GetText(player, 0), GOSSIP_SENDER_MAIN, 1);
  29.         player->ADD_GOSSIP_ITEM(0, GetText(player, 1), GOSSIP_SENDER_MAIN, 0);
  30.         // player->ADD_GOSSIP_ITEM_DB(menuId, menuItemId, sender, action); // Or use DB instead like this
  31.         player->SEND_GOSSIP_MENU(40002, creature->GetGUID());
  32.         return true;
  33.     }
  34.  
  35.     bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
  36.     {
  37.         player->PlayerTalkClass->ClearMenus();
  38.         switch(action)
  39.         {
  40.         case 0:
  41.             player->CLOSE_GOSSIP_MENU();
  42.             break;
  43.         case 1:
  44.             player->ADD_GOSSIP_ITEM(2, GetText(player, 3), GOSSIP_SENDER_MAIN, 0);
  45.             player->ADD_GOSSIP_ITEM(0, GetText(player, 4), GOSSIP_SENDER_MAIN, 0);
  46.             player->SEND_GOSSIP_MENU(1, creature->GetGUID());
  47.             break;
  48.         }
  49.         return true;
  50.     }
  51. };
  52.  
  53. void AddSC_example_gossip()
  54. {
  55.     new example_gossip();
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement