Advertisement
EmuDevs

EmuDevs - TrinityCore Gossip Extended

Jun 16th, 2013
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. /*
  2.  *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
  3.  *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
  4.  *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
  5.  *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
  6.  *       EmuDevs - (http://emudevs.com)
  7. */
  8.  
  9. class npc_gossip_extended : public CreatureScript
  10. {
  11. public:
  12.     npc_gossip_extended() : CreatureScript("npc_gossip_extended") { }
  13.  
  14.     bool OnGossipHello(Player* player, Creature* creature)
  15.     {
  16.         player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_BATTLE, "Battle", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "Write a name", 0, true);
  17.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Nevermind..", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+99);
  18.         return true;
  19.     }
  20.  
  21.     bool OnGossipSelect(Player* player, Creature* Creature, uint32 /* sender */, uint32 actions)
  22.     {
  23.         player->PlayerTalkClass->ClearMenus();
  24.         if (actions == GOSSIP_ACTION_INFO_DEF+99)
  25.             player->CLOSE_GOSSIP_MENU();
  26.         return true;
  27.     }
  28.  
  29.     bool OnGossipSelectCode(Player* player, Creature* creature, uint32 /* sender */, uint32 actions, const char* code)
  30.     {
  31.         player->PlayerTalkClass->ClearMenus();
  32.         if (actions == GOSSIP_ACTION_INFO_DEF+1)
  33.         {
  34.             std::string name = code;
  35.  
  36.             if (name.empty)
  37.             {
  38.                 player->GetSession()->SendNotification("The name cannot be empty!");
  39.                 return false;
  40.             }
  41.  
  42.             Player* _player = sObjectAccessor->FindPlayerByName(name.c_str());
  43.             if (!_player)
  44.             {
  45.                 player->GetSession()->SendNotification("Player not found");
  46.                 return false;
  47.             }
  48.             // DO ANYTHING BELOW HERE TO THE PLAYER THAT WAS WRITTEN IN TIME
  49.         }
  50.         return true;
  51.     }
  52. };
  53.  
  54. void AddSC_gossip_extension()
  55. {
  56.     new npc_gossip_extended();
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement