Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
- *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
- *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
- *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
- * EmuDevs - (http://emudevs.com)
- */
- struct Plots
- {
- float x, y;
- };
- UNORDERED_MAP<uint64, Plots> PlotsContainer;
- class npc_gossip_plot : public CreatureScript
- {
- public:
- npc_gossip_plot() : CreatureScript("npc_gossip_plot") { }
- bool OnGossipHello(Player* player, Creature* creature)
- {
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Get Plot 1", GOSSIP_SENDER_MAIN, 1);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Get Plot 2", GOSSIP_SENDER_MAIN, 2);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Nevermind", 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 (PlotsContainer.size() > 0)
- {
- UNORDERED_MAP<uint64, Plots>::iterator itr = PlotsContainer.find(player->GetGUID());
- if (itr != PlotsContainer.end())
- {
- player->GetSession()->SendNotification("You already have a plot!");
- player->CLOSE_GOSSIP_MENU();
- return false;
- }
- }
- if (actions == 1)
- {
- PlotsContainer[player->GetGUID()].x = 5780.797363f;
- PlotsContainer[player->GetGUID()].y = -2959.686279f;
- creature->SummonCreature(54001, 5780.797363f, -2959.686279f, 274, 1.0f, TEMPSUMMON_MANUAL_DESPAWN, 0);
- ChatHandler(player->GetSession()).SendSysMessage("Plot created!");
- player->CLOSE_GOSSIP_MENU();
- }
- else if (actions == 2)
- {
- PlotsContainer[player->GetGUID()].x = 5748.431641f;
- PlotsContainer[player->GetGUID()].y = -2973.928223f;
- creature->SummonCreature(54002, 5748.431641f, -2973.928223f, 274, 1.0f, TEMPSUMMON_MANUAL_DESPAWN, 0);
- ChatHandler(player->GetSession()).SendSysMessage("Plot created!");
- player->CLOSE_GOSSIP_MENU();
- }
- else if (actions == 3)
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- };
- class npc_trigger_plot : public CreatureScript
- {
- public:
- npc_trigger_plot() : CreatureScript("npc_trigger_plot") { }
- struct npc_trigger_plotAI : public ScriptedAI
- {
- npc_trigger_plotAI(Creature* creature) : ScriptedAI(creature) { }
- uint32 teleportTimer;
- void Reset()
- {
- teleportTimer = 1000;
- }
- void UpdateAI(uint32 diff)
- {
- if (teleportTimer <= diff)
- {
- Player* player = me->SelectNearestPlayer(15.0f);
- if (player && !player->isDead())
- {
- if (PlotsContainer.size() > 0)
- {
- UNORDERED_MAP<uint64, Plots>::iterator itr = PlotsContainer.find(player->GetGUID());
- if (itr != PlotsContainer.end())
- {
- if (player->GetGUID() == itr->first) // If the guid matches
- {
- if (itr->second.x != me->GetPositionX() && itr->second.y != me->GetPositionY()) // If these don't match, gtfo
- {
- player->TeleportTo(player->GetMapId(), player->GetPositionX() + 15, player->GetPositionY() - 15, player->GetPositionZ() + 5, player->GetOrientation());
- player->GetSession()->SendNotification("This isn't your plot!");
- }
- }
- }
- else // You don't have a plot, don't touch MINE!
- {
- player->TeleportTo(player->GetMapId(), player->GetPositionX() + 15, player->GetPositionY() - 15, player->GetPositionZ() + 5, player->GetOrientation());
- player->GetSession()->SendNotification("This isn't your plot!");
- }
- }
- }
- }
- else
- teleportTimer -= diff;
- }
- };
- CreatureAI* GetAI(Creature* creature) const
- {
- return new npc_trigger_plotAI(creature);
- }
- };
- class npc_trigger_plotTwo : public CreatureScript
- {
- public:
- npc_trigger_plotTwo() : CreatureScript("npc_trigger_plotTwo") { }
- struct npc_trigger_plotTwoAI : public ScriptedAI
- {
- npc_trigger_plotTwoAI(Creature* creature) : ScriptedAI(creature) { }
- uint32 teleportTimer;
- void Reset()
- {
- teleportTimer = 1000;
- }
- void UpdateAI(uint32 diff)
- {
- if (teleportTimer <= diff)
- {
- Player* player = me->SelectNearestPlayer(15.0f);
- if (player && !player->isDead())
- {
- if (PlotsContainer.size() > 0)
- {
- UNORDERED_MAP<uint64, Plots>::iterator itr = PlotsContainer.find(player->GetGUID());
- if (itr != PlotsContainer.end())
- {
- if (player->GetGUID() == itr->first) // If the guid matches
- {
- if (itr->second.x != me->GetPositionX() && itr->second.y != me->GetPositionY()) // If these don't match, gtfo
- {
- player->TeleportTo(player->GetMapId(), player->GetPositionX() + 15, player->GetPositionY() - 15, player->GetPositionZ() + 5, player->GetOrientation());
- player->GetSession()->SendNotification("This isn't your plot!");
- }
- }
- }
- else // You don't have a plot, don't touch MINE!
- {
- player->TeleportTo(player->GetMapId(), player->GetPositionX() + 15, player->GetPositionY() - 15, player->GetPositionZ() + 5, player->GetOrientation());
- player->GetSession()->SendNotification("This isn't your plot!");
- }
- }
- }
- }
- else
- teleportTimer -= diff;
- }
- };
- CreatureAI* GetAI(Creature* creature) const
- {
- return new npc_trigger_plotTwoAI(creature);
- }
- };
- void AddSC_custom_thing() // This is your ScriptLoader.cpp setup function
- {
- new npc_gossip_plot; // Call any new classes here as 'new classname();'
- new npc_trigger_plot;
- new npc_trigger_plotTwo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement