Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptPCH.h"
- class levelnpc_teleporter : public CreatureScript
- {
- public:
- levelnpc_teleporter() : CreatureScript("levelnpc_teleporter") { } // levelnpc_teleporter is the scriptname to put to DB to the scriptname column
- bool OnGossipHello(Player* pPlayer, Creature* pCreature) // when the player opens the gossip menu
- {
- if (pPlayer->isInCombat()) // check combat
- {
- pPlayer->GetSession()->SendNotification("You are in combat"); // send a red areatriggermessage
- return false; // this causes the function to stop executing further and returns false value, which prevents any further gossip
- }
- // if not in combat :
- 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
- 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
- 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)
- return true; // it is a bool function, we must return true or false. Returning false should prevent all further gossip
- }
- bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
- {
- pPlayer->PlayerTalkClass->ClearMenus();
- switch (uiAction) // google switch :3, its like IF END IF END, but not quite.
- {
- case 1: // intid 1
- {
- 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
- } break; // stop here, do not execute other cases
- case 2: // intid 2
- {
- 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
- pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Back..", GOSSIP_SENDER_MAIN, 4); // 1, 2 are the intids, but in here we call them uiAction
- 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)
- return true; // prevent the code for going to the close gossip menu. It would just close our newly created gossip menu :(
- } break; // stop here, do not execute other cases
- case 3: // intid 3
- {
- 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
- } break; // stop here, do not execute other cases
- case 4: // intid 4
- {
- // this shows the OnGossipHello menu (main menu)
- OnGossipHello(pPlayer, pCreature);
- return true; // prevent the code for going to the close gossip menu. It would just close our newly created gossip menu :(
- } break; // stop here, do not execute other cases
- }
- pPlayer->CLOSE_GOSSIP_MENU(); // close the gossip menu
- return true;
- }
- };
- void AddSC_levelnpc_teleporter()
- {
- new levelnpc_teleporter();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement