Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- EmuDevs NPC Tutorial
- http://emudevs.com
- TrinityCore Tutorial
- */
- struct SpecialCoords
- {
- float x, y, z;
- };
- UNORDERED_MAP<uint64, SpecialCoords> CoordsStore;
- class npc_tutorial : public CreatureScript
- {
- public:
- npc_tutorial() : CreatureScript("npc_tutorial") { }
- bool OnGossipHello(Player* player, Creature* creature)
- {
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Add Coords", GOSSIP_SENDER_MAIN, 1);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Show Data", GOSSIP_SENDER_MAIN, 2);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Delete my aata", GOSSIP_SENDER_MAIN, 3);
- player->SEND_GOSSIP_MENU(1, creature->GetGUID());
- return true;
- }
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 actions)
- {
- player->PlayerTalkClass->ClearMenus();
- if (CoordsStore.size() > 0)
- {
- UNORDERED_MAP<uint64, SpecialCoords>::iterator itr = CoordsStore.find(player->GetGUID());
- if (itr != CoordsStore.end())
- {
- player->GetSession()->SendNotification("You are already in!");
- player->CLOSE_GOSSIP_MENU();
- return false;
- }
- }
- if (actions == 1)
- {
- CoordsStore[player->GetGUID()].x = 5912.873212f;
- CoordsStore[player->GetGUID()].y = -1912.473212f;
- CoordsStore[player->GetGUID()].z = 122.873212f;
- ChatHandler(player->GetSession()).SendSysMessage("You are in this map!");
- player->CLOSE_GOSSIP_MENU();
- }
- else if (actions == 2)
- {
- for (UNORDERED_MAP<uint64, SpecialCoords>::const_iterator itr = CoordsStore.begin(); itr != CoordsStore.end(); ++itr)
- {
- Player* _player = sObjectMgr->GetPlayerByLowGUID(GUID_LOPART(itr->first));
- if (player || player->IsInWorld())
- ChatHandler(player->GetSession()).PSendSysMessage("DATA FOR COORDS \n Name: %s \n Coords: \n X: %f \n Y: %f \n Z: %f", _player->GetName().c_str(), itr->second.x, itr->second.y, itr->second.z);
- }
- }
- else if (actions == 3)
- CoordsStore.erase(player->GetGUID());
- return true;
- }
- };
- void AddSC_gossip()
- {
- new npc_tutorial();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement