Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptPch.h"
- #include <cstring>
- #include <stdio.h>
- #include <time.h>
- #define OFFSET_THEME 10000
- int GetLastThemeTime()
- {
- QueryResult result;
- result = WorldDatabase.PQuery("SELECT `time` FROM `evento_gurubashi_lastspawn`");
- if (result)
- {
- Field *fields = result->Fetch();
- return fields[0].GetInt32();
- }
- else
- return 0;
- }
- void GossipObjects(Player *player, Creature *m_creature)
- {
- if (GetLastThemeTime() + 600 <= time (NULL))
- {
- QueryResult result;
- result = WorldDatabase.PQuery("SELECT `id`, `name` FROM `evento_gurubashi_reliquias`");
- if (result)
- {
- do
- {
- Field *fields = result->Fetch();
- player->ADD_GOSSIP_ITEM(4, fields[1].GetString(), GOSSIP_SENDER_MAIN, OFFSET_THEME + fields[0].GetInt32());
- }
- while (result->NextRow());
- }
- }
- else
- {
- char msg[100];
- int time2 = GetLastThemeTime() + 600 - time (NULL);
- if (time2 < 60)
- sprintf(msg, "La siguiente reliquia se podrá spawnear en menos de un minuto.");
- else
- sprintf(msg, "La siguiente reliquia se podrá spawnear en %u minuto/s.", time2 / 60);
- player->ADD_GOSSIP_ITEM(0, msg, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
- }
- player->ADD_GOSSIP_ITEM(0, "Salir.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
- player->SEND_GOSSIP_MENU(1,m_creature->GetGUID());
- }
- class NPC_Evento_Gurubashi : public CreatureScript
- {
- public:
- NPC_Evento_Gurubashi() : CreatureScript("NPC_Evento_Gurubashi") {}
- bool OnGossipHello(Player * pPlayer, Creature * pCreature)
- {
- GossipObjects(pPlayer, pCreature);
- return true;
- }
- bool OnGossipSelect(Player *player, Creature * m_creature, uint32 sender, uint32 action)
- {
- if (action > OFFSET_THEME)
- {
- QueryResult result;
- result = WorldDatabase.PQuery("DELETE FROM `evento_gurubashi_lastspawn`");
- result = WorldDatabase.PQuery("INSERT INTO `evento_gurubashi_lastspawn` VALUES (%u)", time (NULL));
- result = WorldDatabase.PQuery("SELECT `x`, `y`, `z`, `o`, `entry` FROM `evento_gurubashi_spawns` WHERE `theme` = %u", action - OFFSET_THEME);
- if (result)
- {
- player->CastSpell(player, 20217, 1);
- player->CastSpell(player, 93744, 1);
- player->CastSpell(player, 1126, 1);
- player->CastSpell(player, 1459, 1);
- player->GetSession()->SendAreaTriggerMessage("Has sido buffeado como obsequio por spawnear una reliquia.");
- sWorld->SendGlobalText("Una |cFFFF6060Reliquia Zalandari|r ha aparecido en la arena gurubashi. Obtendrás valiosas recompensas si acudes al evento y te haces con la reliquia.", NULL);
- m_creature->MonsterSay("Spawneando gameobjects...", LANG_UNIVERSAL, player->GetGUID());
- do
- {
- Field *fields = result->Fetch();
- m_creature->SummonGameObject(fields[4].GetInt32(), fields[0].GetFloat(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), 0, 0, 0, 0, 600);
- }
- while (result->NextRow());
- }
- else
- {
- m_creature->MonsterSay("No se han encontrado gameobjects.", LANG_UNIVERSAL, player->GetGUID());
- }
- player->PlayerTalkClass->SendCloseGossip();
- }
- else
- {
- switch (action)
- {
- case GOSSIP_ACTION_INFO_DEF + 1:
- player->PlayerTalkClass->SendCloseGossip();
- break;
- case GOSSIP_ACTION_INFO_DEF + 2:
- GossipObjects(player, m_creature);
- break;
- }
- }
- return true;
- }
- };
- void AddSC_Script_Evento_Gurubashi()
- {
- new NPC_Evento_Gurubashi();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement