Advertisement
EmuDevs

Gossip (CreatureScript) Template

Mar 30th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.61 KB | None | 0 0
  1. /*
  2.     EmuDevs - (http://emudevs.com)
  3.     Use this as your template. Make sure to point credits towards ED.
  4. */
  5.  
  6. class npc_tut : public CreatureScript // npc_tut - Class constructor, name this anything that doesn't conflict with another class name
  7. {
  8. public:
  9.     npc_tut() : CreatureScript("npc_tut") { } // npc_tut, should be the same as class npc_tut so you don't have many different names scattered everywhere; CreatureScript("npc_tut") - This is your 'ScriptName' that you will assign in your database.
  10.  
  11.     // This will show first when a player clicks on a gossip npc
  12.     // override since it is a virtual function
  13.     bool OnGossipHello(Player* player, Creature* creature) override
  14.     {
  15.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "First Menu", GOSSIP_SENDER_MAIN, 1); // 1. Once the player clicks this menu,
  16.         player->SEND_GOSSIP_MENU(1, creature->GetGUID()); // This sends the menu to the player
  17.         return true;
  18.     }
  19.  
  20.     // This will handle actions based on the menu clicked
  21.     // override since it is a virtual function
  22.     bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 actions) override
  23.     {
  24.         player->PlayerTalkClass->ClearMenus();
  25.         if (actions == 1) // 2. This is the action that will be called when player clicks our "First Menu"
  26.         {
  27.             player->GetSession()->SendAreaTriggerMessage("Hello World");
  28.             player->CLOSE_GOSSIP_MENU();
  29.         }
  30.         return true;
  31.     }
  32. };
  33.  
  34. void AddSC_tutorial() // This is your ScriptLoader.cpp setup function
  35. {
  36.     new npc_tut; // Call any new classes here as 'new classname;'
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement