Advertisement
Rochet2

Simple Trinity teleporter

Jul 26th, 2012
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ScriptPCH.h"
  2.  
  3. class levelnpc_teleporter : public CreatureScript
  4. {
  5. public:
  6.     levelnpc_teleporter() : CreatureScript("levelnpc_teleporter") { } // levelnpc_teleporter is the scriptname to put to DB to the scriptname column
  7.  
  8.     bool OnGossipHello(Player* pPlayer, Creature* pCreature) // when the player opens the gossip menu
  9.     {
  10.         if (pPlayer->isInCombat()) // check combat
  11.         {
  12.             pPlayer->GetSession()->SendNotification("You are in combat"); // send a red areatriggermessage
  13.             return false; // this causes the function to stop executing further and returns false value, which prevents any further gossip
  14.         }
  15.         // if not in combat :
  16.         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport somewhere", GOSSIP_SENDER_MAIN, 1); // GOSSIP_SENDER_MAIN is basically just a number, which is the uiSender in OnGossipSelect function, you can ignore it in simple teleporters
  17.         pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Go to raids submenu", GOSSIP_SENDER_MAIN, 2); // 1, 2 are the intids, but in here we call them uiAction
  18.         pPlayer->SEND_GOSSIP_MENU(907, pCreature->GetGUID()); // This sends the options to the player. 907 is the entry of the npc_text row (text at the top of the menu)
  19.         return true; // it is a bool function, we must return true or false. Returning false should prevent all further gossip
  20.     }
  21.  
  22.     bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
  23.     {
  24.         pPlayer->PlayerTalkClass->ClearMenus();
  25.  
  26.         switch (uiAction) // google switch :3, its like IF END IF END, but not quite.
  27.         {
  28.         case 1: // intid 1
  29.             {
  30.                 pPlayer->TeleportTo(1, 4620.84f, -3847.99f, 943.92f, 1.0814f); // map, x, y, z, orientation All float (decimal) values need an f after them: 1.5f
  31.             } break; // stop here, do not execute other cases
  32.         case 2: // intid 2
  33.             {
  34.                 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport somewhere", GOSSIP_SENDER_MAIN, 3); // GOSSIP_SENDER_MAIN is basically just a number, which is the uiSender in OnGossipSelect function, you can ignore it in simple teleporters
  35.                 pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Back..", GOSSIP_SENDER_MAIN, 4); // 1, 2 are the intids, but in here we call them uiAction
  36.                 pPlayer->SEND_GOSSIP_MENU(907, pCreature->GetGUID()); // This sends the options to the player. 907 is the entry of the npc_text row (text at the top of the menu)
  37.                 return true; // prevent the code for going to the close gossip menu. It would just close our newly created gossip menu :(
  38.             } break; // stop here, do not execute other cases
  39.         case 3: // intid 3
  40.             {
  41.                 pPlayer->TeleportTo(1, 4620.84f, -3847.99f, 943.92f, 1.0814f); // map, x, y, z, orientation All float (decimal) values need an f after them: 1.5f
  42.             } break; // stop here, do not execute other cases
  43.         case 4: // intid 4
  44.             {
  45.                 // this shows the OnGossipHello menu (main menu)
  46.                 OnGossipHello(pPlayer, pCreature);
  47.                 return true; // prevent the code for going to the close gossip menu. It would just close our newly created gossip menu :(
  48.             } break; // stop here, do not execute other cases
  49.         }
  50.         pPlayer->CLOSE_GOSSIP_MENU(); // close the gossip menu
  51.         return true;
  52.     }
  53. };
  54.  
  55. void AddSC_levelnpc_teleporter()
  56. {
  57.     new levelnpc_teleporter();
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement