Guest User

Untitled

a guest
Dec 11th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 151.07 KB | None | 0 0
  1. diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
  2. index e1485b3..f18abd4 100644
  3. --- a/src/server/game/Entities/Player/Player.cpp
  4. +++ b/src/server/game/Entities/Player/Player.cpp
  5. @@ -2951,6 +2951,22 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate)
  6. {
  7. if (xp < 1)
  8. return;
  9. +
  10. + uint32 guild = GetGuildIdFromDB(this->GetGUID());
  11. + QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  12. + if (result && xp > 0) {
  13. + Field *fields = result->Fetch();
  14. + uint16 level = fields[0].GetUInt16();
  15. + uint32 xps = fields[1].GetUInt32();
  16. +
  17. + QueryResult knowLevel = CharacterDatabase.PQuery("SELECT level FROM guild_xp_table WHERE xp > %u", xps);
  18. + if (knowLevel)
  19. + {
  20. + Field *fs = knowLevel->Fetch();
  21. + uint16 gLevel = fs[0].GetUInt16();
  22. + xp += xp*(gLevel-1)*5/100;
  23. + }
  24. + }
  25.  
  26. if (!IsAlive() && !GetBattlegroundId())
  27. return;
  28. @@ -6879,6 +6895,29 @@ void Player::CheckAreaExploreAndOutdoor()
  29. }
  30. }
  31.  
  32. +uint32 Player::GetGuildRate(uint32 amount) const
  33. +{
  34. +if (uint32 guild = GetGuildIdFromDB(GetGUID())) {
  35. + QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  36. + if (result)
  37. + {
  38. + Field *fields = result->Fetch();
  39. + uint16 level = fields[0].GetUInt16();
  40. + uint32 xp = fields[1].GetUInt32();
  41. + QueryResult knowLevel = CharacterDatabase.PQuery("SELECT level FROM guild_xp_table WHERE xp > %u", xp);
  42. + if (knowLevel)
  43. + {
  44. + Field *fs = knowLevel->Fetch();
  45. + uint16 gLevel = fs[0].GetUInt16();
  46. + amount += amount*(gLevel-1)*5/100;
  47. + }
  48. + }
  49. + }
  50. +
  51. + return amount;
  52. +
  53. +}
  54. +
  55. uint32 Player::TeamForRace(uint8 race)
  56. {
  57. if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race))
  58. @@ -7222,7 +7261,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto
  59. AddPct(honor_f, GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HONOR_GAIN_PCT));
  60. }
  61.  
  62. - honor_f *= sWorld->getRate(RATE_HONOR);
  63. + honor_f *= GetGuildRate(sWorld->getRate(RATE_HONOR));
  64. // Back to int now
  65. honor = int32(honor_f);
  66. // honor - for show honor points in log
  67. @@ -8864,7 +8903,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
  68. loot->FillLoot(item->GetEntry(), LootTemplates_Milling, this, true);
  69. break;
  70. default:
  71. - loot->generateMoneyLoot(item->GetTemplate()->MinMoneyLoot, item->GetTemplate()->MaxMoneyLoot);
  72. + loot->generateMoneyLoot(GetGuildRate(item->GetTemplate()->MinMoneyLoot), GetGuildRate(item->GetTemplate()->MaxMoneyLoot));
  73. loot->FillLoot(item->GetEntry(), LootTemplates_Item, this, true, loot->gold != 0);
  74.  
  75. // Force save the loot and money items that were just rolled
  76. @@ -8898,7 +8937,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
  77. loot->FillLoot(1, LootTemplates_Creature, this, true);
  78. // It may need a better formula
  79. // Now it works like this: lvl10: ~6copper, lvl70: ~9silver
  80. - bones->loot.gold = uint32(urand(50, 150) * 0.016f * pow(float(pLevel)/5.76f, 2.5f) * sWorld->getRate(RATE_DROP_MONEY));
  81. + bones->loot.gold = GetGuildRate(uint32(urand(50, 150) * 0.016f * pow(float(pLevel)/5.76f, 2.5f) * sWorld->getRate(RATE_DROP_MONEY)));
  82. }
  83.  
  84. if (bones->lootRecipient != this)
  85. @@ -8938,7 +8977,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
  86. // Generate extra money for pick pocket loot
  87. const uint32 a = urand(0, creature->getLevel()/2);
  88. const uint32 b = urand(0, getLevel()/2);
  89. - loot->gold = uint32(10 * (a + b) * sWorld->getRate(RATE_DROP_MONEY));
  90. + loot->gold = GetGuildRate(uint32(10 * (a + b) * sWorld->getRate(RATE_DROP_MONEY)));
  91. permission = OWNER_PERMISSION;
  92. }
  93. }
  94. @@ -15225,7 +15264,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
  95. if (getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
  96. GiveXP(XP, NULL);
  97. else
  98. - moneyRew = int32(quest->GetRewMoneyMaxLevel() * sWorld->getRate(RATE_DROP_MONEY));
  99. + moneyRew = GetGuildRate(int32(quest->GetRewMoneyMaxLevel() * sWorld->getRate(RATE_DROP_MONEY)));
  100.  
  101. // Give player extra money if GetRewOrReqMoney > 0 and get ReqMoney if negative
  102. if (quest->GetRewOrReqMoney())
  103. @@ -16586,7 +16625,7 @@ void Player::SendQuestReward(Quest const* quest, uint32 XP)
  104. else
  105. {
  106. data << uint32(0);
  107. - data << uint32(quest->GetRewOrReqMoney() + int32(quest->GetRewMoneyMaxLevel() * sWorld->getRate(RATE_DROP_MONEY)));
  108. + data << GetGuildRate(uint32(quest->GetRewOrReqMoney() + int32(quest->GetRewMoneyMaxLevel() * sWorld->getRate(RATE_DROP_MONEY))));
  109. }
  110.  
  111. data << uint32(10 * quest->CalculateHonorGain(GetQuestLevel(quest)));
  112. diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
  113. index 35a3f5f..173d7d3 100644
  114. --- a/src/server/game/Entities/Player/Player.h
  115. +++ b/src/server/game/Entities/Player/Player.h
  116. @@ -1100,6 +1100,9 @@ class Player : public Unit, public GridObject<Player>
  117.  
  118. void SendInitialPacketsBeforeAddToMap();
  119. void SendInitialPacketsAfterAddToMap();
  120. +
  121. + uint32 GetGuildRate(uint32 amount) const;
  122. +
  123. void SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg = 0);
  124. void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time);
  125.  
  126. diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp
  127. index c52d046..043fbe5 100644
  128. --- a/src/server/game/Guilds/Guild.cpp
  129. +++ b/src/server/game/Guilds/Guild.cpp
  130. @@ -1177,6 +1177,8 @@ bool Guild::Create(Player* pLeader, std::string const& name)
  131. PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBERS);
  132. stmt->setUInt32(0, m_id);
  133. trans->Append(stmt);
  134. +
  135. + CharacterDatabase.PQuery("INSERT INTO guild_level (guild, level, xp) VALUES (%u, 1, 0)", m_id);
  136.  
  137. uint8 index = 0;
  138. stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD);
  139. @@ -1253,6 +1255,10 @@ void Guild::Disband()
  140.  
  141. CharacterDatabase.CommitTransaction(trans);
  142. sGuildMgr->RemoveGuild(m_id);
  143. +
  144. + uint32 guild = GetId();
  145. + CharacterDatabase.PQuery("DELETE FROM guild_level WHERE guild = %u", guild);
  146. + CharacterDatabase.PQuery("DELETE FROM guild_level_invested WHERE guild = %u", guild);
  147. }
  148.  
  149. void Guild::UpdateMemberData(Player* player, uint8 dataid, uint32 value)
  150. @@ -1573,6 +1579,35 @@ void Guild::HandleAcceptMember(WorldSession* session)
  151. return;
  152.  
  153. AddMember(player->GetGUID());
  154. +
  155. + uint32 guild = GetId();
  156. + std::string name = player->GetName();
  157. + QueryResult result = CharacterDatabase.PQuery("SELECT spellortitle, isSpell FROM guild_learn_spell WHERE guild = %u", guild);
  158. + if (result) {
  159. + do {
  160. + Field* fields = result->Fetch();
  161. + uint32 spellortitle = fields[0].GetUInt32();
  162. + uint32 isSpell = fields[1].GetUInt32();
  163. +
  164. + if (isSpell == 1) player->learnSpell(spellortitle, false);
  165. + else player->SetTitle(sCharTitlesStore.LookupEntry(spellortitle));
  166. + }
  167. + while (result->NextRow());
  168. + }
  169. +
  170. + uint32 number;
  171. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  172. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number) VALUES (%u, '%s', 0, 0, 10000)", guild, name.c_str());
  173. +
  174. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  175. + if (result3) return;
  176. +
  177. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  178. + if (result2) {
  179. + Field* fields = result2->Fetch();
  180. + number = fields[0].GetUInt32();
  181. + }
  182. + CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number) VALUES (%u, '%s', 0, 0, %u)", guild, name.c_str(), number+1);
  183. }
  184.  
  185. void Guild::HandleLeaveMember(WorldSession* session)
  186. @@ -1591,6 +1626,26 @@ void Guild::HandleLeaveMember(WorldSession* session)
  187. // Guild is disbanded if leader leaves.
  188. Disband();
  189. disband = true;
  190. +
  191. + uint32 guild = GetId();
  192. + QueryResult result2 = CharacterDatabase.PQuery("SELECT spellortitle, isSpell FROM guild_learn_spell WHERE guild = %u", guild);
  193. + if (result2) {
  194. + do {
  195. + Field* fields = result2->Fetch();
  196. + uint32 spellortitle = fields[0].GetUInt32();
  197. + uint32 isSpell = fields[1].GetUInt32();
  198. +
  199. + if (isSpell == 1) player->removeSpell(spellortitle);
  200. + else
  201. + {
  202. + player->SetTitle(sCharTitlesStore.LookupEntry(spellortitle), true);
  203. + if (!player->HasTitle(player->GetInt32Value(PLAYER_CHOSEN_TITLE))) player->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
  204. + }
  205. + }
  206. + while (result2->NextRow());
  207. + }
  208. +
  209. + CharacterDatabase.PQuery("DELETE FROM guild_learn_spell WHERE guild = %u", guild);
  210. }
  211. }
  212. else
  213. @@ -1601,6 +1656,24 @@ void Guild::HandleLeaveMember(WorldSession* session)
  214. _BroadcastEvent(GE_LEFT, player->GetGUID(), player->GetName().c_str());
  215.  
  216. SendCommandResult(session, GUILD_COMMAND_QUIT, ERR_GUILD_COMMAND_SUCCESS, m_name);
  217. +
  218. + uint32 guild = GetId();
  219. + QueryResult result2 = CharacterDatabase.PQuery("SELECT spellortitle, isSpell FROM guild_learn_spell WHERE guild = %u", guild);
  220. + if (result2) {
  221. + do {
  222. + Field* fields = result2->Fetch();
  223. + uint32 spellortitle = fields[0].GetUInt32();
  224. + uint32 isSpell = fields[1].GetUInt32();
  225. +
  226. + if (isSpell == 1) player->removeSpell(spellortitle);
  227. + else
  228. + {
  229. + player->SetTitle(sCharTitlesStore.LookupEntry(spellortitle), true);
  230. + if (!player->HasTitle(player->GetInt32Value(PLAYER_CHOSEN_TITLE))) player->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
  231. + }
  232. + }
  233. + while (result2->NextRow());
  234. + }
  235. }
  236.  
  237. sCalendarMgr->RemovePlayerGuildEventsAndSignups(player->GetGUID(), GetId());
  238. @@ -1633,6 +1706,29 @@ void Guild::HandleRemoveMember(WorldSession* session, std::string const& name)
  239. DeleteMember(guid, false, true);
  240. _LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUIDLow(), GUID_LOPART(guid));
  241. _BroadcastEvent(GE_REMOVED, 0, name.c_str(), player->GetName().c_str());
  242. +
  243. + uint32 guild = GetId();
  244. + QueryResult result2 = CharacterDatabase.PQuery("SELECT spellortitle, isSpell FROM guild_learn_spell WHERE guild = %u", guild);
  245. + if (result2) {
  246. + do {
  247. + Field* fields = result2->Fetch();
  248. + uint32 spellortitle = fields[0].GetUInt32();
  249. + uint32 isSpell = fields[1].GetUInt32();
  250. +
  251. + if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid))
  252. + {
  253. + if (onlinePlayer->IsInWorld()) {
  254. + if (isSpell == 1) onlinePlayer->removeSpell(spellortitle);
  255. + else
  256. + {
  257. + onlinePlayer->SetTitle(sCharTitlesStore.LookupEntry(spellortitle), true);
  258. + if (!onlinePlayer->HasTitle(onlinePlayer->GetInt32Value(PLAYER_CHOSEN_TITLE))) onlinePlayer->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
  259. + }
  260. + }
  261. + }
  262. + }
  263. + while (result2->NextRow());
  264. + }
  265. }
  266. }
  267. }
  268. @@ -1943,7 +2039,23 @@ void Guild::SendLoginInfo(WorldSession* session)
  269. bool Guild::LoadFromDB(Field* fields)
  270. {
  271. m_id = fields[0].GetUInt32();
  272. - m_name = fields[1].GetString();
  273. + QueryResult resul = CharacterDatabase.PQuery("SELECT level, color FROM guild_level WHERE guild = %u", m_id);
  274. + if (resul)
  275. + {
  276. + std::ostringstream m_nam;
  277. + Field *field = resul->Fetch();
  278. + uint16 leve = field[0].GetUInt16();
  279. + std::string color = field[1].GetString();
  280. + if (color != "") m_nam << color;
  281. + else m_nam << "";
  282. + m_nam << fields[1].GetString();
  283. + if (color != "") m_nam << "|r (";
  284. + else m_nam << " (";
  285. + m_nam << leve;
  286. + m_nam << " yp.)";
  287. + m_name = m_nam.str().c_str();
  288. + }
  289. + else m_name = fields[1].GetString();
  290. m_leaderGuid = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER);
  291. m_emblemInfo.LoadFromDB(fields);
  292. m_info = fields[8].GetString();
  293. diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
  294. index 4da0d82..93e8a04 100644
  295. --- a/src/server/game/Handlers/MiscHandler.cpp
  296. +++ b/src/server/game/Handlers/MiscHandler.cpp
  297. @@ -192,6 +192,21 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData)
  298.  
  299. recvData >> guild_name; // guild name, case sensitive...
  300.  
  301. + Guild* _guild = sGuildMgr->GetGuildByName(guild_name);
  302. + if (_guild)
  303. + {
  304. + QueryResult resul = CharacterDatabase.PQuery("SELECT level FROM guild_level WHERE guild = %u", _guild->GetId());
  305. + if (resul)
  306. + {
  307. + Field *field = resul->Fetch();
  308. + uint16 leve = field[0].GetUInt16();
  309. +
  310. + guild_name += ": ";
  311. + guild_name += leve;
  312. + guild_name += " level";
  313. + }
  314. + }
  315. +
  316. recvData >> racemask; // race mask
  317. recvData >> classmask; // class mask
  318. recvData >> zones_count; // zones count, client limit = 10 (2.0.10)
  319. diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
  320. index 6e9dbea..9b5e5c2 100644
  321. --- a/src/server/scripts/Commands/cs_account.cpp
  322. +++ b/src/server/scripts/Commands/cs_account.cpp
  323. @@ -27,6 +27,30 @@ EndScriptData */
  324. #include "Language.h"
  325. #include "Player.h"
  326. #include "ScriptMgr.h"
  327. +#include "Guild.h"
  328. +#include "GuildMgr.h"
  329. +
  330. +void UpdateLevel(Player* player) {
  331. + uint32 guild = player->GetGuildId();
  332. + QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  333. + if (result) {
  334. + Field *fields = result->Fetch();
  335. + uint16 level = fields[0].GetUInt16();
  336. + uint32 xp = fields[1].GetUInt32();
  337. +
  338. + QueryResult knowLevel = CharacterDatabase.PQuery("SELECT level FROM guild_xp_table WHERE xp > %u", xp);
  339. + if (knowLevel)
  340. + {
  341. + Field *fs = knowLevel->Fetch();
  342. + uint16 gLevel = fs[0].GetUInt16();
  343. + CharacterDatabase.PQuery("UPDATE guild_level SET level = %u WHERE guild = %u",gLevel, guild);
  344. + }
  345. +
  346. + }
  347. +
  348. + sGuildMgr->LoadGuilds();
  349. +
  350. + }
  351.  
  352. class account_commandscript : public CommandScript
  353. {
  354. @@ -942,7 +966,3978 @@ public:
  355. }
  356. };
  357.  
  358. +class item_tpguild : public ItemScript
  359. +{
  360. +public:
  361. + item_tpguild() : ItemScript("item_tpguild") { }
  362. +
  363. + bool OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/)
  364. + {
  365. + uint32 guild = player->GetGuildId();
  366. + QueryResult result = CharacterDatabase.PQuery("SELECT x, y, z, map FROM guildhouses WHERE guild = %u", guild);
  367. + if (result && !player->IsInCombat())
  368. + {
  369. + float x,y,z;
  370. + uint32 map;
  371. + std::string name;
  372. +
  373. + Field* fields = result->Fetch();
  374. + x = fields[0].GetFloat();
  375. + y = fields[1].GetFloat();
  376. + z = fields[2].GetFloat();
  377. + map = fields[3].GetUInt32();
  378. +
  379. + player->TeleportTo(map,x,y,z,0.0f,0U);
  380. + player->RemoveSpellCooldown(8690, true);
  381. + player->SetPhaseMask(1, true);
  382. + }
  383. +
  384. + return true;
  385. + }
  386. +
  387. +};
  388. +
  389. +class npc_guild_level : public CreatureScript
  390. +
  391. +{
  392. +
  393. + public:
  394. +
  395. + npc_guild_level() : CreatureScript("npc_guild_level") {}
  396. +
  397. + bool OnGossipHello(Player* player, Creature* creature) {
  398. + player->PlayerTalkClass->ClearMenus();
  399. + uint32 guild = player->GetGuildId();
  400. + uint16 level;
  401. + if (!guild) {
  402. + player->SEND_GOSSIP_MENU(55004, creature->GetGUID());
  403. + return false;
  404. + }
  405. + QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  406. + if (result) {
  407. + Field *fields = result->Fetch();
  408. + level = fields[0].GetUInt16();
  409. + if (level < 30) {
  410. + std::ostringstream temb;
  411. + temb << "|TInterface/ICONS/INV_Inscription_ArmorScroll02:32:32:-18:0|tП";
  412. + std::ostringstream femb;
  413. + femb << "|TInterface/ICONS/INV_Sword_131:32:32:-18:0|tПожертвовать 1 эмблему (10 опыта гильдии)";
  414. + std::ostringstream hnr;
  415. + hnr << "|TInterface/ICONS/Achievement_BG_kill_flag_carrierEOS:32:32:-18:0|tПожертвовать очки чести для гильдии";
  416. + std::ostringstream arn;
  417. + arn << "|TInterface/ICONS/Achievement_Arena_2v2_1:32:32:-18:0|tПожертвовать очки арены для гильдии";
  418. + std::ostringstream gld;
  419. + gld << "|TInterface/ICONS/Achievement_Reputation_02:32:32:-18:0|tПожертвовать золото для гильдии";
  420. + //player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, temb.str(), GOSSIP_SENDER_MAIN, 35);
  421. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, femb.str(), GOSSIP_SENDER_MAIN, 36);
  422. + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, gld.str(), GOSSIP_SENDER_MAIN, 200, "Введите сумму, которую хотите пожертвовать, 5 000 золота = 10 опыта гильдии", 0, true);
  423. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, hnr.str(), GOSSIP_SENDER_MAIN, 1);
  424. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, arn.str(), GOSSIP_SENDER_MAIN, 2);
  425. + }
  426. + }
  427. +
  428. + if (player->GetRank() == 0)
  429. + {
  430. + std::ostringstream clr;
  431. + clr << "|TInterface/ICONS/Spell_Magic_ManaGain:32:32:-18:0|tСменить цвет названия ги";
  432. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, clr.str(), GOSSIP_SENDER_MAIN, 24);
  433. + }
  434. + std::ostringstream prg;
  435. + prg << "|TInterface/ICONS/Spell_Magic_ManaGain:32:32:-18:0|tПрогресс моей гильдии";
  436. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, prg.str(), GOSSIP_SENDER_MAIN, 3);
  437. + std::ostringstream gsr;
  438. + gsr << "|TInterface/ICONS/Spell_Shadow_Fumble:32:32:-18:0|tТОП гильдий с уровнями";
  439. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, gsr.str(), GOSSIP_SENDER_MAIN, 13);
  440. + std::ostringstream vlg;
  441. + vlg << "|TInterface/ICONS/Temp:32:32:-18:0|tСписок вложивших в гильдию";
  442. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, vlg.str(), GOSSIP_SENDER_MAIN, 9914);
  443. +
  444. + std::ostringstream vxd;
  445. + vxd << "|TInterface/ICONS/Spell_ChargeNegative:32:32:-18:0|tВыход";
  446. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, vxd.str(), GOSSIP_SENDER_MAIN, 4);
  447. + player->SEND_GOSSIP_MENU(55000, creature->GetGUID());
  448. +
  449. + return true;
  450. + }
  451. +
  452. + void InvestedRoster(Player* player, Creature* creature) {
  453. + player->PlayerTalkClass->ClearMenus();
  454. + //player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию свитков", GOSSIP_SENDER_MAIN, 9917);
  455. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию эмблем", GOSSIP_SENDER_MAIN, 9918);
  456. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию очков чести", GOSSIP_SENDER_MAIN, 9915);
  457. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию очков арены", GOSSIP_SENDER_MAIN, 9916);
  458. + //player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию золота", GOSSIP_SENDER_MAIN, 9000);
  459. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  460. + }
  461. +
  462. + void InvestedRosterGold1(Player* player, Creature* creature) {
  463. + player->PlayerTalkClass->ClearMenus();
  464. + uint32 guild = player->GetGuildId();
  465. + QueryResult result = CharacterDatabase.PQuery("SELECT name, gold, number FROM guild_level_invested WHERE gold > 0 AND guild = %u ORDER BY honor DESC", guild);
  466. + if (result) {
  467. + std::string name;
  468. + uint32 gold;
  469. + uint64 number;
  470. + uint16 go = 0;
  471. + do {
  472. + Field* fields = result->Fetch();
  473. + name = fields[0].GetString();
  474. + gold = fields[1].GetUInt32();
  475. + number = fields[2].GetUInt64();
  476. +
  477. + if (go == 30) break;
  478. + std::stringstream buffer;
  479. + buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << gold << " золота" << "|r";
  480. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
  481. +
  482. + go++;
  483. +
  484. + } while (result->NextRow());
  485. +
  486. +
  487. + }
  488. +
  489. +
  490. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  491. + }
  492. +
  493. + void InvestedSvitok(Player* player, Creature* creature) {
  494. + player->PlayerTalkClass->ClearMenus();
  495. + uint32 guild = player->GetGuildId();
  496. + QueryResult result = CharacterDatabase.PQuery("SELECT name, svitok, number FROM guild_level_invested WHERE svitok > 0 AND guild = %u ORDER BY svitok DESC", guild);
  497. + if (result) {
  498. + std::string name;
  499. + uint32 svitok;
  500. + uint64 number;
  501. + uint16 go = 0;
  502. + do {
  503. + Field* fields = result->Fetch();
  504. + name = fields[0].GetString();
  505. + svitok = fields[1].GetUInt32();
  506. + number = fields[2].GetUInt64();
  507. +
  508. + if (go == 50) {
  509. + break;
  510. + }
  511. + std::stringstream buffer;
  512. + buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << svitok << " свитков" << "|r";
  513. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
  514. +
  515. + go++;
  516. +
  517. + } while (result->NextRow());
  518. +
  519. +
  520. + }
  521. +
  522. +
  523. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  524. + }
  525. +
  526. + void InvestedToken(Player* player, Creature* creature) {
  527. + player->PlayerTalkClass->ClearMenus();
  528. + uint32 guild = player->GetGuildId();
  529. + QueryResult result = CharacterDatabase.PQuery("SELECT name, token, number FROM guild_level_invested WHERE token > 0 AND guild = %u ORDER BY token DESC", guild);
  530. + if (result) {
  531. + std::string name;
  532. + uint32 token;
  533. + uint64 number;
  534. + uint16 go = 0;
  535. + do {
  536. + Field* fields = result->Fetch();
  537. + name = fields[0].GetString();
  538. + token = fields[1].GetUInt32();
  539. + number = fields[2].GetUInt64();
  540. +
  541. + if (go == 50) {
  542. + break;
  543. + }
  544. + std::stringstream buffer;
  545. + buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << token << " эмблем" << "|r";
  546. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
  547. +
  548. + go++;
  549. +
  550. + } while (result->NextRow());
  551. +
  552. +
  553. + }
  554. +
  555. +
  556. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  557. + }
  558. +
  559. + void InvestedRosterHonor1(Player* player, Creature* creature) {
  560. + player->PlayerTalkClass->ClearMenus();
  561. + uint32 guild = player->GetGuildId();
  562. + QueryResult result = CharacterDatabase.PQuery("SELECT name, honor, number FROM guild_level_invested WHERE honor > 0 AND guild = %u ORDER BY honor DESC", guild);
  563. + if (result) {
  564. + std::string name;
  565. + uint32 honor;
  566. + uint64 number;
  567. + uint16 go = 0;
  568. + do {
  569. + Field* fields = result->Fetch();
  570. + name = fields[0].GetString();
  571. + honor = fields[1].GetUInt32();
  572. + number = fields[2].GetUInt64();
  573. +
  574. + if (go == 30) {
  575. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 9910);
  576. + break;
  577. + }
  578. + std::stringstream buffer;
  579. + buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << honor << " чести" << "|r";
  580. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
  581. +
  582. + go++;
  583. +
  584. + } while (result->NextRow());
  585. +
  586. +
  587. + }
  588. +
  589. +
  590. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  591. + }
  592. +
  593. + void InvestedRosterHonor2(Player* player, Creature* creature) {
  594. + player->PlayerTalkClass->ClearMenus();
  595. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 9911);
  596. + uint32 guild = player->GetGuildId();
  597. + QueryResult result = CharacterDatabase.PQuery("SELECT name, honor, number FROM guild_level_invested WHERE honor > 0 AND guild = %u ORDER BY honor DESC", guild);
  598. + if (result) {
  599. + std::string name;
  600. + uint32 honor;
  601. + uint64 number;
  602. + uint16 go = 0;
  603. + do {
  604. + if (go < 30) {
  605. + go++;
  606. + continue;
  607. + }
  608. + Field* fields = result->Fetch();
  609. + name = fields[0].GetString();
  610. + honor = fields[1].GetUInt32();
  611. + number = fields[2].GetUInt64();
  612. +
  613. + if (go == 60) break;
  614. + std::stringstream buffer;
  615. + buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << honor << " чести" << "|r";
  616. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
  617. +
  618. + go++;
  619. +
  620. + } while (result->NextRow());
  621. +
  622. +
  623. + }
  624. +
  625. +
  626. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  627. + }
  628. +
  629. + void InvestedRosterArena1(Player* player, Creature* creature) {
  630. + player->PlayerTalkClass->ClearMenus();
  631. + uint32 guild = player->GetGuildId();
  632. + QueryResult result = CharacterDatabase.PQuery("SELECT name, arena, number FROM guild_level_invested WHERE arena > 0 AND guild = %u ORDER BY arena DESC", guild);
  633. + if (result) {
  634. + std::string name;
  635. + uint32 arena;
  636. + uint64 number;
  637. + uint16 go = 0;
  638. + do {
  639. + Field* fields = result->Fetch();
  640. + name = fields[0].GetString();
  641. + arena = fields[1].GetUInt32();
  642. + number = fields[2].GetUInt64();
  643. +
  644. + if (go == 30) {
  645. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 9912);
  646. + break;
  647. + }
  648. + std::stringstream buffer;
  649. + buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << arena << " арены" << "|r";
  650. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
  651. +
  652. + go++;
  653. +
  654. + } while (result->NextRow());
  655. +
  656. +
  657. + }
  658. +
  659. +
  660. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  661. + }
  662. +
  663. + void InvestedRosterArena2(Player* player, Creature* creature) {
  664. + player->PlayerTalkClass->ClearMenus();
  665. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 9913);
  666. + uint32 guild = player->GetGuildId();
  667. + QueryResult result = CharacterDatabase.PQuery("SELECT name, arena, number FROM guild_level_invested WHERE arena > 0 AND guild = %u ORDER BY arena DESC", guild);
  668. + if (result) {
  669. + std::string name;
  670. + uint32 arena;
  671. + uint64 number;
  672. + uint16 go = 0;
  673. + do {
  674. + if (go < 30) {
  675. + go++;
  676. + continue;
  677. + }
  678. + Field* fields = result->Fetch();
  679. + name = fields[0].GetString();
  680. + arena = fields[1].GetUInt32();
  681. + number = fields[2].GetUInt64();
  682. +
  683. + if (go == 60) break;
  684. + std::stringstream buffer;
  685. + buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << arena << " арены" << "|r";
  686. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
  687. +
  688. + go++;
  689. +
  690. + } while (result->NextRow());
  691. +
  692. +
  693. + }
  694. +
  695. +
  696. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  697. + }
  698. +
  699. +
  700. +
  701. + void UpdateLevelCost(Player* player) {
  702. + uint32 guild = player->GetGuildId();
  703. + QueryResult result10 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  704. + if (result10) {
  705. + Field *fields = result10->Fetch();
  706. + uint16 level = fields[0].GetUInt16();
  707. + uint32 xp = fields[1].GetUInt32();
  708. +
  709. + QueryResult knowLevel = CharacterDatabase.PQuery("SELECT level FROM guild_xp_table WHERE xp > %u", xp);
  710. + if (knowLevel)
  711. + {
  712. + Field *fs = knowLevel->Fetch();
  713. + uint16 gLevel = fs[0].GetUInt16();
  714. + CharacterDatabase.PQuery("UPDATE guild_level SET level = %u WHERE guild = %u",gLevel, guild);
  715. + }
  716. +
  717. + }
  718. + }
  719. +
  720. +
  721. +
  722. + void SelectSpell5(Player* player, Creature* creature, uint32 action) {
  723. + uint32 spell;
  724. + uint32 cost;
  725. + uint32 number;
  726. + uint32 guild = player->GetGuildId();
  727. + uint64 guid;
  728. + QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 5");
  729. + if (result) {
  730. + do {
  731. + Field* fields = result->Fetch();
  732. + spell = fields[0].GetUInt32();
  733. + cost = fields[1].GetUInt32();
  734. + number = fields[2].GetUInt32();
  735. +
  736. + if (number == action) {
  737. + // learn spell
  738. +
  739. + QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
  740. + if (result2) {
  741. + QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  742. + if (result15) {
  743. + Field* fields = result15->Fetch();
  744. + uint16 level = fields[0].GetUInt16();
  745. + uint32 xp = fields[1].GetUInt32();
  746. + if (xp >= cost) {
  747. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
  748. +
  749. + UpdateLevelCost(player);
  750. + }
  751. + else {
  752. + player->CLOSE_GOSSIP_MENU();
  753. + player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
  754. + return;
  755. + }
  756. +
  757. + }
  758. + do {
  759. + Field* fields = result2->Fetch();
  760. + guid = fields[0].GetUInt64();
  761. + if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
  762. + onlinePlayer->learnSpell(spell, false);
  763. + }
  764. + else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
  765. +
  766. + CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
  767. +
  768. +
  769. + }
  770. + while (result2->NextRow());
  771. +
  772. + }
  773. +
  774. + // learn spell
  775. + player->CLOSE_GOSSIP_MENU();
  776. + player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
  777. + }
  778. +
  779. + }
  780. + while (result->NextRow());
  781. + }
  782. +
  783. + }
  784. +
  785. + void SelectSpell10(Player* player, Creature* creature, uint32 action) {
  786. + uint32 spell;
  787. + uint32 cost;
  788. + uint32 number;
  789. + uint32 guild = player->GetGuildId();
  790. + uint64 guid;
  791. + QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 10");
  792. + if (result) {
  793. + do {
  794. + Field* fields = result->Fetch();
  795. + spell = fields[0].GetUInt32();
  796. + cost = fields[1].GetUInt32();
  797. + number = fields[2].GetUInt32();
  798. +
  799. + if (number == action) {
  800. + // learn spell
  801. +
  802. + QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
  803. + if (result2) {
  804. + QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  805. + if (result15) {
  806. + Field* fields = result15->Fetch();
  807. + uint16 level = fields[0].GetUInt16();
  808. + uint32 xp = fields[1].GetUInt32();
  809. + if (xp >= cost) {
  810. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
  811. +
  812. + UpdateLevelCost(player);
  813. + }
  814. + else {
  815. + player->CLOSE_GOSSIP_MENU();
  816. + player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
  817. + return;
  818. + }
  819. +
  820. + }
  821. + do {
  822. + Field* fields = result2->Fetch();
  823. + guid = fields[0].GetUInt64();
  824. + if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
  825. + onlinePlayer->learnSpell(spell, false);
  826. + }
  827. + else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
  828. +
  829. + CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
  830. +
  831. +
  832. + }
  833. + while (result2->NextRow());
  834. +
  835. + }
  836. +
  837. + // learn spell
  838. + player->CLOSE_GOSSIP_MENU();
  839. + player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
  840. + }
  841. +
  842. + }
  843. + while (result->NextRow());
  844. + }
  845. +
  846. + }
  847. +
  848. + void SelectSpell15(Player* player, Creature* creature, uint32 action) {
  849. + uint32 spell;
  850. + uint32 cost;
  851. + uint32 number;
  852. + uint32 guild = player->GetGuildId();
  853. + uint64 guid;
  854. + QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 15");
  855. + if (result) {
  856. + do {
  857. + Field* fields = result->Fetch();
  858. + spell = fields[0].GetUInt32();
  859. + cost = fields[1].GetUInt32();
  860. + number = fields[2].GetUInt32();
  861. +
  862. + if (number == action) {
  863. + // learn spell
  864. +
  865. + QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
  866. + if (result2) {
  867. + QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  868. + if (result15) {
  869. + Field* fields = result15->Fetch();
  870. + uint16 level = fields[0].GetUInt16();
  871. + uint32 xp = fields[1].GetUInt32();
  872. + if (xp >= cost) {
  873. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
  874. +
  875. + UpdateLevelCost(player);
  876. + }
  877. + else {
  878. + player->CLOSE_GOSSIP_MENU();
  879. + player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
  880. + return;
  881. + }
  882. +
  883. + }
  884. + do {
  885. + Field* fields = result2->Fetch();
  886. + guid = fields[0].GetUInt64();
  887. + if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
  888. + onlinePlayer->learnSpell(spell, false);
  889. + }
  890. + else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
  891. +
  892. + CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
  893. +
  894. +
  895. + }
  896. + while (result2->NextRow());
  897. +
  898. + }
  899. +
  900. + // learn spell
  901. + player->CLOSE_GOSSIP_MENU();
  902. + player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
  903. + }
  904. +
  905. + }
  906. + while (result->NextRow());
  907. + }
  908. +
  909. + }
  910. +
  911. + void SelectSpell20(Player* player, Creature* creature, uint32 action) {
  912. + uint32 spell;
  913. + uint32 cost;
  914. + uint32 number;
  915. + uint32 guild = player->GetGuildId();
  916. + uint64 guid;
  917. + QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 20");
  918. + if (result) {
  919. + do {
  920. + Field* fields = result->Fetch();
  921. + spell = fields[0].GetUInt32();
  922. + cost = fields[1].GetUInt32();
  923. + number = fields[2].GetUInt32();
  924. +
  925. + if (number == action) {
  926. + // learn spell
  927. +
  928. + QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
  929. + if (result2) {
  930. + QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  931. + if (result15) {
  932. + Field* fields = result15->Fetch();
  933. + uint16 level = fields[0].GetUInt16();
  934. + uint32 xp = fields[1].GetUInt32();
  935. + if (xp >= cost) {
  936. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
  937. +
  938. + UpdateLevelCost(player);
  939. + }
  940. + else {
  941. + player->CLOSE_GOSSIP_MENU();
  942. + player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
  943. + return;
  944. + }
  945. +
  946. + }
  947. + do {
  948. + Field* fields = result2->Fetch();
  949. + guid = fields[0].GetUInt64();
  950. + if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
  951. + onlinePlayer->learnSpell(spell, false);
  952. + }
  953. + else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
  954. +
  955. + CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
  956. +
  957. +
  958. + }
  959. + while (result2->NextRow());
  960. +
  961. + }
  962. +
  963. + // learn spell
  964. + player->CLOSE_GOSSIP_MENU();
  965. + player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
  966. + }
  967. +
  968. + }
  969. + while (result->NextRow());
  970. + }
  971. +
  972. + }
  973. +
  974. + void SelectSpell25(Player* player, Creature* creature, uint32 action) {
  975. + uint32 spell;
  976. + uint32 cost;
  977. + uint32 number;
  978. + uint32 guild = player->GetGuildId();
  979. + uint64 guid;
  980. + QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 25");
  981. + if (result) {
  982. + do {
  983. + Field* fields = result->Fetch();
  984. + spell = fields[0].GetUInt32();
  985. + cost = fields[1].GetUInt32();
  986. + number = fields[2].GetUInt32();
  987. +
  988. + if (number == action) {
  989. + // learn spell
  990. +
  991. + QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
  992. + if (result2) {
  993. + QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  994. + if (result15) {
  995. + Field* fields = result15->Fetch();
  996. + uint16 level = fields[0].GetUInt16();
  997. + uint32 xp = fields[1].GetUInt32();
  998. + if (xp >= cost) {
  999. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
  1000. +
  1001. + UpdateLevelCost(player);
  1002. + }
  1003. + else {
  1004. + player->CLOSE_GOSSIP_MENU();
  1005. + player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
  1006. + return;
  1007. + }
  1008. +
  1009. + }
  1010. + do {
  1011. + Field* fields = result2->Fetch();
  1012. + guid = fields[0].GetUInt64();
  1013. + if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
  1014. + onlinePlayer->learnSpell(spell, false);
  1015. + }
  1016. + else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
  1017. +
  1018. + CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
  1019. +
  1020. +
  1021. + }
  1022. + while (result2->NextRow());
  1023. +
  1024. + }
  1025. +
  1026. + // learn spell
  1027. + player->CLOSE_GOSSIP_MENU();
  1028. + player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
  1029. + }
  1030. +
  1031. + }
  1032. + while (result->NextRow());
  1033. + }
  1034. +
  1035. + }
  1036. +
  1037. + void SelectSpell30(Player* player, Creature* creature, uint32 action) {
  1038. + uint32 spell;
  1039. + uint32 cost;
  1040. + uint32 number;
  1041. + uint32 guild = player->GetGuildId();
  1042. + uint64 guid;
  1043. + QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 30");
  1044. + if (result) {
  1045. + do {
  1046. + Field* fields = result->Fetch();
  1047. + spell = fields[0].GetUInt32();
  1048. + cost = fields[1].GetUInt32();
  1049. + number = fields[2].GetUInt32();
  1050. +
  1051. + if (number == action) {
  1052. + // learn spell
  1053. +
  1054. + QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
  1055. + if (result2) {
  1056. + QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  1057. + if (result15) {
  1058. + Field* fields = result15->Fetch();
  1059. + uint16 level = fields[0].GetUInt16();
  1060. + uint32 xp = fields[1].GetUInt32();
  1061. + if (xp >= cost) {
  1062. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
  1063. +
  1064. + UpdateLevelCost(player);
  1065. + }
  1066. + else {
  1067. + player->CLOSE_GOSSIP_MENU();
  1068. + player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
  1069. + return;
  1070. + }
  1071. +
  1072. + }
  1073. + do {
  1074. + Field* fields = result2->Fetch();
  1075. + guid = fields[0].GetUInt64();
  1076. + if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
  1077. + onlinePlayer->learnSpell(spell, false);
  1078. + }
  1079. + else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
  1080. +
  1081. + CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
  1082. +
  1083. +
  1084. + }
  1085. + while (result2->NextRow());
  1086. +
  1087. + }
  1088. +
  1089. + // learn spell
  1090. + player->CLOSE_GOSSIP_MENU();
  1091. + player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
  1092. + }
  1093. +
  1094. + }
  1095. + while (result->NextRow());
  1096. + }
  1097. +
  1098. + }
  1099. +
  1100. + void ReplaceColorList(Player* player, Creature* creature)
  1101. + {
  1102. + player->PlayerTalkClass->ClearMenus();
  1103. +
  1104. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Красный", GOSSIP_SENDER_MAIN, 25);
  1105. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Синий", GOSSIP_SENDER_MAIN, 26);
  1106. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Чёрный", GOSSIP_SENDER_MAIN, 27);
  1107. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Белый", GOSSIP_SENDER_MAIN, 28);
  1108. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Зелёный", GOSSIP_SENDER_MAIN, 29);
  1109. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Желтый", GOSSIP_SENDER_MAIN, 30);
  1110. +
  1111. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1112. + }
  1113. +
  1114. + void ReplaceColor(Player* player, Creature* creature, uint32 color)
  1115. + {
  1116. + switch(color)
  1117. + {
  1118. + case 1:
  1119. + CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFF0000' WHERE guild = %u", player->GetGuildId());
  1120. + break;
  1121. + case 2:
  1122. + CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cff0000FF' WHERE guild = %u", player->GetGuildId());
  1123. + break;
  1124. + case 3:
  1125. + CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cff000000' WHERE guild = %u", player->GetGuildId());
  1126. + break;
  1127. + case 4:
  1128. + CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFFFFFF' WHERE guild = %u", player->GetGuildId());
  1129. + break;
  1130. + case 5:
  1131. + CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cff00FF00' WHERE guild = %u", player->GetGuildId());
  1132. + break;
  1133. + case 6:
  1134. + CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFFFF00' WHERE guild = %u", player->GetGuildId());
  1135. + break;
  1136. +
  1137. + }
  1138. + sGuildMgr->LoadGuilds();
  1139. + player->GetSession()->SendAreaTriggerMessage("Вы успешно сменили цвет названия гильдии!");
  1140. + player->CLOSE_GOSSIP_MENU();
  1141. + }
  1142. +
  1143. + void BuySpell10(Player* player, Creature* creature) {
  1144. + player->PlayerTalkClass->ClearMenus();
  1145. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9900);
  1146. + uint32 spell;
  1147. + uint32 cost;
  1148. + uint16 level;
  1149. + uint32 number;
  1150. + uint32 faction;
  1151. + char* name;
  1152. + QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 10");
  1153. + if (result) {
  1154. + do {
  1155. + Field* fields = result->Fetch();
  1156. + spell = fields[0].GetUInt32();
  1157. + cost = fields[1].GetUInt32();
  1158. + level = fields[2].GetUInt16();
  1159. + number = fields[3].GetUInt32();
  1160. + faction = fields[4].GetUInt32();
  1161. +
  1162. + if (player->HasSpell(spell)) continue;
  1163. +
  1164. + if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
  1165. +
  1166. + if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
  1167. + const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
  1168. + name = (spellEntry->SpellName[8]);
  1169. +
  1170. + std::stringstream buffer;
  1171. + buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " опыта." << "|r";
  1172. +
  1173. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
  1174. + }
  1175. +
  1176. + while (result->NextRow());
  1177. +
  1178. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1179. + }
  1180. + }
  1181. +
  1182. + void BuySpell15(Player* player, Creature* creature) {
  1183. + player->PlayerTalkClass->ClearMenus();
  1184. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9901);
  1185. + uint32 spell;
  1186. + uint32 cost;
  1187. + uint16 level;
  1188. + uint32 number;
  1189. + uint32 faction;
  1190. + char* name;
  1191. + QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 15");
  1192. + if (result) {
  1193. + do {
  1194. + Field* fields = result->Fetch();
  1195. + spell = fields[0].GetUInt32();
  1196. + cost = fields[1].GetUInt32();
  1197. + level = fields[2].GetUInt16();
  1198. + number = fields[3].GetUInt32();
  1199. + faction = fields[4].GetUInt32();
  1200. +
  1201. + if (player->HasSpell(spell)) continue;
  1202. +
  1203. + if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
  1204. +
  1205. + if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
  1206. + const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
  1207. + name = (spellEntry->SpellName[8]);
  1208. +
  1209. + std::stringstream buffer;
  1210. + buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " опыта." << "|r";
  1211. +
  1212. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
  1213. + }
  1214. +
  1215. + while (result->NextRow());
  1216. +
  1217. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1218. + }
  1219. + }
  1220. +
  1221. + void BuySpell20(Player* player, Creature* creature) {
  1222. + player->PlayerTalkClass->ClearMenus();
  1223. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9902);
  1224. + uint32 spell;
  1225. + uint32 cost;
  1226. + uint16 level;
  1227. + uint32 number;
  1228. + uint32 faction;
  1229. + char* name;
  1230. + QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 20");
  1231. + if (result) {
  1232. + do {
  1233. + Field* fields = result->Fetch();
  1234. + spell = fields[0].GetUInt32();
  1235. + cost = fields[1].GetUInt32();
  1236. + level = fields[2].GetUInt16();
  1237. + number = fields[3].GetUInt32();
  1238. + faction = fields[4].GetUInt32();
  1239. +
  1240. + if (player->HasSpell(spell)) continue;
  1241. +
  1242. + if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
  1243. +
  1244. + if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
  1245. + const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
  1246. + name = (spellEntry->SpellName[8]);
  1247. +
  1248. + std::stringstream buffer;
  1249. + buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " опыта." << "|r";
  1250. +
  1251. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
  1252. + }
  1253. +
  1254. + while (result->NextRow());
  1255. +
  1256. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1257. + }
  1258. + }
  1259. + void BuySpell25(Player* player, Creature* creature) {
  1260. + player->PlayerTalkClass->ClearMenus();
  1261. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9903);
  1262. + uint32 spell;
  1263. + uint32 cost;
  1264. + uint16 level;
  1265. + uint32 number;
  1266. + uint32 faction;
  1267. + char* name;
  1268. + QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 25");
  1269. + if (result) {
  1270. + do {
  1271. + Field* fields = result->Fetch();
  1272. + spell = fields[0].GetUInt32();
  1273. + cost = fields[1].GetUInt32();
  1274. + level = fields[2].GetUInt16();
  1275. + number = fields[3].GetUInt32();
  1276. + faction = fields[4].GetUInt32();
  1277. +
  1278. + if (player->HasSpell(spell)) continue;
  1279. +
  1280. + if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
  1281. +
  1282. + if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
  1283. + const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
  1284. + name = (spellEntry->SpellName[8]);
  1285. +
  1286. + std::stringstream buffer;
  1287. + buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " опыта." << "|r";
  1288. +
  1289. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
  1290. + }
  1291. +
  1292. + while (result->NextRow());
  1293. +
  1294. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1295. + }
  1296. + }
  1297. +
  1298. + void BuySpell30(Player* player, Creature* creature) {
  1299. + player->PlayerTalkClass->ClearMenus();
  1300. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9904);
  1301. + uint32 spell;
  1302. + uint32 cost;
  1303. + uint16 level;
  1304. + uint32 number;
  1305. + uint32 faction;
  1306. + char* name;
  1307. + QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 30");
  1308. + if (result) {
  1309. + do {
  1310. + Field* fields = result->Fetch();
  1311. + spell = fields[0].GetUInt32();
  1312. + cost = fields[1].GetUInt32();
  1313. + level = fields[2].GetUInt16();
  1314. + number = fields[3].GetUInt32();
  1315. + faction = fields[4].GetUInt32();
  1316. +
  1317. + if (player->HasSpell(spell)) continue;
  1318. +
  1319. + if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
  1320. +
  1321. + if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
  1322. + const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
  1323. + name = (spellEntry->SpellName[8]);
  1324. +
  1325. + std::stringstream buffer;
  1326. + buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " опыта." << "|r";
  1327. +
  1328. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
  1329. + }
  1330. +
  1331. + while (result->NextRow());
  1332. +
  1333. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1334. + }
  1335. + }
  1336. +
  1337. + void CurrentSpellsMenu(Player* player, Creature* creature) {
  1338. + player->PlayerTalkClass->ClearMenus();
  1339. +
  1340. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Доступные уровни заклинаний:", GOSSIP_SENDER_MAIN, 9905);
  1341. + uint32 guild = player->GetGuildId();
  1342. + uint16 level;
  1343. + QueryResult result = CharacterDatabase.PQuery("SELECT level FROM guild_level WHERE guild = %u", guild);
  1344. + if (result) {
  1345. + Field* fields = result->Fetch();
  1346. + level = fields[0].GetUInt16();
  1347. + }
  1348. +
  1349. + uint32 spell;
  1350. + if (level >= 5) {
  1351. + QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 5");
  1352. + if (result2) {
  1353. + do {
  1354. + Field* fields = result2->Fetch();
  1355. + spell = fields[0].GetUInt32();
  1356. + if (!player->HasSpell(spell)) {
  1357. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 5-го уровня", GOSSIP_SENDER_MAIN, 24);
  1358. + break;
  1359. + }
  1360. + }
  1361. + while (result2->NextRow());
  1362. + }
  1363. + }
  1364. +
  1365. + if (level >= 10) {
  1366. + QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 10");
  1367. + if (result2) {
  1368. + do {
  1369. + Field* fields = result2->Fetch();
  1370. + spell = fields[0].GetUInt32();
  1371. + if (!player->HasSpell(spell)) {
  1372. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 10-го уровня", GOSSIP_SENDER_MAIN, 25);
  1373. + break;
  1374. + }
  1375. + }
  1376. + while (result2->NextRow());
  1377. + }
  1378. + }
  1379. +
  1380. + if (level >= 15) {
  1381. + QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 15");
  1382. + if (result2) {
  1383. + do {
  1384. + Field* fields = result2->Fetch();
  1385. + spell = fields[0].GetUInt32();
  1386. + if (!player->HasSpell(spell)) {
  1387. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 15-го уровня", GOSSIP_SENDER_MAIN, 26);
  1388. + break;
  1389. + }
  1390. + }
  1391. + while (result2->NextRow());
  1392. + }
  1393. + }
  1394. +
  1395. + if (level >= 20) {
  1396. + QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 20");
  1397. + if (result2) {
  1398. + do {
  1399. + Field* fields = result2->Fetch();
  1400. + spell = fields[0].GetUInt32();
  1401. + if (!player->HasSpell(spell)) {
  1402. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 20-го уровня", GOSSIP_SENDER_MAIN, 27);
  1403. + break;
  1404. + }
  1405. + }
  1406. + while (result2->NextRow());
  1407. + }
  1408. + }
  1409. +
  1410. + if (level >= 25) {
  1411. + QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 25");
  1412. + if (result2) {
  1413. + do {
  1414. + Field* fields = result2->Fetch();
  1415. + spell = fields[0].GetUInt32();
  1416. + if (!player->HasSpell(spell)) {
  1417. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 25-го уровня", GOSSIP_SENDER_MAIN, 28);
  1418. + break;
  1419. + }
  1420. + }
  1421. + while (result2->NextRow());
  1422. + }
  1423. + }
  1424. +
  1425. + if (level >= 30) {
  1426. + QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 30");
  1427. + if (result2) {
  1428. + do {
  1429. + Field* fields = result2->Fetch();
  1430. + spell = fields[0].GetUInt32();
  1431. + if (!player->HasSpell(spell)) {
  1432. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 30-го уровня", GOSSIP_SENDER_MAIN, 29);
  1433. + break;
  1434. + }
  1435. + }
  1436. + while (result2->NextRow());
  1437. + }
  1438. + }
  1439. +
  1440. +
  1441. +
  1442. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1443. + }
  1444. +
  1445. + void AllGuilds1(Player* player, Creature* creature) {
  1446. + player->PlayerTalkClass->ClearMenus();
  1447. + uint32 count;
  1448. + QueryResult result3 = CharacterDatabase.PQuery("SELECT COUNT(guild) FROM guild_level WHERE level > 1");
  1449. + if (result3) {
  1450. + Field* fields = result3->Fetch();
  1451. + count = fields[0].GetUInt32();
  1452. + }
  1453. + QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
  1454. + if (result) {
  1455. + std::string name;
  1456. + std::string gleader;
  1457. + uint32 guild;
  1458. + uint16 level;
  1459. + uint16 go = 0;
  1460. + uint64 leaderguid;
  1461. + do {
  1462. + Field* fields = result->Fetch();
  1463. + guild = fields[0].GetUInt32();
  1464. + level = fields[1].GetUInt16();
  1465. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
  1466. + if (result3) {
  1467. + Field* fields = result3->Fetch();
  1468. + name = fields[0].GetString();
  1469. + leaderguid = fields[1].GetUInt64();
  1470. + }
  1471. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
  1472. + if (result4) {
  1473. + Field* fields = result4->Fetch();
  1474. + gleader = fields[0].GetString();
  1475. + }
  1476. + if (go == 10) {
  1477. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 14);
  1478. + break;
  1479. + }
  1480. + std::stringstream buffer;
  1481. + buffer << "|cff084E13" << name << "|r" << ". Уровень: " << "|cFF1E90FF" << level << "|r" << ". ГМ: " << "|cff790C06" << gleader << "|r";
  1482. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild+100);
  1483. +
  1484. + go++;
  1485. +
  1486. + } while (result->NextRow());
  1487. +
  1488. +
  1489. + }
  1490. +
  1491. +
  1492. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1493. + }
  1494. +
  1495. + void AllGuilds2(Player* player, Creature* creature) {
  1496. + player->PlayerTalkClass->ClearMenus();
  1497. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 19);
  1498. + QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
  1499. + if (result) {
  1500. + std::string name;
  1501. + std::string gleader;
  1502. + uint32 guild;
  1503. + uint16 level;
  1504. + uint16 go = 0;
  1505. + uint64 leaderguid;
  1506. + do {
  1507. + if (go < 10) {
  1508. + go++;
  1509. + continue;
  1510. + }
  1511. + Field* fields = result->Fetch();
  1512. + guild = fields[0].GetUInt32();
  1513. + level = fields[1].GetUInt16();
  1514. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
  1515. + if (result3) {
  1516. + Field* fields = result3->Fetch();
  1517. + name = fields[0].GetString();
  1518. + leaderguid = fields[1].GetUInt64();
  1519. + }
  1520. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
  1521. + if (result4) {
  1522. + Field* fields = result4->Fetch();
  1523. + gleader = fields[0].GetString();
  1524. + }
  1525. + if (go == 20) {
  1526. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше =>", GOSSIP_SENDER_MAIN, 15);
  1527. + break;
  1528. + }
  1529. + std::stringstream buffer;
  1530. + buffer << "|cff084E13" << name << "|r" << ". Уровень: " << "|cFF1E90FF" << level << "|r" << ". ГМ: " << "|cff790C06" << gleader << "|r";
  1531. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild+1000);
  1532. +
  1533. + go++;
  1534. + } while (result->NextRow());
  1535. +
  1536. +
  1537. + }
  1538. +
  1539. +
  1540. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1541. + }
  1542. +
  1543. + void AllGuilds3(Player* player, Creature* creature) {
  1544. + player->PlayerTalkClass->ClearMenus();
  1545. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 20);
  1546. + QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
  1547. + if (result) {
  1548. + std::string name;
  1549. + std::string gleader;
  1550. + uint32 guild;
  1551. + uint16 level;
  1552. + uint16 go = 0;
  1553. + uint64 leaderguid;
  1554. + do {
  1555. + if (go < 20) {
  1556. + go++;
  1557. + continue;
  1558. + }
  1559. + Field* fields = result->Fetch();
  1560. + guild = fields[0].GetUInt32();
  1561. + level = fields[1].GetUInt16();
  1562. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
  1563. + if (result3) {
  1564. + Field* fields = result3->Fetch();
  1565. + name = fields[0].GetString();
  1566. + leaderguid = fields[1].GetUInt64();
  1567. + }
  1568. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
  1569. + if (result4) {
  1570. + Field* fields = result4->Fetch();
  1571. + gleader = fields[0].GetString();
  1572. + }
  1573. + if (go == 30) {
  1574. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше =>", GOSSIP_SENDER_MAIN, 16);
  1575. + break;
  1576. + }
  1577. + std::stringstream buffer;
  1578. + buffer << "|cff084E13" << name << "|r" << ". Уровень: " << "|cFF1E90FF" << level << "|r" << ". ГМ: " << "|cff790C06" << gleader << "|r";
  1579. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild+2000);
  1580. + go++;
  1581. + } while (result->NextRow());
  1582. +
  1583. +
  1584. + }
  1585. +
  1586. +
  1587. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1588. + }
  1589. +
  1590. + void AllGuilds4(Player* player, Creature* creature) {
  1591. + player->PlayerTalkClass->ClearMenus();
  1592. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 21);
  1593. + QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
  1594. + if (result) {
  1595. + std::string name;
  1596. + std::string gleader;
  1597. + uint32 guild;
  1598. + uint16 level;
  1599. + uint16 go = 0;
  1600. + uint64 leaderguid;
  1601. + do {
  1602. + if (go < 30) {
  1603. + go++;
  1604. + continue;
  1605. + }
  1606. + Field* fields = result->Fetch();
  1607. + guild = fields[0].GetUInt32();
  1608. + level = fields[1].GetUInt16();
  1609. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
  1610. + if (result3) {
  1611. + Field* fields = result3->Fetch();
  1612. + name = fields[0].GetString();
  1613. + leaderguid = fields[1].GetUInt64();
  1614. + }
  1615. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
  1616. + if (result4) {
  1617. + Field* fields = result4->Fetch();
  1618. + gleader = fields[0].GetString();
  1619. + }
  1620. + if (go == 40) {
  1621. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше =>", GOSSIP_SENDER_MAIN, 17);
  1622. + break;
  1623. + }
  1624. + std::stringstream buffer;
  1625. + buffer << "|cff084E13" << name << "|r" << ". Уровень: " << "|cFF1E90FF" << level << "|r" << ". ГМ: " << "|cff790C06" << gleader << "|r";
  1626. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild+3000);
  1627. + go++;
  1628. + } while (result->NextRow());
  1629. +
  1630. +
  1631. + }
  1632. +
  1633. +
  1634. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1635. + }
  1636. +
  1637. + void AllGuilds5(Player* player, Creature* creature) {
  1638. + player->PlayerTalkClass->ClearMenus();
  1639. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 22);
  1640. + QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
  1641. + if (result) {
  1642. + std::string name;
  1643. + std::string gleader;
  1644. + uint32 guild;
  1645. + uint16 level;
  1646. + uint16 go = 0;
  1647. + uint64 leaderguid;
  1648. + do {
  1649. + if (go < 40) {
  1650. + go++;
  1651. + continue;
  1652. + }
  1653. + Field* fields = result->Fetch();
  1654. + guild = fields[0].GetUInt32();
  1655. + level = fields[1].GetUInt16();
  1656. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
  1657. + if (result3) {
  1658. + Field* fields = result3->Fetch();
  1659. + name = fields[0].GetString();
  1660. + leaderguid = fields[1].GetUInt64();
  1661. + }
  1662. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
  1663. + if (result4) {
  1664. + Field* fields = result4->Fetch();
  1665. + gleader = fields[0].GetString();
  1666. + }
  1667. + if (go == 50) {
  1668. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Конец", GOSSIP_SENDER_MAIN, 18);
  1669. + break;
  1670. + }
  1671. + std::stringstream buffer;
  1672. + buffer << "|cff084E13" << name << "|r" << ". Уровень: " << "|cFF1E90FF" << level << "|r" << ". ГМ: " << "|cff790C06" << gleader << "|r";
  1673. + player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild+4000);
  1674. + go++;
  1675. + } while (result->NextRow());
  1676. +
  1677. +
  1678. + }
  1679. +
  1680. +
  1681. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1682. + }
  1683. +
  1684. + void TakeHonorButtons(Player* player, Creature* creature) {
  1685. + if (!player->GetGuildId()) {
  1686. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  1687. + player->CLOSE_GOSSIP_MENU();
  1688. + return;
  1689. + }
  1690. +
  1691. + player->PlayerTalkClass->ClearMenus();
  1692. +
  1693. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 2 000 чести (+10 опыта)", GOSSIP_SENDER_MAIN, 5);
  1694. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 10 000 чести (+50 опыта)", GOSSIP_SENDER_MAIN, 6);
  1695. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 20 000 чести (+100 опыта)", GOSSIP_SENDER_MAIN, 7);
  1696. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 30 000 чести (+150 опыта)", GOSSIP_SENDER_MAIN, 8);
  1697. +
  1698. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1699. + }
  1700. +
  1701. + void TakeGold(Player* player, Creature* creature, char const* code)
  1702. + {
  1703. + int32 gold = atoi(code)*10000;
  1704. + if (!player->GetGuildId()) {
  1705. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  1706. + player->CLOSE_GOSSIP_MENU();
  1707. + return;
  1708. + }
  1709. + if (player->GetMoney() < 5000*10000) {
  1710. + player->GetSession()->SendNotification("У вас недостаточно золота!");
  1711. + player->CLOSE_GOSSIP_MENU();
  1712. + return;
  1713. + }
  1714. + uint32 guild = player->GetGuildId();
  1715. + uint32 axp = gold/50/10000;
  1716. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u",axp, guild);
  1717. + std::string name = player->GetName();
  1718. +
  1719. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  1720. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
  1721. +
  1722. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1723. + uint32 number;
  1724. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  1725. + if (result2) {
  1726. + Field* fields = result2->Fetch();
  1727. + number = fields[0].GetUInt32();
  1728. + if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number+1);
  1729. + }
  1730. +
  1731. + CharacterDatabase.PQuery("UPDATE guild_level_invested SET gold = gold+%u WHERE guild = %u AND name = '%s'",gold/10000, guild, name.c_str());
  1732. + player->ModifyMoney(-gold);
  1733. +
  1734. + UpdateLevel(player);
  1735. +
  1736. + player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
  1737. + player->CLOSE_GOSSIP_MENU();
  1738. +
  1739. + }
  1740. +
  1741. + void TakeArena10000(Player* player) {
  1742. + if (!player->GetGuildId()) {
  1743. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  1744. + player->CLOSE_GOSSIP_MENU();
  1745. + return;
  1746. + }
  1747. + if (player->GetArenaPoints() < 1500) {
  1748. + player->GetSession()->SendNotification("У вас недостаточно очков арены!");
  1749. + player->CLOSE_GOSSIP_MENU();
  1750. + return;
  1751. + }
  1752. + uint32 guild = player->GetGuildId();
  1753. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+150 WHERE guild = %u", guild);
  1754. + std::string name = player->GetName();
  1755. +
  1756. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  1757. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
  1758. +
  1759. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1760. + uint32 number;
  1761. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  1762. + if (result2) {
  1763. + Field* fields = result2->Fetch();
  1764. + number = fields[0].GetUInt32();
  1765. + if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number+1);
  1766. + }
  1767. +
  1768. + CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+1500 WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1769. + player->ModifyArenaPoints(-1500);
  1770. +
  1771. + UpdateLevel(player);
  1772. +
  1773. + player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
  1774. + player->CLOSE_GOSSIP_MENU();
  1775. + }
  1776. +
  1777. + void TakeArena7500(Player* player) {
  1778. + if (!player->GetGuildId()) {
  1779. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  1780. + player->CLOSE_GOSSIP_MENU();
  1781. + return;
  1782. + }
  1783. + if (player->GetArenaPoints() < 1000) {
  1784. + player->GetSession()->SendNotification("У вас недостаточно очков арены!");
  1785. + player->CLOSE_GOSSIP_MENU();
  1786. + return;
  1787. + }
  1788. + uint32 guild = player->GetGuildId();
  1789. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+100 WHERE guild = %u", guild);
  1790. + std::string name = player->GetName();
  1791. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  1792. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
  1793. +
  1794. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1795. + uint32 number;
  1796. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  1797. + if (result2) {
  1798. + Field* fields = result2->Fetch();
  1799. + number = fields[0].GetUInt32();
  1800. + if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number+1);
  1801. + }
  1802. + CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+1000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1803. + player->ModifyArenaPoints(-1000);
  1804. +
  1805. + UpdateLevel(player);
  1806. +
  1807. + player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
  1808. + player->CLOSE_GOSSIP_MENU();
  1809. + }
  1810. +
  1811. + void TakeArena5000(Player* player) {
  1812. + if (!player->GetGuildId()) {
  1813. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  1814. + player->CLOSE_GOSSIP_MENU();
  1815. + return;
  1816. + }
  1817. + if (player->GetArenaPoints() < 500) {
  1818. + player->GetSession()->SendNotification("У вас недостаточно очков арены!");
  1819. + player->CLOSE_GOSSIP_MENU();
  1820. + return;
  1821. + }
  1822. + uint32 guild = player->GetGuildId();
  1823. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+50 WHERE guild = %u", guild);
  1824. + std::string name = player->GetName();
  1825. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  1826. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
  1827. +
  1828. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1829. + uint32 number;
  1830. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  1831. + if (result2) {
  1832. + Field* fields = result2->Fetch();
  1833. + number = fields[0].GetUInt32();
  1834. + if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number+1);
  1835. + }
  1836. + CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+500 WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1837. + player->ModifyArenaPoints(-500);
  1838. +
  1839. + UpdateLevel(player);
  1840. +
  1841. + player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
  1842. + player->CLOSE_GOSSIP_MENU();
  1843. + }
  1844. +
  1845. + void TakeArena2500(Player* player) {
  1846. + if (!player->GetGuildId()) {
  1847. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  1848. + player->CLOSE_GOSSIP_MENU();
  1849. + return;
  1850. + }
  1851. + if (player->GetArenaPoints() < 100) {
  1852. + player->GetSession()->SendNotification("У вас недостаточно очков арены!");
  1853. + player->CLOSE_GOSSIP_MENU();
  1854. + return;
  1855. + }
  1856. + uint32 guild = player->GetGuildId();
  1857. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+10 WHERE guild = %u", guild);
  1858. + std::string name = player->GetName();
  1859. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  1860. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
  1861. +
  1862. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1863. + uint32 number;
  1864. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  1865. + if (result2) {
  1866. + Field* fields = result2->Fetch();
  1867. + number = fields[0].GetUInt32();
  1868. + if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number+1);
  1869. + }
  1870. + CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+100 WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1871. + player->ModifyArenaPoints(-100);
  1872. +
  1873. + UpdateLevel(player);
  1874. +
  1875. + player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
  1876. + player->CLOSE_GOSSIP_MENU();
  1877. + }
  1878. +
  1879. + void TakeHonor200(Player* player) {
  1880. + if (!player->GetGuildId()) {
  1881. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  1882. + player->CLOSE_GOSSIP_MENU();
  1883. + return;
  1884. + }
  1885. + if (player->GetHonorPoints() < 30000) {
  1886. + player->GetSession()->SendNotification("У вас недостаточно очков чести!");
  1887. + player->CLOSE_GOSSIP_MENU();
  1888. + return;
  1889. + }
  1890. + uint32 guild = player->GetGuildId();
  1891. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+150 WHERE guild = %u", guild);
  1892. + std::string name = player->GetName();
  1893. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  1894. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
  1895. +
  1896. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1897. + uint32 number;
  1898. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  1899. + if (result2) {
  1900. + Field* fields = result2->Fetch();
  1901. + number = fields[0].GetUInt32();
  1902. + if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number+1);
  1903. + }
  1904. + CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+30000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1905. + player->ModifyHonorPoints(-30000);
  1906. + UpdateLevel(player);
  1907. + player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
  1908. + player->CLOSE_GOSSIP_MENU();
  1909. + }
  1910. +
  1911. + void TakeHonor150(Player* player) {
  1912. + if (!player->GetGuildId()) {
  1913. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  1914. + player->CLOSE_GOSSIP_MENU();
  1915. + return;
  1916. + }
  1917. + if (player->GetHonorPoints() < 20000) {
  1918. + player->GetSession()->SendNotification("У вас недостаточно очков чести!");
  1919. + player->CLOSE_GOSSIP_MENU();
  1920. + return;
  1921. + }
  1922. + uint32 guild = player->GetGuildId();
  1923. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+100 WHERE guild = %u", guild);
  1924. + std::string name = player->GetName();
  1925. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  1926. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
  1927. +
  1928. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1929. + uint32 number;
  1930. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  1931. + if (result2) {
  1932. + Field* fields = result2->Fetch();
  1933. + number = fields[0].GetUInt32();
  1934. + if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number+1);
  1935. + }
  1936. + CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+20000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1937. + player->ModifyHonorPoints(-20000);
  1938. +
  1939. + UpdateLevel(player);
  1940. +
  1941. + player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
  1942. + player->CLOSE_GOSSIP_MENU();
  1943. + }
  1944. +
  1945. + void TakeHonor100(Player* player) {
  1946. + if (!player->GetGuildId()) {
  1947. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  1948. + player->CLOSE_GOSSIP_MENU();
  1949. + return;
  1950. + }
  1951. + if (player->GetHonorPoints() < 10000) {
  1952. + player->GetSession()->SendNotification("У вас недостаточно очков чести!");
  1953. + player->CLOSE_GOSSIP_MENU();
  1954. + return;
  1955. + }
  1956. + uint32 guild = player->GetGuildId();
  1957. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+50 WHERE guild = %u", guild);
  1958. + std::string name = player->GetName();
  1959. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  1960. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
  1961. +
  1962. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1963. + uint32 number;
  1964. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  1965. + if (result2) {
  1966. + Field* fields = result2->Fetch();
  1967. + number = fields[0].GetUInt32();
  1968. + if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number+1);
  1969. + }
  1970. + CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+10000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1971. + player->ModifyHonorPoints(-10000);
  1972. + UpdateLevel(player);
  1973. + player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
  1974. + player->CLOSE_GOSSIP_MENU();
  1975. + }
  1976. +
  1977. + void TakeFrostEmblem(Player* player)
  1978. + {
  1979. + if (!player->GetGuildId()) {
  1980. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  1981. + player->CLOSE_GOSSIP_MENU();
  1982. + return;
  1983. + }
  1984. +
  1985. + if (!player->HasItemCount(49426, 1, true)) {
  1986. + player->GetSession()->SendNotification("У вас недостаточно эмблем!");
  1987. + player->CLOSE_GOSSIP_MENU();
  1988. + return;
  1989. + }
  1990. + uint32 guild = player->GetGuildId();
  1991. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+10 WHERE guild = %u", guild);
  1992. +
  1993. + std::string name = player->GetName();
  1994. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  1995. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
  1996. +
  1997. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  1998. + uint32 number;
  1999. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  2000. + if (result2) {
  2001. + Field* fields = result2->Fetch();
  2002. + number = fields[0].GetUInt32();
  2003. + if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number+1);
  2004. + }
  2005. + CharacterDatabase.PQuery("UPDATE guild_level_invested SET token = token+1 WHERE guild = %u AND name = '%s'", guild, name.c_str());
  2006. + player->DestroyItemCount(49426, 1, true);
  2007. + UpdateLevel(player);
  2008. + player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
  2009. + player->CLOSE_GOSSIP_MENU();
  2010. + }
  2011. +
  2012. + void TakeTriumphEmblem(Player* player)
  2013. + {
  2014. + if (!player->GetGuildId()) {
  2015. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  2016. + player->CLOSE_GOSSIP_MENU();
  2017. + return;
  2018. + }
  2019. +
  2020. + if (!player->HasItemCount(18228, 50, true)) {
  2021. + player->GetSession()->SendNotification("У вас недостаточно свитков!");
  2022. + player->CLOSE_GOSSIP_MENU();
  2023. + return;
  2024. + }
  2025. + uint32 guild = player->GetGuildId();
  2026. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+10 WHERE guild = %u", guild);
  2027. +
  2028. + std::string name = player->GetName();
  2029. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  2030. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
  2031. +
  2032. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  2033. + uint32 number;
  2034. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  2035. + if (result2) {
  2036. + Field* fields = result2->Fetch();
  2037. + number = fields[0].GetUInt32();
  2038. + if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number+1);
  2039. + }
  2040. + CharacterDatabase.PQuery("UPDATE guild_level_invested SET svitok = svitok+50 WHERE guild = %u AND name = '%s'", guild, name.c_str());
  2041. + player->DestroyItemCount(18228, 50, true);
  2042. + UpdateLevel(player);
  2043. + player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
  2044. + player->CLOSE_GOSSIP_MENU();
  2045. + }
  2046. +
  2047. + void TakeHonor50(Player* player) {
  2048. + if (!player->GetGuildId()) {
  2049. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  2050. + player->CLOSE_GOSSIP_MENU();
  2051. + return;
  2052. + }
  2053. + if (player->GetHonorPoints() < 2000) {
  2054. + player->GetSession()->SendNotification("У вас недостаточно очков чести!");
  2055. + player->CLOSE_GOSSIP_MENU();
  2056. + return;
  2057. + }
  2058. + uint32 guild = player->GetGuildId();
  2059. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+10 WHERE guild = %u", guild);
  2060. +
  2061. + std::string name = player->GetName();
  2062. + QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
  2063. + if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
  2064. +
  2065. + QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
  2066. + uint32 number;
  2067. + QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
  2068. + if (result2) {
  2069. + Field* fields = result2->Fetch();
  2070. + number = fields[0].GetUInt32();
  2071. + if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number+1);
  2072. + }
  2073. + CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+2000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
  2074. + player->ModifyHonorPoints(-2000);
  2075. + UpdateLevel(player);
  2076. + player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
  2077. + player->CLOSE_GOSSIP_MENU();
  2078. + }
  2079. +
  2080. +
  2081. +
  2082. + void TakeArenaButtons(Player* player, Creature* creature) {
  2083. + if (!player->GetGuildId()) {
  2084. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  2085. + player->CLOSE_GOSSIP_MENU();
  2086. + return;
  2087. + }
  2088. +
  2089. + player->PlayerTalkClass->ClearMenus();
  2090. +
  2091. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 100 арены (+10 опыта)", GOSSIP_SENDER_MAIN, 9);
  2092. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 500 арены (+50 опыта)", GOSSIP_SENDER_MAIN, 10);
  2093. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 1000 арены (+100 опыта)", GOSSIP_SENDER_MAIN, 11);
  2094. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 1500 арены (+150 опыта)", GOSSIP_SENDER_MAIN, 12);
  2095. +
  2096. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  2097. + }
  2098. +
  2099. + void GuildInfo(Player* player) {
  2100. + if (!player->GetGuildId()) {
  2101. + player->GetSession()->SendNotification("Вы не состоите в гильдии!");
  2102. + player->CLOSE_GOSSIP_MENU();
  2103. + return;
  2104. + }
  2105. + uint32 guild = player->GetGuildId();
  2106. + QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  2107. + if (result) {
  2108. + Field *fields = result->Fetch();
  2109. + uint16 level = fields[0].GetUInt16();
  2110. + uint32 xp = fields[1].GetUInt32();
  2111. +
  2112. + ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eУровень вашей гильдии:|r |cfffcedbb%u|r", level);
  2113. + ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eПрогресс уровня вашей гильдии:|r |cfffcedbb%u|r", xp);
  2114. +
  2115. + QueryResult result1 = CharacterDatabase.PQuery("SELECT xp FROM guild_xp_table WHERE level = %u", level);
  2116. + if (result1) {
  2117. + Field *fields = result1->Fetch();
  2118. + uint32 reqXp = fields[0].GetUInt32();
  2119. + uint32 ReqXp = reqXp-xp;
  2120. + if (level < 30) ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eДо %u-го уровня гильдии осталось накопить:|r |cfffcedbb%u опыта|r", level+1, ReqXp);
  2121. + else ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eВаша гильдия имеет максимальный уровень!|r");
  2122. +
  2123. + }
  2124. +
  2125. + }
  2126. + player->CLOSE_GOSSIP_MENU();
  2127. + }
  2128. +
  2129. + bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) {
  2130. + switch (action) {
  2131. + case 1:
  2132. + TakeHonorButtons(player, creature);
  2133. + break;
  2134. + case 2:
  2135. + TakeArenaButtons(player, creature);
  2136. + break;
  2137. + case 3:
  2138. + GuildInfo(player);
  2139. + break;
  2140. + case 4:
  2141. + player->CLOSE_GOSSIP_MENU();
  2142. + break;
  2143. + case 5:
  2144. + TakeHonor50(player);
  2145. + break;
  2146. + case 6:
  2147. + TakeHonor100(player);
  2148. + break;
  2149. + case 7:
  2150. + TakeHonor150(player);
  2151. + break;
  2152. + case 8:
  2153. + TakeHonor200(player);
  2154. + break;
  2155. + case 9:
  2156. + TakeArena2500(player);
  2157. + break;
  2158. + case 10:
  2159. + TakeArena5000(player);
  2160. + break;
  2161. + case 11:
  2162. + TakeArena7500(player);
  2163. + break;
  2164. + case 12:
  2165. + TakeArena10000(player);
  2166. + break;
  2167. + case 13:
  2168. + AllGuilds1(player, creature);
  2169. + break;
  2170. + case 14:
  2171. + AllGuilds2(player, creature);
  2172. + break;
  2173. + case 15:
  2174. + AllGuilds3(player, creature);
  2175. + break;
  2176. + case 16:
  2177. + AllGuilds4(player, creature);
  2178. + break;
  2179. + case 17:
  2180. + AllGuilds5(player, creature);
  2181. + break;
  2182. + case 18:
  2183. + player->CLOSE_GOSSIP_MENU();
  2184. + break;
  2185. + case 19:
  2186. + AllGuilds1(player, creature);
  2187. + break;
  2188. + case 20:
  2189. + AllGuilds2(player, creature);
  2190. + break;
  2191. + case 21:
  2192. + AllGuilds3(player, creature);
  2193. + break;
  2194. + case 22:
  2195. + AllGuilds4(player, creature);
  2196. + break;
  2197. + case 23:
  2198. + CurrentSpellsMenu(player, creature);
  2199. + break;
  2200. + case 24:
  2201. + ReplaceColorList(player, creature);
  2202. + break;
  2203. + case 25:
  2204. + ReplaceColor(player, creature, 1);
  2205. + break;
  2206. + case 26:
  2207. + ReplaceColor(player, creature, 2);
  2208. + break;
  2209. + case 27:
  2210. + ReplaceColor(player, creature, 3);
  2211. + break;
  2212. + case 28:
  2213. + ReplaceColor(player, creature, 4);
  2214. + break;
  2215. + case 29:
  2216. + ReplaceColor(player, creature, 5);
  2217. + break;
  2218. + case 30:
  2219. + ReplaceColor(player, creature, 6);
  2220. + break;
  2221. + case 35:
  2222. + TakeTriumphEmblem(player);
  2223. + break;
  2224. + case 36:
  2225. + TakeFrostEmblem(player);
  2226. + break;
  2227. + /*case 9998:
  2228. + BuySpell5(player, creature);
  2229. + break;
  2230. + case 9900:
  2231. + BuySpell10(player, creature);
  2232. + break;
  2233. + case 9901:
  2234. + BuySpell15(player, creature);
  2235. + break;
  2236. + case 9902:
  2237. + BuySpell20(player, creature);
  2238. + break;
  2239. + case 9903:
  2240. + BuySpell25(player, creature);
  2241. + break;
  2242. + case 9904:
  2243. + BuySpell30(player, creature);
  2244. + break;
  2245. + case 9905:
  2246. + CurrentSpellsMenu(player, creature);
  2247. + break;*/
  2248. + case 9000:
  2249. + InvestedRosterGold1(player, creature);
  2250. + break;
  2251. + case 9910:
  2252. + InvestedRosterHonor2(player, creature);
  2253. + break;
  2254. + case 9911:
  2255. + InvestedRosterHonor1(player, creature);
  2256. + break;
  2257. + case 9912:
  2258. + InvestedRosterArena2(player, creature);
  2259. + break;
  2260. + case 9913:
  2261. + InvestedRosterArena1(player, creature);
  2262. + break;
  2263. + case 9914:
  2264. + InvestedRoster(player, creature);
  2265. + break;
  2266. + case 9917:
  2267. + InvestedSvitok(player, creature);
  2268. + break;
  2269. + case 9918:
  2270. + InvestedToken(player, creature);
  2271. + break;
  2272. + case 9915:
  2273. + InvestedRosterHonor1(player, creature);
  2274. + break;
  2275. + case 9916:
  2276. + InvestedRosterArena1(player, creature);
  2277. + break;
  2278. +
  2279. + }
  2280. +
  2281. + if (action > 100 && action < 1000) AllGuilds1(player, creature);
  2282. + if (action > 1000 && action < 2000) AllGuilds2(player, creature);
  2283. + if (action > 2000 && action < 3000) AllGuilds3(player, creature);
  2284. + if (action > 3000 && action < 4000) AllGuilds4(player, creature);
  2285. + if (action > 4000 && action < 5000) AllGuilds5(player, creature);
  2286. + if (action >= 10000) InvestedRoster(player, creature);
  2287. +
  2288. + /*SelectSpell5(player, creature, action);
  2289. + SelectSpell10(player, creature, action);
  2290. + SelectSpell15(player, creature, action);
  2291. + SelectSpell20(player, creature, action);
  2292. + SelectSpell25(player, creature, action);
  2293. + SelectSpell30(player, creature, action);*/
  2294. +
  2295. + return true;
  2296. + }
  2297. + bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code)
  2298. + {
  2299. + switch(action)
  2300. + {
  2301. + case 200:
  2302. + TakeGold(player, creature, code);
  2303. + break;
  2304. + }
  2305. + return true;
  2306. + }
  2307. +
  2308. +};
  2309. +
  2310. +class npc_guildhouse : public CreatureScript
  2311. +
  2312. +{
  2313. +
  2314. + public:
  2315. +
  2316. + npc_guildhouse() : CreatureScript("npc_guildhouse") {}
  2317. +
  2318. + bool OnGossipHello(Player* player, Creature* creature) {
  2319. + player->PlayerTalkClass->ClearMenus();
  2320. + uint16 count;
  2321. + if (uint32 guild = player->GetGuildId())
  2322. + {
  2323. + if (player->GetRankFromDB(player->GetGUID()) == 0)
  2324. + {
  2325. + QueryResult result = CharacterDatabase.PQuery("SELECT COUNT(guild) FROM guildhouses WHERE guild = 0");
  2326. + if (result)
  2327. + {
  2328. + QueryResult result2 = CharacterDatabase.PQuery("SELECT guild FROM guildhouses WHERE guild = %u", guild);
  2329. + if (!result2)
  2330. + {
  2331. + Field* fields = result->Fetch();
  2332. + count = fields[0].GetUInt16();
  2333. + if (count > 0)
  2334. + {
  2335. + std::ostringstream psm;
  2336. + psm << "|TInterface/ICONS/Spell_Arcane_TeleportTheramore:32:32:-18:0|tПосмотреть место для Дома Гильдии";
  2337. + std::ostringstream kpt;
  2338. + kpt << "|TInterface/ICONS/Spell_Arcane_TeleportSilvermoon:32:32:-18:0|tКупить место для Дома Гильдии";
  2339. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, psm.str(), GOSSIP_SENDER_MAIN, 1);
  2340. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, kpt.str(), GOSSIP_SENDER_MAIN, 2);
  2341. + }
  2342. + }
  2343. + }
  2344. + else
  2345. + {
  2346. + player->GetSession()->SendNotification("Свободных мест нет!");
  2347. + player->CLOSE_GOSSIP_MENU();
  2348. + return false;
  2349. + }
  2350. + }
  2351. + std::ostringstream tpd;
  2352. + tpd << "|TInterface/ICONS/Spell_Arcane_TeleportThunderBluff:32:32:-18:0|tТелепорт в Дом своей гильдии";
  2353. + QueryResult result5 = CharacterDatabase.PQuery("SELECT guild FROM guildhouses WHERE guild = %u", guild);
  2354. + if (result5) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, tpd.str(), GOSSIP_SENDER_MAIN, 3);
  2355. +
  2356. + std::ostringstream vxd;
  2357. + vxd << "|TInterface/ICONS/Spell_ChargeNegative:32:32:-18:0|tВыход";
  2358. +
  2359. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, vxd.str(), GOSSIP_SENDER_MAIN, 4);
  2360. + }
  2361. + else
  2362. + {
  2363. + player->SEND_GOSSIP_MENU(55004, creature->GetGUID());
  2364. + return false;
  2365. + }
  2366. + player->SEND_GOSSIP_MENU(55001, creature->GetGUID());
  2367. +
  2368. + return true;
  2369. + }
  2370. +
  2371. + void LookGuildHouses(Player* player, Creature* creature)
  2372. + {
  2373. + player->PlayerTalkClass->ClearMenus();
  2374. + player->ADD_GOSSIP_ITEM(4, "Список доступных ГХ:", GOSSIP_SENDER_MAIN, 200);
  2375. + QueryResult result = CharacterDatabase.PQuery("SELECT name, x, y, z, radius, cost, number, number2 FROM guildhouses WHERE guild = 0 ORDER BY cost");
  2376. + if (result)
  2377. + {
  2378. + float x,y,z,radius;
  2379. + uint32 cost, number, number_2;
  2380. + const char* name;
  2381. + uint16 go = 0;
  2382. + do
  2383. + {
  2384. + Field* fields = result->Fetch();
  2385. + name = fields[0].GetCString();
  2386. + x = fields[1].GetFloat();
  2387. + y = fields[2].GetFloat();
  2388. + z = fields[3].GetFloat();
  2389. + radius = fields[4].GetFloat();
  2390. + cost = fields[5].GetUInt32();
  2391. + number = fields[6].GetUInt32();
  2392. + number_2 = fields[7].GetUInt32();
  2393. +
  2394. + if (go == 30)
  2395. + {
  2396. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 101);
  2397. + break;
  2398. + }
  2399. +
  2400. + std::stringstream buffer;
  2401. + buffer << "Посмотреть ГХ: " << "|cff177245" << name << "|r" << ". Цена: " << "|cffE024B4" << cost << " опыта" << "|r";
  2402. + if (i == 1) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  2403. + if (i == 2) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number_2);
  2404. +
  2405. + go++;
  2406. + }
  2407. + while (result->NextRow());
  2408. + }
  2409. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  2410. + }
  2411. +
  2412. + void LookGuildHouses2(Player* player, Creature* creature)
  2413. + {
  2414. + player->PlayerTalkClass->ClearMenus();
  2415. + player->ADD_GOSSIP_ITEM(4, "Список доступных ГХ:", GOSSIP_SENDER_MAIN, 201);
  2416. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 100);
  2417. + QueryResult result = CharacterDatabase.PQuery("SELECT name, x, y, z, radius, cost, number, number2 FROM guildhouses WHERE guild = 0 ORDER BY cost");
  2418. + if (result)
  2419. + {
  2420. + float x,y,z,radius;
  2421. + uint32 cost, number, number_2;
  2422. + const char* name;
  2423. + uint16 go = 0;
  2424. + do
  2425. + {
  2426. + if (go < 30)
  2427. + {
  2428. + go++;
  2429. + continue;
  2430. + }
  2431. + Field* fields = result->Fetch();
  2432. + name = fields[0].GetCString();
  2433. + x = fields[1].GetFloat();
  2434. + y = fields[2].GetFloat();
  2435. + z = fields[3].GetFloat();
  2436. + radius = fields[4].GetFloat();
  2437. + cost = fields[5].GetUInt32();
  2438. + number = fields[6].GetUInt32();
  2439. + number_2 = fields[7].GetUInt32();
  2440. +
  2441. + if (go == 60) break;
  2442. +
  2443. + std::stringstream buffer;
  2444. + buffer << "Посмотреть ГХ: " << "|cff177245" << name << "|r" << ". Цена: " << "|cffE024B4" << cost << " опыта" << "|r";
  2445. + if (i == 1) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  2446. + if (i == 2) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number_2);
  2447. +
  2448. + go++;
  2449. + }
  2450. + while (result->NextRow());
  2451. + }
  2452. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  2453. + }
  2454. +
  2455. + uint8 i;
  2456. +
  2457. + bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
  2458. + {
  2459. + switch (action)
  2460. + {
  2461. + case 1:
  2462. + i = 1;
  2463. + LookGuildHouses(player, creature);
  2464. + break;
  2465. + case 2:
  2466. + i = 2;
  2467. + LookGuildHouses(player, creature);
  2468. + break;
  2469. + case 3:
  2470. + TeleportToGH(player);
  2471. + break;
  2472. + case 100:
  2473. + LookGuildHouses(player, creature);
  2474. + break;
  2475. + case 101:
  2476. + LookGuildHouses2(player, creature);
  2477. + break;
  2478. + case 4:
  2479. + player->CLOSE_GOSSIP_MENU();
  2480. + break;
  2481. + case 200:
  2482. + LookGuildHouses(player, creature);
  2483. + break;
  2484. + case 201:
  2485. + LookGuildHouses2(player, creature);
  2486. + break;
  2487. + }
  2488. + if (i == 1) TeleportToLook(player, action);
  2489. + if (i == 2) BuyGuildHouse(player, action);
  2490. + return true;
  2491. + }
  2492. +
  2493. + void BuyGuildHouse(Player* player, uint32 action)
  2494. + {
  2495. + QueryResult result = CharacterDatabase.PQuery("SELECT number2, cost FROM guildhouses WHERE guild = 0 ORDER BY cost");
  2496. + if (result)
  2497. + {
  2498. + uint16 level, level_table;
  2499. + uint32 number_2, cost, xp, xp_table;
  2500. + uint32 guild = player->GetGuildId();
  2501. + do
  2502. + {
  2503. + Field* fields = result->Fetch();
  2504. + number_2 = fields[0].GetUInt32();
  2505. + cost = fields[1].GetUInt32();
  2506. +
  2507. + if (action == number_2)
  2508. + {
  2509. +
  2510. + QueryResult result2 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  2511. + if (result2)
  2512. + {
  2513. + Field *fields = result2->Fetch();
  2514. + level = fields[0].GetUInt16();
  2515. + xp = fields[1].GetUInt32();
  2516. + if (xp >= cost)
  2517. + {
  2518. + CharacterDatabase.PQuery("UPDATE guildhouses SET guild = %u WHERE number2 = %u", guild, number_2);
  2519. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp - %u WHERE guild = %u", cost, guild);
  2520. + if (!player->HasSpell(69541)) player->learnSpell(69541,false);
  2521. + UpdateLevel(player);
  2522. + player->GetSession()->SendAreaTriggerMessage("Место для дома гильдии куплено!");
  2523. + ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eВы купили место для дома гильдии. |r");
  2524. + ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eЧтобы начать его обустраивать вызовите пандарена-монаха из списка небоевых спутников.|r");
  2525. + player->CLOSE_GOSSIP_MENU();
  2526. + break;
  2527. + }
  2528. + else
  2529. + {
  2530. + player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
  2531. + player->CLOSE_GOSSIP_MENU();
  2532. + break;
  2533. + }
  2534. + }
  2535. + }
  2536. + }
  2537. + while (result->NextRow());
  2538. + }
  2539. + }
  2540. +
  2541. +
  2542. +
  2543. + void TeleportToGH(Player* player)
  2544. + {
  2545. + uint32 guild = player->GetGuildId();
  2546. + QueryResult result = CharacterDatabase.PQuery("SELECT x, y, z, map FROM guildhouses WHERE guild = %u", guild);
  2547. + if (result)
  2548. + {
  2549. + float x,y,z;
  2550. + uint32 map;
  2551. + std::string name;
  2552. +
  2553. + Field* fields = result->Fetch();
  2554. + x = fields[0].GetFloat();
  2555. + y = fields[1].GetFloat();
  2556. + z = fields[2].GetFloat();
  2557. + map = fields[3].GetUInt32();
  2558. +
  2559. + player->TeleportTo(map,x,y,z,0.0f,0U);
  2560. + player->RemoveSpellCooldown(8690, true);
  2561. + player->SetPhaseMask(1, true);
  2562. + }
  2563. + }
  2564. +
  2565. + void TeleportToLook(Player* player, uint32 action)
  2566. + {
  2567. + QueryResult result = CharacterDatabase.PQuery("SELECT x, y, z, map, number, number2 FROM guildhouses WHERE guild = 0 ORDER BY cost");
  2568. + if (result)
  2569. + {
  2570. + float x,y,z;
  2571. + uint32 number, map;
  2572. + std::string name;
  2573. + do
  2574. + {
  2575. + Field* fields = result->Fetch();
  2576. + x = fields[0].GetFloat();
  2577. + y = fields[1].GetFloat();
  2578. + z = fields[2].GetFloat();
  2579. + map = fields[3].GetUInt32();
  2580. + number = fields[4].GetUInt32();
  2581. +
  2582. + if (action == number)
  2583. + {
  2584. + player->SaveRecallPosition();
  2585. + player->TeleportTo(map,x,y,z,0.0f,0U);
  2586. + player->RemoveArenaSpellCooldowns();
  2587. + player->RemoveSpellCooldown(8690, true);
  2588. + player->SetPhaseMask(1, true);
  2589. + if (!player->HasSpell(69541)) player->learnSpell(69541,false);
  2590. + ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eВы решили посмотреть место для дома гильдии.|r");
  2591. + ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eЧтобы телепортироваться обратно вызовите пандарена-монаха из списка небоевых спутников|r");
  2592. + break;
  2593. + }
  2594. +
  2595. + }
  2596. + while (result->NextRow());
  2597. + }
  2598. + }
  2599. +
  2600. +};
  2601. +
  2602. +class npc_guildhouse_builder : public CreatureScript
  2603. +
  2604. +{
  2605. +
  2606. + public:
  2607. +
  2608. + npc_guildhouse_builder() : CreatureScript("npc_guildhouse_builder") {}
  2609. +
  2610. +
  2611. + bool OnGossipHello(Player* player, Creature* creature) {
  2612. + player->PlayerTalkClass->ClearMenus();
  2613. + if (uint32 guild = player->GetGuildId()) {
  2614. + if (player->GetRankFromDB(player->GetGUID()) == 0) {
  2615. + QueryResult haveGuildHouse = CharacterDatabase.PQuery("SELECT * FROM guildhouses WHERE guild = %u", guild);
  2616. + if (haveGuildHouse)
  2617. + {
  2618. + QueryResult result5 = CharacterDatabase.PQuery("SELECT guild FROM guildhouses WHERE guild = %u", guild);
  2619. + std::ostringstream pnp;
  2620. + pnp << "|TInterface/ICONS/Spell_Holy_Rapture:32:32:-18:0|tПоставить НПС";
  2621. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, pnp.str(), GOSSIP_SENDER_MAIN, 8);
  2622. + std::ostringstream pob;
  2623. + pob << "|TInterface/ICONS/Spell_Nature_NullWard:32:32:-18:0|tПоставить объект";
  2624. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, pob.str(), GOSSIP_SENDER_MAIN, 1);
  2625. + std::ostringstream dnpc;
  2626. + dnpc << "|TInterface/ICONS/Spell_Shadow_DeathScream:32:32:-18:0|tУдалить поставленного НПС";
  2627. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, dnpc.str(), GOSSIP_SENDER_MAIN, 9);
  2628. + std::ostringstream danpc;
  2629. + danpc << "|TInterface/ICONS/Spell_Shadow_DeadofNight:32:32:-18:0|tУдалить всех НПС в Доме Гильдии";
  2630. + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_BATTLE, danpc.str(), GOSSIP_SENDER_MAIN, 11, "Вы действительно хотите удалить всех НПС? Введите 123 для удаления!", 0, true);
  2631. + std::ostringstream dobj;
  2632. + dobj << "|TInterface/ICONS/Spell_Shadow_FingerOfDeath:32:32:-18:0|tУдалить ближайший объект";
  2633. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE,dobj.str() , GOSSIP_SENDER_MAIN, 2);
  2634. + std::ostringstream daobj;
  2635. + daobj << "|TInterface/ICONS/Spell_Shadow_GrimWard:32:32:-18:0|tУдалить все объекты в Доме Гильдии";
  2636. + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_BATTLE, daobj.str(), GOSSIP_SENDER_MAIN, 3, "Вы действительно хотите удалить все объекты? Введите 123 для удаления!", 0, true);
  2637. + std::ostringstream prad;
  2638. + prad << "|TInterface/ICONS/Spell_ChargePositive:32:32:-18:0|tРасширить радиус ГХ на 10 ярдов(500 опыта)";
  2639. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, prad.str(), GOSSIP_SENDER_MAIN, 5);
  2640. + std::ostringstream zst;
  2641. + zst << "|TInterface/ICONS/Spell_Fire_FelHellfire:32:32:-18:0|tЗАСТРЯЛ!";
  2642. + if (result5) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, zst.str(), GOSSIP_SENDER_MAIN, 7);
  2643. + }
  2644. + else player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Телепортироваться обратно", GOSSIP_SENDER_MAIN, 15);
  2645. + }
  2646. + }
  2647. + else
  2648. + {
  2649. + player->SEND_GOSSIP_MENU(55004, creature->GetGUID());
  2650. + return false;
  2651. + }
  2652. + std::ostringstream vxd;
  2653. + vxd << "|TInterface/ICONS/Spell_ChargeNegative:32:32:-18:0|tВыход";
  2654. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, vxd.str(), GOSSIP_SENDER_MAIN, 4);
  2655. + player->SEND_GOSSIP_MENU(55002, creature->GetGUID());
  2656. +
  2657. + return true;
  2658. + }
  2659. +
  2660. + void AddGobject1(Player* player, Creature* creature)
  2661. + {
  2662. + player->PlayerTalkClass->ClearMenus();
  2663. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
  2664. + if (result)
  2665. + {
  2666. + const char* name;
  2667. + uint32 cost, number;
  2668. + uint16 go = 0;
  2669. + do
  2670. + {
  2671. + Field* fields = result->Fetch();
  2672. + name = fields[0].GetCString();
  2673. + cost = fields[1].GetUInt32();
  2674. + number = fields[2].GetUInt32();
  2675. + if (go == 30)
  2676. + {
  2677. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 101);
  2678. + break;
  2679. + }
  2680. +
  2681. + std::stringstream buffer;
  2682. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  2683. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  2684. + go++;
  2685. + }
  2686. + while (result->NextRow());
  2687. + }
  2688. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  2689. + }
  2690. +
  2691. + void AddGobject2(Player* player, Creature* creature)
  2692. + {
  2693. + player->PlayerTalkClass->ClearMenus();
  2694. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 100);
  2695. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
  2696. + if (result)
  2697. + {
  2698. + const char* name;
  2699. + uint32 cost, number;
  2700. + uint16 go = 0;
  2701. + do
  2702. + {
  2703. + if (go < 30)
  2704. + {
  2705. + go++;
  2706. + continue;
  2707. + }
  2708. + Field* fields = result->Fetch();
  2709. + name = fields[0].GetCString();
  2710. + cost = fields[1].GetUInt32();
  2711. + number = fields[2].GetUInt32();
  2712. +
  2713. + if (go == 60)
  2714. + {
  2715. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 102);
  2716. + break;
  2717. + }
  2718. +
  2719. + std::stringstream buffer;
  2720. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  2721. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  2722. + go++;
  2723. + }
  2724. + while (result->NextRow());
  2725. + }
  2726. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  2727. +
  2728. + }
  2729. +
  2730. + void AddGobject3(Player* player, Creature* creature)
  2731. + {
  2732. + player->PlayerTalkClass->ClearMenus();
  2733. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 101);
  2734. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
  2735. + if (result)
  2736. + {
  2737. + const char* name;
  2738. + uint32 cost, number;
  2739. + uint16 go = 0;
  2740. + do
  2741. + {
  2742. + if (go < 60)
  2743. + {
  2744. + go++;
  2745. + continue;
  2746. + }
  2747. + Field* fields = result->Fetch();
  2748. + name = fields[0].GetCString();
  2749. + cost = fields[1].GetUInt32();
  2750. + number = fields[2].GetUInt32();
  2751. +
  2752. + if (go == 90)
  2753. + {
  2754. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 103);
  2755. + break;
  2756. + }
  2757. +
  2758. + std::stringstream buffer;
  2759. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  2760. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  2761. + go++;
  2762. + }
  2763. + while (result->NextRow());
  2764. + }
  2765. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  2766. +
  2767. + }
  2768. +
  2769. + void AddGobject4(Player* player, Creature* creature)
  2770. + {
  2771. + player->PlayerTalkClass->ClearMenus();
  2772. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 102);
  2773. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
  2774. +
  2775. + if (result)
  2776. + {
  2777. + const char* name;
  2778. + uint32 cost, number;
  2779. + uint16 go = 0;
  2780. + do
  2781. + {
  2782. + if (go < 90)
  2783. + {
  2784. + go++;
  2785. + continue;
  2786. + }
  2787. + Field* fields = result->Fetch();
  2788. + name = fields[0].GetCString();
  2789. + cost = fields[1].GetUInt32();
  2790. + number = fields[2].GetUInt32();
  2791. +
  2792. + if (go == 120)
  2793. + {
  2794. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 104);
  2795. + break;
  2796. + }
  2797. +
  2798. + std::stringstream buffer;
  2799. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  2800. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  2801. + go++;
  2802. + }
  2803. + while (result->NextRow());
  2804. + }
  2805. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  2806. +
  2807. + }
  2808. +
  2809. + void AddGobject5(Player* player, Creature* creature)
  2810. + {
  2811. + player->PlayerTalkClass->ClearMenus();
  2812. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 103);
  2813. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
  2814. +
  2815. + if (result)
  2816. + {
  2817. + const char* name;
  2818. + uint32 cost, number;
  2819. + uint16 go = 0;
  2820. + do
  2821. + {
  2822. + if (go < 120)
  2823. + {
  2824. + go++;
  2825. + continue;
  2826. + }
  2827. + Field* fields = result->Fetch();
  2828. + name = fields[0].GetCString();
  2829. + cost = fields[1].GetUInt32();
  2830. + number = fields[2].GetUInt32();
  2831. +
  2832. + if (go == 150)
  2833. + {
  2834. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 105);
  2835. + break;
  2836. + }
  2837. +
  2838. + std::stringstream buffer;
  2839. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  2840. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  2841. + go++;
  2842. + }
  2843. + while (result->NextRow());
  2844. + }
  2845. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  2846. +
  2847. + }
  2848. +
  2849. + void AddGobject6(Player* player, Creature* creature)
  2850. + {
  2851. + player->PlayerTalkClass->ClearMenus();
  2852. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 104);
  2853. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
  2854. +
  2855. + if (result)
  2856. + {
  2857. + const char* name;
  2858. + uint32 cost, number;
  2859. + uint16 go = 0;
  2860. + do
  2861. + {
  2862. + if (go < 150)
  2863. + {
  2864. + go++;
  2865. + continue;
  2866. + }
  2867. + Field* fields = result->Fetch();
  2868. + name = fields[0].GetCString();
  2869. + cost = fields[1].GetUInt32();
  2870. + number = fields[2].GetUInt32();
  2871. +
  2872. + if (go == 180)
  2873. + {
  2874. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 106);
  2875. + break;
  2876. + }
  2877. +
  2878. + std::stringstream buffer;
  2879. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  2880. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  2881. + go++;
  2882. + }
  2883. + while (result->NextRow());
  2884. + }
  2885. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  2886. +
  2887. + }
  2888. +
  2889. + void AddGobject7(Player* player, Creature* creature)
  2890. + {
  2891. + player->PlayerTalkClass->ClearMenus();
  2892. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 105);
  2893. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
  2894. +
  2895. + if (result)
  2896. + {
  2897. + const char* name;
  2898. + uint32 cost, number;
  2899. + uint16 go = 0;
  2900. + do
  2901. + {
  2902. + if (go < 180)
  2903. + {
  2904. + go++;
  2905. + continue;
  2906. + }
  2907. + Field* fields = result->Fetch();
  2908. + name = fields[0].GetCString();
  2909. + cost = fields[1].GetUInt32();
  2910. + number = fields[2].GetUInt32();
  2911. +
  2912. + if (go == 210)
  2913. + {
  2914. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 107);
  2915. + break;
  2916. + }
  2917. +
  2918. + std::stringstream buffer;
  2919. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  2920. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  2921. + go++;
  2922. + }
  2923. + while (result->NextRow());
  2924. + }
  2925. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  2926. +
  2927. + }
  2928. +
  2929. + void AddGobject8(Player* player, Creature* creature)
  2930. + {
  2931. + player->PlayerTalkClass->ClearMenus();
  2932. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 106);
  2933. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
  2934. +
  2935. + if (result)
  2936. + {
  2937. + const char* name;
  2938. + uint32 cost, number;
  2939. + uint16 go = 0;
  2940. + do
  2941. + {
  2942. + if (go < 210)
  2943. + {
  2944. + go++;
  2945. + continue;
  2946. + }
  2947. + Field* fields = result->Fetch();
  2948. + name = fields[0].GetCString();
  2949. + cost = fields[1].GetUInt32();
  2950. + number = fields[2].GetUInt32();
  2951. +
  2952. + if (go == 240)
  2953. + {
  2954. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 108);
  2955. + break;
  2956. + }
  2957. +
  2958. + std::stringstream buffer;
  2959. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  2960. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  2961. + go++;
  2962. + }
  2963. + while (result->NextRow());
  2964. + }
  2965. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  2966. +
  2967. + }
  2968. +
  2969. + void AddGobject9(Player* player, Creature* creature)
  2970. + {
  2971. + player->PlayerTalkClass->ClearMenus();
  2972. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 107);
  2973. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
  2974. +
  2975. + if (result)
  2976. + {
  2977. + const char* name;
  2978. + uint32 cost, number;
  2979. + uint16 go = 0;
  2980. + do
  2981. + {
  2982. + if (go < 240)
  2983. + {
  2984. + go++;
  2985. + continue;
  2986. + }
  2987. + Field* fields = result->Fetch();
  2988. + name = fields[0].GetCString();
  2989. + cost = fields[1].GetUInt32();
  2990. + number = fields[2].GetUInt32();
  2991. +
  2992. + if (go == 270)
  2993. + {
  2994. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 109);
  2995. + break;
  2996. + }
  2997. +
  2998. + std::stringstream buffer;
  2999. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3000. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3001. + go++;
  3002. + }
  3003. + while (result->NextRow());
  3004. + }
  3005. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3006. +
  3007. + }
  3008. +
  3009. + void AddGobject10(Player* player, Creature* creature)
  3010. + {
  3011. + player->PlayerTalkClass->ClearMenus();
  3012. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 108);
  3013. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
  3014. +
  3015. + if (result)
  3016. + {
  3017. + const char* name;
  3018. + uint32 cost, number;
  3019. + uint16 go = 0;
  3020. + do
  3021. + {
  3022. + if (go < 270)
  3023. + {
  3024. + go++;
  3025. + continue;
  3026. + }
  3027. + Field* fields = result->Fetch();
  3028. + name = fields[0].GetCString();
  3029. + cost = fields[1].GetUInt32();
  3030. + number = fields[2].GetUInt32();
  3031. +
  3032. + if (go == 300) break;
  3033. +
  3034. + std::stringstream buffer;
  3035. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3036. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3037. + go++;
  3038. + }
  3039. + while (result->NextRow());
  3040. + }
  3041. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3042. +
  3043. + }
  3044. +
  3045. +
  3046. + void AddNPC1(Player* player, Creature* creature)
  3047. + {
  3048. + player->PlayerTalkClass->ClearMenus();
  3049. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
  3050. +
  3051. + if (result)
  3052. + {
  3053. + const char* name;
  3054. + uint32 cost, number;
  3055. + uint16 go = 0;
  3056. + do
  3057. + {
  3058. + Field* fields = result->Fetch();
  3059. + name = fields[0].GetCString();
  3060. + cost = fields[1].GetUInt32();
  3061. + number = fields[2].GetUInt32();
  3062. + if (go == 30)
  3063. + {
  3064. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 151);
  3065. + break;
  3066. + }
  3067. +
  3068. + std::stringstream buffer;
  3069. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3070. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3071. + go++;
  3072. + }
  3073. + while (result->NextRow());
  3074. + }
  3075. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3076. + }
  3077. +
  3078. +
  3079. +
  3080. + void AddNPC2(Player* player, Creature* creature)
  3081. + {
  3082. + player->PlayerTalkClass->ClearMenus();
  3083. + //player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 150);
  3084. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
  3085. +
  3086. + if (result)
  3087. + {
  3088. + const char* name;
  3089. + uint32 cost, number;
  3090. + uint16 go = 0;
  3091. + do
  3092. + {
  3093. + if (go < 30)
  3094. + {
  3095. + go++;
  3096. + continue;
  3097. + }
  3098. + Field* fields = result->Fetch();
  3099. + name = fields[0].GetCString();
  3100. + cost = fields[1].GetUInt32();
  3101. + number = fields[2].GetUInt32();
  3102. +
  3103. + if (go == 60)
  3104. + {
  3105. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 152);
  3106. + break;
  3107. + }
  3108. +
  3109. + std::stringstream buffer;
  3110. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3111. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3112. + go++;
  3113. + }
  3114. + while (result->NextRow());
  3115. + }
  3116. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3117. +
  3118. + }
  3119. +
  3120. + void AddNPC3(Player* player, Creature* creature)
  3121. + {
  3122. + player->PlayerTalkClass->ClearMenus();
  3123. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 151);
  3124. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
  3125. +
  3126. + if (result)
  3127. + {
  3128. + const char* name;
  3129. + uint32 cost, number;
  3130. + uint16 go = 0;
  3131. + do
  3132. + {
  3133. + if (go < 60)
  3134. + {
  3135. + go++;
  3136. + continue;
  3137. + }
  3138. + Field* fields = result->Fetch();
  3139. + name = fields[0].GetCString();
  3140. + cost = fields[1].GetUInt32();
  3141. + number = fields[2].GetUInt32();
  3142. +
  3143. + if (go == 90)
  3144. + {
  3145. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 153);
  3146. + break;
  3147. + }
  3148. +
  3149. + std::stringstream buffer;
  3150. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3151. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3152. + go++;
  3153. + }
  3154. + while (result->NextRow());
  3155. + }
  3156. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3157. +
  3158. + }
  3159. +
  3160. + void AddNPC4(Player* player, Creature* creature)
  3161. + {
  3162. + player->PlayerTalkClass->ClearMenus();
  3163. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 152);
  3164. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
  3165. +
  3166. + if (result)
  3167. + {
  3168. + const char* name;
  3169. + uint32 cost, number;
  3170. + uint16 go = 0;
  3171. + do
  3172. + {
  3173. + if (go < 90)
  3174. + {
  3175. + go++;
  3176. + continue;
  3177. + }
  3178. + Field* fields = result->Fetch();
  3179. + name = fields[0].GetCString();
  3180. + cost = fields[1].GetUInt32();
  3181. + number = fields[2].GetUInt32();
  3182. +
  3183. + if (go == 120)
  3184. + {
  3185. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 154);
  3186. + break;
  3187. + }
  3188. +
  3189. + std::stringstream buffer;
  3190. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3191. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3192. + go++;
  3193. + }
  3194. + while (result->NextRow());
  3195. + }
  3196. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3197. +
  3198. + }
  3199. +
  3200. + void AddNPC5(Player* player, Creature* creature)
  3201. + {
  3202. + player->PlayerTalkClass->ClearMenus();
  3203. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 153);
  3204. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
  3205. +
  3206. + if (result)
  3207. + {
  3208. + const char* name;
  3209. + uint32 cost, number;
  3210. + uint16 go = 0;
  3211. + do
  3212. + {
  3213. + if (go < 120)
  3214. + {
  3215. + go++;
  3216. + continue;
  3217. + }
  3218. + Field* fields = result->Fetch();
  3219. + name = fields[0].GetCString();
  3220. + cost = fields[1].GetUInt32();
  3221. + number = fields[2].GetUInt32();
  3222. +
  3223. + if (go == 150)
  3224. + {
  3225. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 155);
  3226. + break;
  3227. + }
  3228. +
  3229. + std::stringstream buffer;
  3230. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3231. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3232. + go++;
  3233. + }
  3234. + while (result->NextRow());
  3235. + }
  3236. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3237. +
  3238. + }
  3239. +
  3240. + void AddNPC6(Player* player, Creature* creature)
  3241. + {
  3242. + player->PlayerTalkClass->ClearMenus();
  3243. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 154);
  3244. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
  3245. +
  3246. + if (result)
  3247. + {
  3248. + const char* name;
  3249. + uint32 cost, number;
  3250. + uint16 go = 0;
  3251. + do
  3252. + {
  3253. + if (go < 150)
  3254. + {
  3255. + go++;
  3256. + continue;
  3257. + }
  3258. + Field* fields = result->Fetch();
  3259. + name = fields[0].GetCString();
  3260. + cost = fields[1].GetUInt32();
  3261. + number = fields[2].GetUInt32();
  3262. +
  3263. + if (go == 180)
  3264. + {
  3265. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 156);
  3266. + break;
  3267. + }
  3268. +
  3269. + std::stringstream buffer;
  3270. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3271. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3272. + go++;
  3273. + }
  3274. + while (result->NextRow());
  3275. + }
  3276. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3277. +
  3278. + }
  3279. +
  3280. + void AddNPC7(Player* player, Creature* creature)
  3281. + {
  3282. + player->PlayerTalkClass->ClearMenus();
  3283. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 155);
  3284. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
  3285. +
  3286. + if (result)
  3287. + {
  3288. + const char* name;
  3289. + uint32 cost, number;
  3290. + uint16 go = 0;
  3291. + do
  3292. + {
  3293. + if (go < 180)
  3294. + {
  3295. + go++;
  3296. + continue;
  3297. + }
  3298. + Field* fields = result->Fetch();
  3299. + name = fields[0].GetCString();
  3300. + cost = fields[1].GetUInt32();
  3301. + number = fields[2].GetUInt32();
  3302. +
  3303. + if (go == 210)
  3304. + {
  3305. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 157);
  3306. + break;
  3307. + }
  3308. +
  3309. + std::stringstream buffer;
  3310. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3311. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3312. + go++;
  3313. + }
  3314. + while (result->NextRow());
  3315. + }
  3316. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3317. +
  3318. + }
  3319. +
  3320. + void AddNPC8(Player* player, Creature* creature)
  3321. + {
  3322. + player->PlayerTalkClass->ClearMenus();
  3323. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 156);
  3324. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
  3325. +
  3326. + if (result)
  3327. + {
  3328. + const char* name;
  3329. + uint32 cost, number;
  3330. + uint16 go = 0;
  3331. + do
  3332. + {
  3333. + if (go < 210)
  3334. + {
  3335. + go++;
  3336. + continue;
  3337. + }
  3338. + Field* fields = result->Fetch();
  3339. + name = fields[0].GetCString();
  3340. + cost = fields[1].GetUInt32();
  3341. + number = fields[2].GetUInt32();
  3342. +
  3343. + if (go == 240)
  3344. + {
  3345. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 158);
  3346. + break;
  3347. + }
  3348. +
  3349. + std::stringstream buffer;
  3350. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3351. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3352. + go++;
  3353. + }
  3354. + while (result->NextRow());
  3355. + }
  3356. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3357. +
  3358. + }
  3359. +
  3360. + void AddNPC9(Player* player, Creature* creature)
  3361. + {
  3362. + player->PlayerTalkClass->ClearMenus();
  3363. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 157);
  3364. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
  3365. +
  3366. + if (result)
  3367. + {
  3368. + const char* name;
  3369. + uint32 cost, number;
  3370. + uint16 go = 0;
  3371. + do
  3372. + {
  3373. + if (go < 240)
  3374. + {
  3375. + go++;
  3376. + continue;
  3377. + }
  3378. + Field* fields = result->Fetch();
  3379. + name = fields[0].GetCString();
  3380. + cost = fields[1].GetUInt32();
  3381. + number = fields[2].GetUInt32();
  3382. +
  3383. + if (go == 270)
  3384. + {
  3385. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 159);
  3386. + break;
  3387. + }
  3388. +
  3389. + std::stringstream buffer;
  3390. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3391. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3392. + go++;
  3393. + }
  3394. + while (result->NextRow());
  3395. + }
  3396. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3397. +
  3398. + }
  3399. +
  3400. + void AddNPC10(Player* player, Creature* creature)
  3401. + {
  3402. + player->PlayerTalkClass->ClearMenus();
  3403. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 158);
  3404. + QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
  3405. +
  3406. + if (result)
  3407. + {
  3408. + const char* name;
  3409. + uint32 cost, number;
  3410. + uint16 go = 0;
  3411. + do
  3412. + {
  3413. + if (go < 270)
  3414. + {
  3415. + go++;
  3416. + continue;
  3417. + }
  3418. + Field* fields = result->Fetch();
  3419. + name = fields[0].GetCString();
  3420. + cost = fields[1].GetUInt32();
  3421. + number = fields[2].GetUInt32();
  3422. +
  3423. + if (go == 300) break;
  3424. +
  3425. + std::stringstream buffer;
  3426. + buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
  3427. + player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
  3428. + go++;
  3429. + }
  3430. + while (result->NextRow());
  3431. + }
  3432. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  3433. +
  3434. + }
  3435. +
  3436. + void PlusRadius(Player* player)
  3437. + {
  3438. +
  3439. + uint32 guild = player->GetGuildId();
  3440. + QueryResult result15 = CharacterDatabase.PQuery("SELECT * FROM guildhouses WHERE guild = %u", guild);
  3441. + if (!result15)
  3442. + {
  3443. + player->CLOSE_GOSSIP_MENU();
  3444. + player->GetSession()->SendNotification("У вас нет Дома Гильдии!");
  3445. + return;
  3446. + }
  3447. + QueryResult result10 = CharacterDatabase.PQuery("SELECT radius FROM guildhouses WHERE guild = %u AND radius >= 80", guild);
  3448. + if (result10)
  3449. + {
  3450. + player->CLOSE_GOSSIP_MENU();
  3451. + player->GetSession()->SendNotification("У вас максимальный радиус ГХ!");
  3452. + return;
  3453. + }
  3454. + uint32 level_table, xp_table, xp;
  3455. + QueryResult result2 = CharacterDatabase.PQuery("SELECT xp FROM guild_level WHERE guild = %u", guild);
  3456. + if (result2)
  3457. + {
  3458. + Field *fields = result2->Fetch();
  3459. + xp = fields[0].GetUInt32();
  3460. + }
  3461. + if (xp < 500)
  3462. + {
  3463. + player->CLOSE_GOSSIP_MENU();
  3464. + player->GetSession()->SendNotification("Недостаточно гильдейского опыта!");
  3465. + return;
  3466. + }
  3467. + CharacterDatabase.PQuery("UPDATE guildhouses SET radius = radius+10 WHERE guild = %u", guild);
  3468. + player->GetSession()->SendAreaTriggerMessage("Радиус вашего дома гильдии расширен на 10 ярдов!");
  3469. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-500 WHERE guild = %u", guild);
  3470. +
  3471. + UpdateLevel(player);
  3472. + }
  3473. +
  3474. + void DeleteAllGobjects(Player* player, Creature* creature, char const* code)
  3475. + {
  3476. +
  3477. + uint32 da = atoi(code);
  3478. + if (da != 123) return;
  3479. + uint32 lowguid;
  3480. + uint64 leader_guid = player->GetGUID();
  3481. + QueryResult result = CharacterDatabase.PQuery("SELECT guid FROM guildhouse_spawned WHERE leader_guid = %u", leader_guid);
  3482. + if (!result)
  3483. + {
  3484. + player->CLOSE_GOSSIP_MENU();
  3485. + player->GetSession()->SendNotification("Вы не поставили не единого объекта!");
  3486. + return;
  3487. + }
  3488. + if (result)
  3489. + {
  3490. + do
  3491. + {
  3492. + Field* fields = result->Fetch();
  3493. + lowguid = fields[0].GetUInt32();
  3494. + if(!lowguid)
  3495. + return;
  3496. +
  3497. + GameObject* obj = NULL;
  3498. + // by DB guid
  3499. + if(GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid))
  3500. + obj = ChatHandler(player->GetSession()).GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id);
  3501. +
  3502. + if(!obj)
  3503. + {
  3504. + ChatHandler(player->GetSession()).PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
  3505. + ChatHandler(player->GetSession()).SetSentErrorMessage(true);
  3506. + return;
  3507. + }
  3508. +
  3509. + QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_go WHERE id = %u", obj->GetEntry());
  3510. + if (res)
  3511. + {
  3512. + Field* ff = res->Fetch();
  3513. + uint32 cost = ff[0].GetUInt32();
  3514. +
  3515. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u",cost ,player->GetGuildId());
  3516. + UpdateLevel(player);
  3517. + }
  3518. +
  3519. + uint64 owner_guid = obj->GetOwnerGUID();
  3520. + if(owner_guid)
  3521. + {
  3522. + Unit* owner = ObjectAccessor::GetUnit(*ChatHandler(player->GetSession()).GetSession()->GetPlayer(), owner_guid);
  3523. + if(!owner || !IS_PLAYER_GUID(owner_guid))
  3524. + {
  3525. + ChatHandler(player->GetSession()).PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow());
  3526. + ChatHandler(player->GetSession()).SetSentErrorMessage(true);
  3527. + return;
  3528. + }
  3529. +
  3530. + owner->RemoveGameObject(obj, false);
  3531. + }
  3532. +
  3533. + obj->SetRespawnTime(0); // not save respawn time
  3534. + obj->Delete();
  3535. + obj->DeleteFromDB();
  3536. +
  3537. + player->CLOSE_GOSSIP_MENU();
  3538. + }
  3539. + while (result->NextRow());
  3540. + CharacterDatabase.PQuery("DELETE FROM guildhouse_spawned WHERE leader_guid = %u", leader_guid);
  3541. + ChatHandler(player->GetSession()).PSendSysMessage("Объекты были успешно удалены!");
  3542. + }
  3543. + }
  3544. +
  3545. + void DeleteAllNPC(Player* player, Creature* creature, char const* code)
  3546. + {
  3547. +
  3548. + uint32 da = atoi(code);
  3549. + if (da != 123) return;
  3550. + uint32 lowguid;
  3551. + uint64 leader_guid = player->GetGUID();
  3552. + QueryResult result = CharacterDatabase.PQuery("SELECT guid FROM guildhouse_npc_spawned WHERE leader_guid = %u", leader_guid);
  3553. + if (!result)
  3554. + {
  3555. + player->CLOSE_GOSSIP_MENU();
  3556. + player->GetSession()->SendNotification("Вы не поставили не единого НПС!");
  3557. + return;
  3558. + }
  3559. + if (result)
  3560. + {
  3561. + do
  3562. + {
  3563. + Field* fields = result->Fetch();
  3564. + lowguid = fields[0].GetUInt32();
  3565. + if(!lowguid) return;
  3566. + Creature* unit = NULL;
  3567. + if(CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid))
  3568. + unit = player->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT));
  3569. +
  3570. + QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_npc WHERE id = %u", unit->GetEntry());
  3571. + if (res)
  3572. + {
  3573. + Field* ff = res->Fetch();
  3574. + uint32 cost = ff[0].GetUInt32();
  3575. +
  3576. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u",cost ,player->GetGuildId());
  3577. + UpdateLevel(player);
  3578. + }
  3579. +
  3580. + if(!unit || unit->IsPet() || unit->IsTotem()) return;
  3581. +
  3582. + // Delete the creature
  3583. + unit->CombatStop();
  3584. + unit->DeleteFromDB();
  3585. + unit->AddObjectToRemoveList();
  3586. + CharacterDatabase.PQuery("DELETE FROM guildhouse_npc_spawned WHERE guid = %u", lowguid);
  3587. +
  3588. + player->GetSession()->SendAreaTriggerMessage("НПС успешно удален!");
  3589. +
  3590. + player->CLOSE_GOSSIP_MENU();
  3591. + }
  3592. + while (result->NextRow());
  3593. + CharacterDatabase.PQuery("DELETE FROM guildhouse_npc_spawned WHERE leader_guid = %u", leader_guid);
  3594. + ChatHandler(player->GetSession()).PSendSysMessage("НПС были успешно удалены!");
  3595. + }
  3596. + }
  3597. +
  3598. + void DeleteNPC(Player* player, Creature* creature)
  3599. + {
  3600. +
  3601. + Creature* unit = player->GetSelectedUnit()->ToCreature();
  3602. +
  3603. + uint32 leader_guid = player->GetGUIDLow();
  3604. + uint64 lowguid = unit->GetGUIDLow();;
  3605. +
  3606. +
  3607. + QueryResult result = CharacterDatabase.PQuery("SELECT guid, leader_guid FROM guildhouse_npc_spawned WHERE leader_guid = %u AND guid = %u", leader_guid, lowguid);
  3608. + if (!result)
  3609. + {
  3610. + player->CLOSE_GOSSIP_MENU();
  3611. + player->GetSession()->SendNotification("НПС с таким номером не найден!", lowguid, leader_guid);
  3612. + return;
  3613. + }
  3614. +
  3615. + if(!unit || unit->IsPet() || unit->IsTotem()) return;
  3616. +
  3617. + QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_npc WHERE id = %u", unit->GetEntry());
  3618. + if (res)
  3619. + {
  3620. + Field* ff = res->Fetch();
  3621. + uint32 cost = ff[0].GetUInt32();
  3622. +
  3623. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u",cost ,player->GetGuildId());
  3624. + UpdateLevel(player);
  3625. + }
  3626. +
  3627. + // Delete the creature
  3628. + unit->CombatStop();
  3629. + unit->DeleteFromDB();
  3630. + unit->AddObjectToRemoveList();
  3631. + CharacterDatabase.PQuery("DELETE FROM guildhouse_npc_spawned WHERE guid = %u", lowguid);
  3632. +
  3633. + player->GetSession()->SendAreaTriggerMessage("НПС успешно удален!");
  3634. + player->CLOSE_GOSSIP_MENU();
  3635. + }
  3636. +
  3637. + void ActivateGobject(Player* player, Creature* creature)
  3638. + {
  3639. + QueryResult result;
  3640. + GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList();
  3641. +
  3642. + std::ostringstream eventFilter;
  3643. + eventFilter << " AND (eventEntry IS NULL ";
  3644. + bool initString = true;
  3645. +
  3646. + for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
  3647. + {
  3648. + if (initString)
  3649. + {
  3650. + eventFilter << "OR eventEntry IN (" << *itr;
  3651. + initString = false;
  3652. + }
  3653. + else
  3654. + eventFilter << ',' << *itr;
  3655. + }
  3656. +
  3657. + if (!initString)
  3658. + eventFilter << "))";
  3659. + else
  3660. + eventFilter << ')';
  3661. + result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, phaseMask, "
  3662. + "(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject "
  3663. + "LEFT OUTER JOIN game_event_gameobject on gameobject.guid = game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10",
  3664. + player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), eventFilter.str().c_str());
  3665. +
  3666. + if (!result)
  3667. + {
  3668. + player->GetSession()->SendNotification("Поблизости не найдено объектов вашего Дома Гильдии!");
  3669. + return;
  3670. + }
  3671. +
  3672. + bool found = false;
  3673. + float x, y, z, o;
  3674. + uint32 guidLow, id, phase;
  3675. + uint16 mapId;
  3676. +
  3677. + do
  3678. + {
  3679. + Field* fields = result->Fetch();
  3680. + guidLow = fields[0].GetUInt32();
  3681. + id = fields[1].GetUInt32();
  3682. + x = fields[2].GetFloat();
  3683. + y = fields[3].GetFloat();
  3684. + z = fields[4].GetFloat();
  3685. + o = fields[5].GetFloat();
  3686. + mapId = fields[6].GetUInt16();
  3687. + phase = fields[7].GetUInt32();
  3688. + QueryResult result15 = CharacterDatabase.PQuery("SELECT guid FROM guildhouse_spawned WHERE leader_guid = %u AND guid = %u", player->GetGUIDLow(), guidLow);
  3689. + if (result15) found = true;
  3690. + } while (result->NextRow() && !found);
  3691. +
  3692. + if (!found)
  3693. + {
  3694. + //player->GetSession()->SendNotification(LANG_GAMEOBJECT_NOT_EXIST);
  3695. + return;
  3696. + }
  3697. +
  3698. + GameObjectTemplate const* objectInfo = sObjectMgr->GetGameObjectTemplate(id);
  3699. +
  3700. + if (!objectInfo)
  3701. + {
  3702. + // player->GetSession()->SendNotification(LANG_GAMEOBJECT_NOT_EXIST);
  3703. + return;
  3704. + }
  3705. +
  3706. + GameObject* target = player->GetMap()->GetGameObject(MAKE_NEW_GUID(guidLow, id, HIGHGUID_GAMEOBJECT));
  3707. +
  3708. + if (target)
  3709. + {
  3710. + QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_go WHERE id = %u", target->GetEntry());
  3711. + if (res)
  3712. + {
  3713. + Field* ff = res->Fetch();
  3714. + uint32 cost = ff[0].GetUInt32();
  3715. +
  3716. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u",cost ,player->GetGuildId());
  3717. + UpdateLevel(player);
  3718. + }
  3719. +
  3720. + target->SetRespawnTime(0);
  3721. + target->Delete();
  3722. + target->DeleteFromDB();
  3723. + player->GetSession()->SendAreaTriggerMessage("Объект успешно удален!");
  3724. + CharacterDatabase.PQuery("DELETE FROM guildhouse_spawned WHERE guid = %u AND leader_guid = %u", guidLow, player->GetGUIDLow());
  3725. + }
  3726. +
  3727. +
  3728. +
  3729. + player->CLOSE_GOSSIP_MENU();
  3730. + }
  3731. +
  3732. + void SpawnNPC(Player* player, Creature* creature, uint32 action)
  3733. + {
  3734. +
  3735. + uint64 leader_guid = player->GetGUID();
  3736. + float x_p,y_p,z_p, radius;
  3737. + float p_x = player->GetPositionX();
  3738. + float p_y = player->GetPositionY();
  3739. + float p_z = player->GetPositionZ();
  3740. + uint32 guild = player->GetGuildId();
  3741. + QueryResult result = CharacterDatabase.PQuery("SELECT id, number, cost FROM guildhouse_npc ORDER BY cost");
  3742. + if (result)
  3743. + {
  3744. + uint32 number, id, cost, level, xp, level_table, xp_table;
  3745. + do
  3746. + {
  3747. + Field* fields = result->Fetch();
  3748. + id = fields[0].GetUInt32();
  3749. + number = fields[1].GetUInt32();
  3750. + cost = fields[2].GetUInt32();
  3751. +
  3752. + if (action == number)
  3753. + {
  3754. + QueryResult result10 = CharacterDatabase.PQuery("SELECT x, y, z, radius FROM guildhouses WHERE guild = %u", guild);
  3755. + if (result10)
  3756. + {
  3757. + Field* fields = result10->Fetch();
  3758. + x_p = fields[0].GetFloat();
  3759. + y_p = fields[1].GetFloat();
  3760. + z_p = fields[2].GetFloat();
  3761. + radius = fields[3].GetFloat();
  3762. + }
  3763. + if (!result10)
  3764. + {
  3765. + player->CLOSE_GOSSIP_MENU();
  3766. + player->GetSession()->SendNotification("У вас нет гильдхауса!");
  3767. + return;
  3768. + }
  3769. + if (p_x > x_p+radius || p_x < x_p-radius || p_y > y_p+radius || p_y < y_p-radius || p_z > z_p+radius || p_z < z_p-radius)
  3770. + {
  3771. + player->CLOSE_GOSSIP_MENU();
  3772. + player->GetSession()->SendNotification("Вы не в своем ГХ!");
  3773. + return;
  3774. + }
  3775. +
  3776. + QueryResult result2 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  3777. + if (result2)
  3778. + {
  3779. + Field* fields = result2->Fetch();
  3780. + level = fields[0].GetUInt32();
  3781. + xp = fields[1].GetUInt32();
  3782. + }
  3783. + if (cost > xp)
  3784. + {
  3785. + player->GetSession()->SendNotification("Недостаточно гильдейского опыта!");
  3786. + return;
  3787. + }
  3788. + Player* chr = player;
  3789. + float x = chr->GetPositionX();
  3790. + float y = chr->GetPositionY();
  3791. + float z = chr->GetPositionZ();
  3792. + float o = chr->GetOrientation();
  3793. + Map *map = chr->GetMap();
  3794. +
  3795. + Creature* creature1 = new Creature;
  3796. + if(!creature1->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, chr->GetTeam(), x, y, z, o))
  3797. + {
  3798. + delete creature1;
  3799. + return;
  3800. + }
  3801. +
  3802. + creature1->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
  3803. +
  3804. + uint32 db_guid = creature1->GetDBTableGUIDLow();
  3805. +
  3806. + // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
  3807. + creature1->LoadFromDB(db_guid, map);
  3808. +
  3809. + map->AddToMap(creature1);
  3810. + sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
  3811. +
  3812. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp - %u WHERE guild = %u", cost, guild);
  3813. +
  3814. + CharacterDatabase.PQuery("REPLACE INTO guildhouse_npc_spawned (guid, leader_guid) VALUES (%u, %u)", db_guid, leader_guid);
  3815. +
  3816. + UpdateLevel(player);
  3817. +
  3818. + AddNPC1(player, creature);
  3819. + break;
  3820. + }
  3821. +
  3822. + }
  3823. + while (result->NextRow());
  3824. + }
  3825. + }
  3826. +
  3827. + void Recall(Player* player)
  3828. + {
  3829. + player->TeleportTo(player->m_recallMap, player->m_recallX, player->m_recallY, player->m_recallZ, player->m_recallO);
  3830. + }
  3831. +
  3832. + void SpawnGobject(Player* player, Creature* creature, uint32 action)
  3833. + {
  3834. +
  3835. + uint64 leader_guid = player->GetGUID();
  3836. + float x_p,y_p,z_p, radius;
  3837. + float p_x = player->GetPositionX();
  3838. + float p_y = player->GetPositionY();
  3839. + float p_z = player->GetPositionZ();
  3840. + uint32 guild = player->GetGuildId();
  3841. + QueryResult result = CharacterDatabase.PQuery("SELECT id, number, cost FROM guildhouse_go ORDER BY cost");
  3842. + if (result)
  3843. + {
  3844. + uint32 number, id, cost, level, xp, level_table, xp_table;
  3845. + do
  3846. + {
  3847. + Field* fields = result->Fetch();
  3848. + id = fields[0].GetUInt32();
  3849. + number = fields[1].GetUInt32();
  3850. + cost = fields[2].GetUInt32();
  3851. +
  3852. + if (action == number)
  3853. + {
  3854. + QueryResult result10 = CharacterDatabase.PQuery("SELECT x, y, z, radius FROM guildhouses WHERE guild = %u", guild);
  3855. + if (result10)
  3856. + {
  3857. + Field* fields = result10->Fetch();
  3858. + x_p = fields[0].GetFloat();
  3859. + y_p = fields[1].GetFloat();
  3860. + z_p = fields[2].GetFloat();
  3861. + radius = fields[3].GetFloat();
  3862. + }
  3863. + if (!result10)
  3864. + {
  3865. + player->CLOSE_GOSSIP_MENU();
  3866. + player->GetSession()->SendNotification("У вас нет гильдхауса!");
  3867. + return;
  3868. + }
  3869. + if (p_x > x_p+radius || p_x < x_p-radius || p_y > y_p+radius || p_y < y_p-radius || p_z > z_p+radius || p_z < z_p-radius)
  3870. + {
  3871. + player->CLOSE_GOSSIP_MENU();
  3872. + player->GetSession()->SendNotification("Вы не в своем ГХ!");
  3873. + return;
  3874. + }
  3875. +
  3876. + QueryResult result2 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
  3877. + if (result2)
  3878. + {
  3879. + Field* fields = result2->Fetch();
  3880. + level = fields[0].GetUInt32();
  3881. + xp = fields[1].GetUInt32();
  3882. + }
  3883. + if (cost > xp)
  3884. + {
  3885. + player->GetSession()->SendNotification("Недостаточно гильдейского опыта!");
  3886. + return;
  3887. + }
  3888. + const GameObjectTemplate *gInfo = sObjectMgr->GetGameObjectTemplate(id);
  3889. + if(!gInfo)
  3890. + {
  3891. + player->GetSession()->SendNotification("Неверный ID");
  3892. + return;
  3893. + }
  3894. + Player* chr = player;
  3895. + float x = float(chr->GetPositionX());
  3896. + float y = float(chr->GetPositionY());
  3897. + float z = float(chr->GetPositionZ());
  3898. + float o = float(chr->GetOrientation());
  3899. + Map *map = chr->GetMap();
  3900. + GameObject* pGameObj = new GameObject;
  3901. + uint32 db_lowGUID = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
  3902. + if(!pGameObj->Create(db_lowGUID, gInfo->entry, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
  3903. + {
  3904. +
  3905. + delete pGameObj;
  3906. + return;
  3907. + }
  3908. + pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
  3909. + if(!pGameObj->LoadFromDB(db_lowGUID, map))
  3910. + {
  3911. + delete pGameObj;
  3912. + return;
  3913. + }
  3914. + map->AddToMap(pGameObj);
  3915. + sObjectMgr->AddGameobjectToGrid(db_lowGUID, sObjectMgr->GetGOData(db_lowGUID));
  3916. +
  3917. + CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp - %u WHERE guild = %u", cost, guild);
  3918. +
  3919. + CharacterDatabase.PQuery("REPLACE INTO guildhouse_spawned (guid, leader_guid) VALUES (%u, %u)", db_lowGUID, leader_guid);
  3920. +
  3921. +
  3922. + QueryResult result3 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_xp_table ORDER BY xp DESC");
  3923. + if (result3)
  3924. + {
  3925. + do
  3926. + {
  3927. + Field *fields = result3->Fetch();
  3928. + level_table = fields[0].GetUInt32();
  3929. + xp_table = fields[1].GetUInt32();
  3930. + if ((xp - cost) < xp_table) continue;
  3931. + else if ((xp - cost) < 100)
  3932. + {
  3933. + CharacterDatabase.PQuery("UPDATE guild_level SET level = 1 WHERE guild = %u", guild);
  3934. + break;
  3935. + }
  3936. + else
  3937. + {
  3938. + CharacterDatabase.PQuery("UPDATE guild_level SET level = %u WHERE guild = %u", level_table, guild);
  3939. + break;
  3940. + }
  3941. + }
  3942. + while (result3->NextRow());
  3943. + }
  3944. + AddGobject1(player, creature);
  3945. + break;
  3946. + }
  3947. +
  3948. + }
  3949. + while (result->NextRow());
  3950. + }
  3951. + }
  3952. +
  3953. + bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
  3954. + {
  3955. + switch (action)
  3956. + {
  3957. + case 8:
  3958. + AddNPC1(player, creature);
  3959. + break;
  3960. + case 1:
  3961. + AddGobject1(player, creature);
  3962. + break;
  3963. + case 100:
  3964. + AddGobject1(player, creature);
  3965. + break;
  3966. + case 101:
  3967. + AddGobject2(player, creature);
  3968. + break;
  3969. + case 102:
  3970. + AddGobject3(player, creature);
  3971. + break;
  3972. + case 103:
  3973. + AddGobject4(player, creature);
  3974. + break;
  3975. + case 104:
  3976. + AddGobject5(player, creature);
  3977. + break;
  3978. + case 105:
  3979. + AddGobject6(player, creature);
  3980. + break;
  3981. + case 106:
  3982. + AddGobject7(player, creature);
  3983. + break;
  3984. + case 107:
  3985. + AddGobject8(player, creature);
  3986. + break;
  3987. + case 108:
  3988. + AddGobject9(player, creature);
  3989. + break;
  3990. + case 109:
  3991. + AddGobject10(player, creature);
  3992. + break;
  3993. + case 150:
  3994. + AddNPC1(player, creature);
  3995. + break;
  3996. + case 151:
  3997. + AddNPC2(player, creature);
  3998. + break;
  3999. + case 152:
  4000. + AddNPC3(player, creature);
  4001. + break;
  4002. + case 153:
  4003. + AddNPC4(player, creature);
  4004. + break;
  4005. + case 154:
  4006. + AddNPC5(player, creature);
  4007. + break;
  4008. + case 155:
  4009. + AddNPC6(player, creature);
  4010. + break;
  4011. + case 156:
  4012. + AddNPC7(player, creature);
  4013. + break;
  4014. + case 157:
  4015. + AddNPC8(player, creature);
  4016. + break;
  4017. + case 158:
  4018. + AddNPC9(player, creature);
  4019. + break;
  4020. + case 159:
  4021. + AddNPC10(player, creature);
  4022. + break;
  4023. + case 2:
  4024. + ActivateGobject(player, creature);
  4025. + break;
  4026. + case 4:
  4027. + player->CLOSE_GOSSIP_MENU();
  4028. + break;
  4029. + case 5:
  4030. + PlusRadius(player);
  4031. + player->CLOSE_GOSSIP_MENU();
  4032. + break;
  4033. + case 7:
  4034. + TeleportToGH(player);
  4035. + break;
  4036. + case 9:
  4037. + DeleteNPC(player, creature);
  4038. + break;
  4039. + case 15:
  4040. + Recall(player);
  4041. + break;
  4042. + }
  4043. + if (action >= 10000) SpawnNPC(player, creature, action);
  4044. + else SpawnGobject(player, creature, action);
  4045. +
  4046. + return true;
  4047. + }
  4048. +
  4049. + void TeleportToGH(Player* player)
  4050. + {
  4051. +
  4052. + uint32 guild = player->GetGuildId();
  4053. + QueryResult result = CharacterDatabase.PQuery("SELECT x, y, z, map, radius FROM guildhouses WHERE guild = %u", guild);
  4054. + if (result)
  4055. + {
  4056. + float x,y,z,radius;
  4057. + float p_x = player->GetPositionX();
  4058. + float p_y = player->GetPositionY();
  4059. + float p_z = player->GetPositionZ();
  4060. + uint32 map;
  4061. + std::string name;
  4062. +
  4063. + Field* fields = result->Fetch();
  4064. + x = fields[0].GetFloat();
  4065. + y = fields[1].GetFloat();
  4066. + z = fields[2].GetFloat();
  4067. + map = fields[3].GetUInt32();
  4068. + radius = fields[4].GetFloat();
  4069. +
  4070. + if (p_x > x+radius || p_x < x-radius || p_y > y+radius || p_y < y-radius || p_z > z+radius || p_z < z-radius)
  4071. + {
  4072. + player->CLOSE_GOSSIP_MENU();
  4073. + player->GetSession()->SendNotification("Вы не в своем ГХ!");
  4074. + return;
  4075. + }
  4076. + player->TeleportTo(map,x,y,z,0.0f,0U);
  4077. + }
  4078. + }
  4079. +
  4080. + bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code)
  4081. + {
  4082. + switch(action)
  4083. + {
  4084. + case 3:
  4085. + DeleteAllGobjects(player, creature, code);
  4086. + break;
  4087. + case 11:
  4088. + DeleteAllNPC(player, creature, code);
  4089. + break;
  4090. + }
  4091. + return true;
  4092. + }
  4093. +
  4094. +};
  4095. +
  4096. +class npc_guildspell : public CreatureScript
  4097. +{
  4098. +public:
  4099. + npc_guildspell() : CreatureScript("npc_guildspell") { }
  4100. +
  4101. + uint8 IsSpell;
  4102. +
  4103. + bool OnGossipHello(Player* player, Creature* creature)
  4104. + {
  4105. + player->PlayerTalkClass->ClearMenus();
  4106. +
  4107. + if (player->GetRankFromDB(player->GetGUID()) == 0 && player->GetGuildId())
  4108. + {
  4109. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Купить гильдейское заклинание.", GOSSIP_SENDER_MAIN, 99000);
  4110. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Купить гильдейское звание.", GOSSIP_SENDER_MAIN, 99002);
  4111. + }
  4112. +
  4113. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Выход.", GOSSIP_SENDER_MAIN, 99001);
  4114. +
  4115. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  4116. +
  4117. + return true;
  4118. + }
  4119. +
  4120. + void BuySpellOrTitle(Player* player, Creature* creature, uint8 isSpell) {
  4121. + player->PlayerTalkClass->ClearMenus();
  4122. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов или званий:", GOSSIP_SENDER_MAIN, 99005);
  4123. + uint32 spell;
  4124. + uint32 cost;
  4125. + uint32 number;
  4126. + const char* name;
  4127. + QueryResult result = CharacterDatabase.PQuery("SELECT spellortitle, cost, number FROM guild_level_spell WHERE isSpell = %u", isSpell);
  4128. + if (result) {
  4129. + do {
  4130. + Field* fields = result->Fetch();
  4131. + spell = fields[0].GetUInt32();
  4132. + cost = fields[1].GetUInt32();
  4133. + number = fields[2].GetUInt32();
  4134. + if (isSpell == 1)
  4135. + {
  4136. + if (player->HasSpell(spell)) continue;
  4137. +
  4138. + const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
  4139. + name = (spellEntry->SpellName[8]);
  4140. + }
  4141. + else
  4142. + {
  4143. + const CharTitlesEntry* titleEntry = sCharTitlesStore.LookupEntry(spell);
  4144. + if (player->HasTitle(titleEntry)) continue;
  4145. +
  4146. + name = (const char*)titleEntry->name[8];
  4147. + }
  4148. + std::stringstream buffer;
  4149. + buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " эмблем." << "|r";
  4150. +
  4151. + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
  4152. + }
  4153. +
  4154. + while (result->NextRow());
  4155. +
  4156. + IsSpell = isSpell;
  4157. +
  4158. + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  4159. + }
  4160. + }
  4161. +
  4162. + void SelectSpellOrTitle(Player* player, Creature* creature, uint32 action) {
  4163. + uint32 spell;
  4164. + uint32 cost;
  4165. + uint32 number;
  4166. + uint32 guild = player->GetGuildId();
  4167. + uint64 guid;
  4168. + QueryResult result = CharacterDatabase.PQuery("SELECT spellortitle, cost, number FROM guild_level_spell WHERE isSpell = %u AND number = %u", IsSpell, action);
  4169. + if (result) {
  4170. + Field* fields = result->Fetch();
  4171. + spell = fields[0].GetUInt32();
  4172. + cost = fields[1].GetUInt32();
  4173. + number = fields[2].GetUInt32();
  4174. +
  4175. + if (number == action) {
  4176. + // learn spell
  4177. +
  4178. + QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
  4179. + if (result2) {
  4180. +
  4181. + if (!player->HasItemCount(49426, cost))
  4182. + {
  4183. + player->CLOSE_GOSSIP_MENU();
  4184. + player->GetSession()->SendNotification("Недостаточно эмблем!");
  4185. + return;
  4186. + }
  4187. +
  4188. + do {
  4189. + Field* fields = result2->Fetch();
  4190. + guid = fields[0].GetUInt64();
  4191. + if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
  4192. + if (IsSpell == 1) onlinePlayer->learnSpell(spell, false);
  4193. + else onlinePlayer->SetTitle(sCharTitlesStore.LookupEntry(spell));
  4194. + }
  4195. +
  4196. + CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spellortitle, isSpell) VALUES (%u, %u, %u)", guild, spell, IsSpell);
  4197. +
  4198. + }
  4199. + while (result2->NextRow());
  4200. +
  4201. + }
  4202. + player->DestroyItemCount(49426, cost, true);
  4203. + // learn spell
  4204. + player->CLOSE_GOSSIP_MENU();
  4205. + if (IsSpell == 1) player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
  4206. + else player->GetSession()->SendAreaTriggerMessage("Гильдейское звание успешно куплено!");
  4207. + }
  4208. +
  4209. + }
  4210. +
  4211. + }
  4212. +
  4213. + bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
  4214. + {
  4215. + switch(action)
  4216. + {
  4217. + case 99000:
  4218. + BuySpellOrTitle(player, creature, 1);
  4219. + break;
  4220. + case 99002:
  4221. + BuySpellOrTitle(player, creature, 0);
  4222. + break;
  4223. + case 99001:
  4224. + player->CLOSE_GOSSIP_MENU();
  4225. + break;
  4226. + case 99005:
  4227. + OnGossipHello(player, creature);
  4228. + break;
  4229. +
  4230. + }
  4231. + if (action < 5000) SelectSpellOrTitle(player, creature, action);
  4232. +
  4233. + return true;
  4234. + }
  4235. +
  4236. +
  4237. +};
  4238. +
  4239. +class Login_spellguild : public PlayerScript
  4240. +{
  4241. +public:
  4242. + Login_spellguild() : PlayerScript("Login_spellguild") { }
  4243. + void OnLogin(Player* player/*, bool firstLogin*/)
  4244. + {
  4245. + uint32 guild = player->GetGuildId();
  4246. +
  4247. + if (!guild) return;
  4248. +
  4249. + QueryResult result = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_learn_spell WHERE guild = %u And isSpell = 1", guild);
  4250. + if (result)
  4251. + {
  4252. + do
  4253. + {
  4254. + Field* fields = result->Fetch();
  4255. + uint32 spell = fields[0].GetUInt32();
  4256. +
  4257. + if (!player->HasSpell(spell)) player->learnSpell(spell, false);
  4258. + }
  4259. + while (result->NextRow());
  4260. + }
  4261. + else
  4262. + {
  4263. + QueryResult result2 = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_level_spell WHERE isSpell = 1");
  4264. + if (result2)
  4265. + {
  4266. + do {
  4267. + Field* fields = result2->Fetch();
  4268. + uint32 Spell = fields[0].GetUInt32();
  4269. +
  4270. + if (player->HasSpell(Spell)) player->removeSpell(Spell);
  4271. + }
  4272. + while (result2->NextRow());
  4273. + }
  4274. + }
  4275. +
  4276. + QueryResult result3 = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_learn_spell WHERE guild = %u And isSpell = 0", guild);
  4277. + if (result3)
  4278. + {
  4279. + do
  4280. + {
  4281. + Field* fields = result3->Fetch();
  4282. + uint32 title = fields[0].GetUInt32();
  4283. +
  4284. + if (!player->HasTitle(sCharTitlesStore.LookupEntry(title))) player->SetTitle(sCharTitlesStore.LookupEntry(title));
  4285. + }
  4286. + while (result3->NextRow());
  4287. + }
  4288. + else
  4289. + {
  4290. + QueryResult result4 = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_level_spell WHERE isSpell = 0");
  4291. + if (result4)
  4292. + {
  4293. + do {
  4294. + Field* fields = result4->Fetch();
  4295. + uint32 title = fields[0].GetUInt32();
  4296. +
  4297. + if (player->HasTitle(sCharTitlesStore.LookupEntry(title)))
  4298. + {
  4299. + player->SetTitle(sCharTitlesStore.LookupEntry(title), true);
  4300. + if (!player->HasTitle(player->GetInt32Value(PLAYER_CHOSEN_TITLE))) player->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
  4301. + }
  4302. + }
  4303. + while (result4->NextRow());
  4304. + }
  4305. + }
  4306. + }
  4307. +};
  4308. +
  4309. +class guildMasterChat : public PlayerScript
  4310. +{
  4311. +public:
  4312. + guildMasterChat() : PlayerScript("guildMasterChat") {}
  4313. +
  4314. + void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Guild* guild)
  4315. + {
  4316. + if (player->GetRank() == 0) msg = "|cFFFFD700" + msg + "|r";
  4317. + }
  4318. +
  4319. +};
  4320. +
  4321. +
  4322. void AddSC_account_commandscript()
  4323. {
  4324. new account_commandscript();
  4325. + new item_tpguild();
  4326. + new npc_guild_level();
  4327. + new npc_guildhouse();
  4328. + new npc_guildhouse_builder();
  4329. + new npc_guildspell();
  4330. + new Login_spellguild();
  4331. + new guildMasterChat();
  4332. }
Add Comment
Please, Sign In to add comment