Advertisement
EmuDevs

EmuDevs - GameObjectScript GameObject Gossip Template

Mar 30th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 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 go_tut : public GameObjectScript // go_tut - Class constructor, name this anything that doesn't conflict with another name
  7. {
  8. public:
  9.     go_tut() : GameObjectScript("go_tut") { } // go_tut, should be the same as class go_tut -- GameObjectScript("go_tut") - This is your 'ScriptName' that you will assign in your database.
  10.  
  11.     // This will show first when a player clicks on a GameObject (Gossip)
  12.     // override since it is a virtual function
  13.     bool OnGossipHello(Player* player, GameObject* go) 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, go->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, GameObject* go, uint32 /*sender*/, uint32 actions) override
  23.     {
  24.         player->PlayerTalkClass->ClearMenus();
  25.         if (actions == 1) // 2. the menu will be sent here to finish the action
  26.         {
  27.             player->GetSession()->SendAreaTriggerMessage("1");
  28.             player->CLOSE_GOSSIP_MENU();
  29.         }
  30.  
  31.         return true;
  32.     }
  33. };
  34.  
  35. void AddSC_tutorial() // This is your ScriptLoader.cpp setup function
  36. {
  37.     new go_tut(); // Call any new classes here as 'new classname();'
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement