class npc_guild_level : public CreatureScript
{
public:
npc_guild_level() : CreatureScript("npc_guild_level") { }
bool OnGossipHello(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
uint32 guild = player->GetGuildId();
uint16 level;
if (!guild)
{
player->SEND_GOSSIP_MENU(55004, creature->GetGUID());
return false;
}
QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result)
{
Field *fields = result->Fetch();
level = fields[0].GetUInt16();
if (level < 40)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/INV_Inscription_ArmorScroll02:25:25:-18:0|t50 эмблем льда (+10 опыта гильдии)", GOSSIP_SENDER_MAIN, 35);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/INV_scroll_11:25:25:-18:0|tВложить 100 PvP Token (+1000 опыта гильдии)", GOSSIP_SENDER_MAIN, 36);
//player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Achievement_Reputation_02:25:25:-18:0|tВложить золото для гильдии", GOSSIP_SENDER_MAIN, 200, "Введите сумму, которую хотите Вложить, 5 000 золота = 10 опыта гильдии", 0, true);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Achievement_BG_kill_flag_carrierEOS:25:25:-18:0|tОбменять хонор на опыт гильдии | Exchange honor to XP guild", GOSSIP_SENDER_MAIN, 1);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Achievement_Arena_2v2_1:25:25:-18:0|tОбменять Очки Арены на опыт гильдии | Exchange Arena Points to XP guild.", GOSSIP_SENDER_MAIN, 2);
}
}
if (player->GetRank() == 0)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Spell_Magic_ManaGain:25:25:-18:0|tСменить цвет названия ги / Change color guild name", GOSSIP_SENDER_MAIN, 24);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Spell_Magic_ManaGain:25:25:-18:0|tПрогресс моей гильдии / Guild Progress", GOSSIP_SENDER_MAIN, 3);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Spell_Shadow_Fumble:25:25:-18:0|tТОП гильдий с уровнями / TOP List guild lvl", GOSSIP_SENDER_MAIN, 13);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "|TInterface/ICONS/Temp:25:25:-18:0|tСписок вложивших в гильдию / List donaters in guild", GOSSIP_SENDER_MAIN, 9914);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "|TInterface/ICONS/Spell_ChargeNegative:25:25:-18:0|tExit", GOSSIP_SENDER_MAIN, 4);
player->SEND_GOSSIP_MENU(55000, creature->GetGUID());
return true;
}
void InvestedRoster(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию эмблем льда", GOSSIP_SENDER_MAIN, 9917);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию PvP Token", GOSSIP_SENDER_MAIN, 9918);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию очков чести ", GOSSIP_SENDER_MAIN, 9915);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию очков арены ", GOSSIP_SENDER_MAIN, 9916);
//player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию золота", GOSSIP_SENDER_MAIN, 9000);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void InvestedRosterGold1(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT name, gold, number FROM guild_level_invested WHERE gold > 0 AND guild = %u ORDER BY honor DESC", guild);
if (result)
{
std::string name;
uint32 gold;
uint32 number;
uint16 go = 0;
do
{
Field* fields = result->Fetch();
name = fields[0].GetString();
gold = fields[1].GetUInt32();
number = fields[2].GetUInt64();
if (go == 30)
break;
std::stringstream buffer;
buffer << "Игрок / Player: " << "|cff790C06" << name << "|r" << " вложил / invested " << "|cFF1E90FF" << gold << " золота" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void InvestedSvitok(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT name, svitok, number FROM guild_level_invested WHERE svitok > 0 AND guild = %u ORDER BY svitok DESC", guild);
if (result)
{
std::string name;
uint32 svitok;
uint32 number;
uint16 go = 0;
do
{
Field* fields = result->Fetch();
name = fields[0].GetString();
svitok = fields[1].GetUInt32();
number = fields[2].GetUInt64();
if (go == 50)
break;
std::stringstream buffer;
buffer << "Игрок / Player: " << "|cff790C06" << name << "|r" << " вложил / invested " << "|cFF1E90FF" << svitok << " эмблем льда" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void InvestedToken(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT name, token, number FROM guild_level_invested WHERE token > 0 AND guild = %u ORDER BY token DESC", guild);
if (result)
{
std::string name;
uint32 token;
uint32 number;
uint16 go = 0;
do
{
Field* fields = result->Fetch();
name = fields[0].GetString();
token = fields[1].GetUInt32();
number = fields[2].GetUInt64();
if (go == 30)
break;
std::stringstream buffer;
buffer << "Игрок / Player: " << "|cff790C06" << name << "|r" << " вложил / invested " << "|cFF1E90FF" << token << " эмблем" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void InvestedRosterHonor1(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT name, honor, number FROM guild_level_invested WHERE honor > 0 AND guild = %u ORDER BY honor DESC", guild);
if (result) {
std::string name;
uint32 honor;
uint32 number;
uint16 go = 0;
do {
Field* fields = result->Fetch();
name = fields[0].GetString();
honor = fields[1].GetUInt32();
number = fields[2].GetUInt64();
if (go == 30) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 9910);
break;
}
std::stringstream buffer;
buffer << "Игрок / Player: " << "|cff790C06" << name << "|r" << " вложил / invested " << "|cFF1E90FF" << honor << " чести" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void InvestedRosterHonor2(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 9911);
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT name, honor, number FROM guild_level_invested WHERE honor > 0 AND guild = %u ORDER BY honor DESC", guild);
if (result) {
std::string name;
uint32 honor;
uint32 number;
uint16 go = 0;
do {
if (go < 30) {
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetString();
honor = fields[1].GetUInt32();
number = fields[2].GetUInt64();
if (go == 60) break;
std::stringstream buffer;
buffer << "Игрок / Player: " << "|cff790C06" << name << "|r" << " вложил / invested " << "|cFF1E90FF" << honor << " чести" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void InvestedRosterArena1(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT name, arena, number FROM guild_level_invested WHERE arena > 0 AND guild = %u ORDER BY arena DESC", guild);
if (result) {
std::string name;
uint32 arena;
uint32 number;
uint16 go = 0;
do {
Field* fields = result->Fetch();
name = fields[0].GetString();
arena = fields[1].GetUInt32();
number = fields[2].GetUInt64();
if (go == 30) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 9912);
break;
}
std::stringstream buffer;
buffer << "Игрок / Player: " << "|cff790C06" << name << "|r" << " вложил / invested " << "|cFF1E90FF" << arena << " арены" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void InvestedRosterArena2(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 9913);
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT name, arena, number FROM guild_level_invested WHERE arena > 0 AND guild = %u ORDER BY arena DESC", guild);
if (result) {
std::string name;
uint32 arena;
uint32 number;
uint16 go = 0;
do {
if (go < 30) {
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetString();
arena = fields[1].GetUInt32();
number = fields[2].GetUInt64();
if (go == 60) break;
std::stringstream buffer;
buffer << "Игрок / Player: " << "|cff790C06" << name << "|r" << " вложил / invested " << "|cFF1E90FF" << arena << " арены" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void UpdateLevelCost(Player* player) {
uint32 guild = player->GetGuildId();
QueryResult result10 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result10) {
Field *fields = result10->Fetch();
uint16 level = fields[0].GetUInt16();
uint32 xp = fields[1].GetUInt32();
QueryResult knowLevel = CharacterDatabase.PQuery("SELECT level FROM guild_xp_table WHERE xp > %u", xp);
if (knowLevel)
{
Field *fs = knowLevel->Fetch();
uint16 gLevel = fs[0].GetUInt16();
CharacterDatabase.PQuery("UPDATE guild_level SET level = %u WHERE guild = %u",gLevel, guild);
}
}
}
void SelectSpell5(Player* player, Creature* creature, uint32 action) {
uint32 spell;
uint32 cost;
uint32 number;
uint32 guild = player->GetGuildId();
uint32 guid;
QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 5");
if (result) {
do {
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (number == action) {
// learn spell
QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
if (result2) {
QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result15) {
Field* fields = result15->Fetch();
uint16 level = fields[0].GetUInt16();
uint32 xp = fields[1].GetUInt32();
if (xp >= cost) {
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
UpdateLevelCost(player);
}
else {
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Недостаточно опыта гильдии! Too little experience of the guild!");
ChatHandler(player->GetSession()).PSendSysMessage("YOUR GUILD EXP: %u", xp);
ChatHandler(player->GetSession()).PSendSysMessage("Need: %u/%u", xp, cost);
return;
}
}
do {
Field* fields = result2->Fetch();
guid = fields[0].GetUInt64();
if (Player* onlinePlayer = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, guid)))
{
onlinePlayer->LearnSpell(spell, false);
}
else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
}
while (result2->NextRow());
}
// learn spell
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Гильдейское заклинание успешно куплено! Теперь каждый новый участник гильдии автоматически выучит его в книгу заклинаний. Guild spell successfully bought! Now every new member of the guild will automatically learn it in a book of spells.");
}
}
while (result->NextRow());
}
}
void SelectSpell10(Player* player, Creature* creature, uint32 action) {
uint32 spell;
uint32 cost;
uint32 number;
uint32 guild = player->GetGuildId();
uint32 guid;
QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 10");
if (result) {
do {
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (number == action) {
// learn spell
QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
if (result2) {
QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result15) {
Field* fields = result15->Fetch();
uint16 level = fields[0].GetUInt16();
uint32 xp = fields[1].GetUInt32();
if (xp >= cost) {
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
UpdateLevelCost(player);
}
else {
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Недостаточно опыта гильдии! Too little experience of the guild!");
ChatHandler(player->GetSession()).PSendSysMessage("YOUR GUILD EXP: %u", xp);
ChatHandler(player->GetSession()).PSendSysMessage("Need: %u/%u", xp, cost);
return;
}
}
do {
Field* fields = result2->Fetch();
guid = fields[0].GetUInt64();
if (Player* onlinePlayer = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, guid))) {
onlinePlayer->LearnSpell(spell, false);
}
else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
}
while (result2->NextRow());
}
// learn spell
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Гильдейское заклинание успешно куплено! Теперь каждый новый участник гильдии автоматически выучит его в книгу заклинаний. Guild spell successfully bought! Now every new member of the guild will automatically learn it in a book of spells.");
}
}
while (result->NextRow());
}
}
void SelectSpell15(Player* player, Creature* creature, uint32 action) {
uint32 spell;
uint32 cost;
uint32 number;
uint32 guild = player->GetGuildId();
uint32 guid;
QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 15");
if (result) {
do {
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (number == action) {
// learn spell
QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
if (result2) {
QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result15) {
Field* fields = result15->Fetch();
uint16 level = fields[0].GetUInt16();
uint32 xp = fields[1].GetUInt32();
if (xp >= cost) {
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
UpdateLevelCost(player);
}
else {
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Недостаточно опыта гильдии! Too little experience of the guild!");
ChatHandler(player->GetSession()).PSendSysMessage("YOUR GUILD EXP: %u", xp);
ChatHandler(player->GetSession()).PSendSysMessage("Need: %u/%u", xp, cost);
return;
}
}
do {
Field* fields = result2->Fetch();
guid = fields[0].GetUInt64();
if (Player* onlinePlayer = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, guid))) {
onlinePlayer->LearnSpell(spell, false);
}
else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
}
while (result2->NextRow());
}
// learn spell
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Гильдейское заклинание успешно куплено! Теперь каждый новый участник гильдии автоматически выучит его в книгу заклинаний. Guild spell successfully bought! Now every new member of the guild will automatically learn it in a book of spells.");
}
}
while (result->NextRow());
}
}
void SelectSpell20(Player* player, Creature* creature, uint32 action) {
uint32 spell;
uint32 cost;
uint32 number;
uint32 guild = player->GetGuildId();
uint32 guid;
QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 20");
if (result) {
do {
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (number == action) {
// learn spell
QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
if (result2) {
QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result15) {
Field* fields = result15->Fetch();
uint16 level = fields[0].GetUInt16();
uint32 xp = fields[1].GetUInt32();
if (xp >= cost) {
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
UpdateLevelCost(player);
}
else {
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Недостаточно опыта гильдии! Too little experience of the guild!");
ChatHandler(player->GetSession()).PSendSysMessage("YOUR GUILD EXP: %u", xp);
ChatHandler(player->GetSession()).PSendSysMessage("Need: %u/%u", xp, cost);
return;
}
}
do {
Field* fields = result2->Fetch();
guid = fields[0].GetUInt64();
if (Player* onlinePlayer = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, guid))) {
onlinePlayer->LearnSpell(spell, false);
}
else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
}
while (result2->NextRow());
}
// learn spell
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Гильдейское заклинание успешно куплено! Теперь каждый новый участник гильдии автоматически выучит его в книгу заклинаний. Guild spell successfully bought! Now every new member of the guild will automatically learn it in a book of spells.");
}
}
while (result->NextRow());
}
}
void SelectSpell25(Player* player, Creature* creature, uint32 action) {
uint32 spell;
uint32 cost;
uint32 number;
uint32 guild = player->GetGuildId();
uint32 guid;
QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 25");
if (result) {
do {
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (number == action) {
// learn spell
QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
if (result2) {
QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result15) {
Field* fields = result15->Fetch();
uint16 level = fields[0].GetUInt16();
uint32 xp = fields[1].GetUInt32();
if (xp >= cost) {
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
UpdateLevelCost(player);
}
else {
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Недостаточно опыта гильдии! Too little experience of the guild!");
ChatHandler(player->GetSession()).PSendSysMessage("YOUR GUILD EXP: %u", xp);
ChatHandler(player->GetSession()).PSendSysMessage("Need: %u/%u", xp, cost);
return;
}
}
do {
Field* fields = result2->Fetch();
guid = fields[0].GetUInt64();
if (Player* onlinePlayer = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, guid))) {
onlinePlayer->LearnSpell(spell, false);
}
else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
}
while (result2->NextRow());
}
// learn spell
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Гильдейское заклинание успешно куплено! Теперь каждый новый участник гильдии автоматически выучит его в книгу заклинаний. Guild spell successfully bought! Now every new member of the guild will automatically learn it in a book of spells.");
}
}
while (result->NextRow());
}
}
void SelectSpell30(Player* player, Creature* creature, uint32 action) {
uint32 spell;
uint32 cost;
uint32 number;
uint32 guild = player->GetGuildId();
uint32 guid;
QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 40");
if (result) {
do {
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (number == action) {
// learn spell
QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
if (result2) {
QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result15) {
Field* fields = result15->Fetch();
uint16 level = fields[0].GetUInt16();
uint32 xp = fields[1].GetUInt32();
if (xp >= cost) {
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
UpdateLevelCost(player);
}
else {
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Недостаточно опыта гильдии! Too little experience of the guild!");
ChatHandler(player->GetSession()).PSendSysMessage("YOUR GUILD EXP: %u", xp);
ChatHandler(player->GetSession()).PSendSysMessage("Need: %u/%u", xp, cost);
return;
}
}
do {
Field* fields = result2->Fetch();
guid = fields[0].GetUInt64();
if (Player* onlinePlayer = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, guid))) {
onlinePlayer->LearnSpell(spell, false);
}
else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
}
while (result2->NextRow());
}
// learn spell
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Гильдейское заклинание успешно куплено! Теперь каждый новый участник гильдии автоматически выучит его в книгу заклинаний. Guild spell successfully bought! Now every new member of the guild will automatically learn it in a book of spells.");
}
}
while (result->NextRow());
}
}
void ReplaceColorList(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на |cffFF0000Красный|r / Change color to |cffFF0000Red|r", GOSSIP_SENDER_MAIN, 25);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на |cff0000FFСиний|r / Change color to |cff0000FFBlue|r", GOSSIP_SENDER_MAIN, 26);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на |cff000000Чёрный|r / Change color to |cff000000Black|r", GOSSIP_SENDER_MAIN, 27);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на |cffFFFFFFБелый|r / Change color to |cffFFFFFFWhite|r", GOSSIP_SENDER_MAIN, 28);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на |cff00FF00Зелёный|r / Change color to |cff00FF00Green|r", GOSSIP_SENDER_MAIN, 29);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на |cffFFFF00Желтый|r / Change color to |cffFFFF00Yellow|r", GOSSIP_SENDER_MAIN, 30);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на |cffFF33FFРозовый|r / Change color to |cffFF33FFPurple|r", GOSSIP_SENDER_MAIN, 31);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на |cffFF6A2EОранжевый|r / Change color to |cffFF6A2EOrange|r", GOSSIP_SENDER_MAIN, 32);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на |cff42D7FFГолубой|r / Change color to |cff42D7FFLight-blue|r", GOSSIP_SENDER_MAIN, 33);
//player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на / Change color to ", GOSSIP_SENDER_MAIN, 34);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void ReplaceColor(Player* player, Creature* creature, uint32 color)
{
if (!player->HasItemCount(38186, 250, true)) {
ChatHandler(player->GetSession()).PSendSysMessage("You not have |Hitem:38186:0:0:0:0:0:0:0:0|h|cfffcedbb[PvP Token]|r|hx250!");
player->CLOSE_GOSSIP_MENU();
return;
}
switch(color)
{
case 1:
CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFF0000' WHERE guild = %u", player->GetGuildId());
break;
case 2:
CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cff0000FF' WHERE guild = %u", player->GetGuildId());
break;
case 3:
CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cff000000' WHERE guild = %u", player->GetGuildId());
break;
case 4:
CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFFFFFF' WHERE guild = %u", player->GetGuildId());
break;
case 5:
CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cff00FF00' WHERE guild = %u", player->GetGuildId());
break;
case 6:
CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFFFF00' WHERE guild = %u", player->GetGuildId());
break;
case 7:
CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFF33FF' WHERE guild = %u", player->GetGuildId());
break;
case 8:
CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFF6A2E' WHERE guild = %u", player->GetGuildId());
break;
case 9:
CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cff42D7FF' WHERE guild = %u", player->GetGuildId());
break;
case 10:
CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFFFF00' WHERE guild = %u", player->GetGuildId());
break;
}
player->DestroyItemCount(38186, 250, true);
sGuildMgr->LoadGuilds();
ChatHandler(player->GetSession()).PSendSysMessage("Вы успешно сменили цвет названия гильдии! Изменения вступят в силу после перезагрузки сервера. You have successfully changed the name of the color of the guild! The changes will take effect when you restart the server.");
player->CLOSE_GOSSIP_MENU();
}
void BuySpell10(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9900);
uint32 spell;
uint32 cost;
uint16 level;
uint32 number;
uint32 faction;
char* name;
QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 10");
if (result) {
do {
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
level = fields[2].GetUInt16();
number = fields[3].GetUInt32();
faction = fields[4].GetUInt32();
if (player->HasSpell(spell)) continue;
if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
name = (spellEntry->SpellName[0]);
std::stringstream buffer;
buffer << "|cff084E13" << name << "|r" << ". Стоимость : " << "|cFF1E90FF" << cost << " опыта " << "|r";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
}
while (result->NextRow());
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
}
void BuySpell15(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9901);
uint32 spell;
uint32 cost;
uint16 level;
uint32 number;
uint32 faction;
char* name;
QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 15");
if (result) {
do {
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
level = fields[2].GetUInt16();
number = fields[3].GetUInt32();
faction = fields[4].GetUInt32();
if (player->HasSpell(spell)) continue;
if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
name = (spellEntry->SpellName[0]);
std::stringstream buffer;
buffer << "|cff084E13" << name << "|r" << ". Стоимость : " << "|cFF1E90FF" << cost << " опыта " << "|r";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
}
while (result->NextRow());
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
}
void BuySpell20(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9902);
uint32 spell;
uint32 cost;
uint16 level;
uint32 number;
uint32 faction;
char* name;
QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 20");
if (result) {
do {
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
level = fields[2].GetUInt16();
number = fields[3].GetUInt32();
faction = fields[4].GetUInt32();
if (player->HasSpell(spell)) continue;
if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
name = (spellEntry->SpellName[0]);
std::stringstream buffer;
buffer << "|cff084E13" << name << "|r" << ". Стоимость : " << "|cFF1E90FF" << cost << " опыта " << "|r";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
}
while (result->NextRow());
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
}
void BuySpell25(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9903);
uint32 spell;
uint32 cost;
uint16 level;
uint32 number;
uint32 faction;
char* name;
QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 25");
if (result) {
do {
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
level = fields[2].GetUInt16();
number = fields[3].GetUInt32();
faction = fields[4].GetUInt32();
if (player->HasSpell(spell)) continue;
if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
name = (spellEntry->SpellName[0]);
std::stringstream buffer;
buffer << "|cff084E13" << name << "|r" << ". Стоимость : " << "|cFF1E90FF" << cost << " опыта " << "|r";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
}
while (result->NextRow());
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
}
void BuySpell30(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9904);
uint32 spell;
uint32 cost;
uint16 level;
uint32 number;
uint32 faction;
char* name;
QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 40");
if (result) {
do {
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
level = fields[2].GetUInt16();
number = fields[3].GetUInt32();
faction = fields[4].GetUInt32();
if (player->HasSpell(spell)) continue;
if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
name = (spellEntry->SpellName[0]);
std::stringstream buffer;
buffer << "|cff084E13" << name << "|r" << ". Стоимость : " << "|cFF1E90FF" << cost << " опыта " << "|r";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
}
while (result->NextRow());
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
}
void CurrentSpellsMenu(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Доступные уровни заклинаний:", GOSSIP_SENDER_MAIN, 9905);
uint32 guild = player->GetGuildId();
uint16 level;
QueryResult result = CharacterDatabase.PQuery("SELECT level FROM guild_level WHERE guild = %u", guild);
if (result) {
Field* fields = result->Fetch();
level = fields[0].GetUInt16();
}
uint32 spell;
if (level >= 5) {
QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 5");
if (result2) {
do {
Field* fields = result2->Fetch();
spell = fields[0].GetUInt32();
if (!player->HasSpell(spell)) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 5-го уровня", GOSSIP_SENDER_MAIN, 24);
break;
}
}
while (result2->NextRow());
}
}
if (level >= 10) {
QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 10");
if (result2) {
do {
Field* fields = result2->Fetch();
spell = fields[0].GetUInt32();
if (!player->HasSpell(spell)) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 10-го уровня", GOSSIP_SENDER_MAIN, 25);
break;
}
}
while (result2->NextRow());
}
}
if (level >= 15) {
QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 15");
if (result2) {
do {
Field* fields = result2->Fetch();
spell = fields[0].GetUInt32();
if (!player->HasSpell(spell)) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 15-го уровня", GOSSIP_SENDER_MAIN, 26);
break;
}
}
while (result2->NextRow());
}
}
if (level >= 20) {
QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 20");
if (result2) {
do {
Field* fields = result2->Fetch();
spell = fields[0].GetUInt32();
if (!player->HasSpell(spell)) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 20-го уровня", GOSSIP_SENDER_MAIN, 27);
break;
}
}
while (result2->NextRow());
}
}
if (level >= 25) {
QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 25");
if (result2) {
do {
Field* fields = result2->Fetch();
spell = fields[0].GetUInt32();
if (!player->HasSpell(spell)) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 25-го уровня", GOSSIP_SENDER_MAIN, 28);
break;
}
}
while (result2->NextRow());
}
}
if (level >= 40) {
QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 40");
if (result2) {
do {
Field* fields = result2->Fetch();
spell = fields[0].GetUInt32();
if (!player->HasSpell(spell)) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 40-го уровня", GOSSIP_SENDER_MAIN, 29);
break;
}
}
while (result2->NextRow());
}
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AllGuilds1(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
uint32 count;
QueryResult result3 = CharacterDatabase.PQuery("SELECT COUNT(guild) FROM guild_level WHERE level > 1");
if (result3) {
Field* fields = result3->Fetch();
count = fields[0].GetUInt32();
}
QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
if (result) {
std::string name;
std::string gleader;
uint32 guild;
uint16 level;
uint16 go = 0;
uint64 leaderguid;
do {
Field* fields = result->Fetch();
guild = fields[0].GetUInt32();
level = fields[1].GetUInt16();
QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
if (result3) {
Field* fields = result3->Fetch();
name = fields[0].GetString();
leaderguid = fields[1].GetUInt64();
}
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
if (result4) {
Field* fields = result4->Fetch();
gleader = fields[0].GetString();
}
if (go == 10) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 14);
break;
}
std::stringstream buffer;
buffer << "|cff084E13" << name << "|r" << ". LvL: " << "|cFF1E90FF" << level << "|r" << ". GM: " << "|cff790C06" << gleader << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild+100);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AllGuilds2(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 19);
QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
if (result) {
std::string name;
std::string gleader;
uint32 guild;
uint16 level;
uint16 go = 0;
uint64 leaderguid;
do {
if (go < 10) {
go++;
continue;
}
Field* fields = result->Fetch();
guild = fields[0].GetUInt32();
level = fields[1].GetUInt16();
QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
if (result3) {
Field* fields = result3->Fetch();
name = fields[0].GetString();
leaderguid = fields[1].GetUInt64();
}
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
if (result4) {
Field* fields = result4->Fetch();
gleader = fields[0].GetString();
}
if (go == 20) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next =>", GOSSIP_SENDER_MAIN, 15);
break;
}
std::stringstream buffer;
buffer << "|cff084E13" << name << "|r" << ". LvL: " << "|cFF1E90FF" << level << "|r" << ". GM: " << "|cff790C06" << gleader << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild+1000);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AllGuilds3(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 20);
QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
if (result) {
std::string name;
std::string gleader;
uint32 guild;
uint16 level;
uint16 go = 0;
uint64 leaderguid;
do {
if (go < 20) {
go++;
continue;
}
Field* fields = result->Fetch();
guild = fields[0].GetUInt32();
level = fields[1].GetUInt16();
QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
if (result3) {
Field* fields = result3->Fetch();
name = fields[0].GetString();
leaderguid = fields[1].GetUInt64();
}
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
if (result4) {
Field* fields = result4->Fetch();
gleader = fields[0].GetString();
}
if (go == 30) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next =>", GOSSIP_SENDER_MAIN, 16);
break;
}
std::stringstream buffer;
buffer << "|cff084E13" << name << "|r" << ". LvL: " << "|cFF1E90FF" << level << "|r" << ". GM: " << "|cff790C06" << gleader << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild+2000);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AllGuilds4(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 21);
QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
if (result) {
std::string name;
std::string gleader;
uint32 guild;
uint16 level;
uint16 go = 0;
uint64 leaderguid;
do {
if (go < 30) {
go++;
continue;
}
Field* fields = result->Fetch();
guild = fields[0].GetUInt32();
level = fields[1].GetUInt16();
QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
if (result3) {
Field* fields = result3->Fetch();
name = fields[0].GetString();
leaderguid = fields[1].GetUInt64();
}
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
if (result4) {
Field* fields = result4->Fetch();
gleader = fields[0].GetString();
}
if (go == 40) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next =>", GOSSIP_SENDER_MAIN, 17);
break;
}
std::stringstream buffer;
buffer << "|cff084E13" << name << "|r" << ". LvL: " << "|cFF1E90FF" << level << "|r" << ". GM: " << "|cff790C06" << gleader << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild+3000);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AllGuilds5(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 22);
QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
if (result) {
std::string name;
std::string gleader;
uint32 guild;
uint16 level;
uint16 go = 0;
uint64 leaderguid;
do {
if (go < 40) {
go++;
continue;
}
Field* fields = result->Fetch();
guild = fields[0].GetUInt32();
level = fields[1].GetUInt16();
QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
if (result3) {
Field* fields = result3->Fetch();
name = fields[0].GetString();
leaderguid = fields[1].GetUInt64();
}
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
if (result4) {
Field* fields = result4->Fetch();
gleader = fields[0].GetString();
}
if (go == 50) {
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Конец", GOSSIP_SENDER_MAIN, 18);
break;
}
std::stringstream buffer;
buffer << "|cff084E13" << name << "|r" << ". LvL: " << "|cFF1E90FF" << level << "|r" << ". GM: " << "|cff790C06" << gleader << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild+4000);
go++;
} while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void TakeHonorButtons(Player* player, Creature* creature) {
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Вложить гильдии 125000 чести (+25 опыта) | Donate guild 125 000 honor (+25 experience)", GOSSIP_SENDER_MAIN, 5);
//player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Вложить гильдии 10 000 чести (+50 опыта)", GOSSIP_SENDER_MAIN, 6);
//player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Вложить гильдии 20 000 чести (+100 опыта)", GOSSIP_SENDER_MAIN, 7);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Вложить гильдии 62500 чести (+10 опыта) | Donate guild 62500 honor (+10 experience)", GOSSIP_SENDER_MAIN, 8);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void TakeGold(Player* player, Creature* creature, char const* code)
{
int32 gold = atoi(code)*10000;
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
if (player->GetMoney() < 5000*10000) {
ChatHandler(player->GetSession()).PSendSysMessage("У вас недостаточно золота!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
uint32 axp = gold/50/10000;
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u",axp, guild);
std::string name = player->GetName();
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
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());
QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
uint32 number;
QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
if (result2) {
Field* fields = result2->Fetch();
number = fields[0].GetUInt32();
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);
}
CharacterDatabase.PQuery("UPDATE guild_level_invested SET gold = gold+%u WHERE guild = %u AND name = '%s'",gold/10000, guild, name.c_str());
player->ModifyMoney(-gold);
UpdateLevel(player);
ChatHandler(player->GetSession()).PSendSysMessage("Пожертвование прошло успешно! The donation was a success!");
player->CLOSE_GOSSIP_MENU();
}
void TakeArena10000(Player* player) {
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
if (player->GetArenaPoints() < 5000) {
ChatHandler(player->GetSession()).PSendSysMessage("У вас недостаточно очков арены! You do not have arena points!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+50 WHERE guild = %u", guild);
std::string name = player->GetName();
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
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());
QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
uint32 number;
QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
if (result2) {
Field* fields = result2->Fetch();
number = fields[0].GetUInt32();
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);
}
CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+5000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
player->ModifyArenaPoints(-5000);
UpdateLevel(player);
ChatHandler(player->GetSession()).PSendSysMessage("Пожертвование прошло успешно! +50 опыт гильдии. The donation was a success! +50 XP Guild.");
player->CLOSE_GOSSIP_MENU();
}
void TakeArena7500(Player* player) {
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
if (player->GetArenaPoints() < 2500) {
ChatHandler(player->GetSession()).PSendSysMessage("У вас недостаточно очков арены! You do not have arena points!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+25 WHERE guild = %u", guild);
std::string name = player->GetName();
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
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());
QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
uint32 number;
QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
if (result2) {
Field* fields = result2->Fetch();
number = fields[0].GetUInt32();
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);
}
CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+2500 WHERE guild = %u AND name = '%s'", guild, name.c_str());
player->ModifyArenaPoints(-2500);
UpdateLevel(player);
ChatHandler(player->GetSession()).PSendSysMessage("Пожертвование прошло успешно! +25 XP Guild. The donation was a success! +25 XP Guild.");
player->CLOSE_GOSSIP_MENU();
}
void TakeArena5000(Player* player) {
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
if (player->GetArenaPoints() < 500) {
ChatHandler(player->GetSession()).PSendSysMessage("У вас недостаточно очков арены! You do not have arena points!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+50 WHERE guild = %u", guild);
std::string name = player->GetName();
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
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());
QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
uint32 number;
QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
if (result2) {
Field* fields = result2->Fetch();
number = fields[0].GetUInt32();
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);
}
CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+500 WHERE guild = %u AND name = '%s'", guild, name.c_str());
player->ModifyArenaPoints(-500);
UpdateLevel(player);
ChatHandler(player->GetSession()).PSendSysMessage("Пожертвование прошло успешно! The donation was a success!");
player->CLOSE_GOSSIP_MENU();
}
void TakeArena2500(Player* player) {
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
if (player->GetArenaPoints() < 100) {
ChatHandler(player->GetSession()).PSendSysMessage("У вас недостаточно очков арены! You do not have arena points!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+10 WHERE guild = %u", guild);
std::string name = player->GetName();
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
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());
QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
uint32 number;
QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
if (result2) {
Field* fields = result2->Fetch();
number = fields[0].GetUInt32();
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);
}
CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+100 WHERE guild = %u AND name = '%s'", guild, name.c_str());
player->ModifyArenaPoints(-100);
UpdateLevel(player);
ChatHandler(player->GetSession()).PSendSysMessage("Пожертвование прошло успешно! The donation was a success!");
player->CLOSE_GOSSIP_MENU();
}
void TakeHonor200(Player* player) {
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
if (player->GetHonorPoints() < 62500) {
ChatHandler(player->GetSession()).PSendSysMessage("У вас недостаточно очков чести! You have not enough honor points!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+10 WHERE guild = %u", guild);
std::string name = player->GetName();
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
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());
QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
uint32 number;
QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
if (result2) {
Field* fields = result2->Fetch();
number = fields[0].GetUInt32();
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);
}
CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+62500 WHERE guild = %u AND name = '%s'", guild, name.c_str());
player->ModifyHonorPoints(-62500);
UpdateLevel(player);
ChatHandler(player->GetSession()).PSendSysMessage("Пожертвование прошло успешно! +10 опыт гильдии. The donation was a success! +10 XP Guild");
player->CLOSE_GOSSIP_MENU();
}
void TakeHonor150(Player* player) {
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
if (player->GetHonorPoints() < 20000) {
ChatHandler(player->GetSession()).PSendSysMessage("У вас недостаточно очков чести! You have not enough honor points!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+100 WHERE guild = %u", guild);
std::string name = player->GetName();
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
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());
QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
uint32 number;
QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
if (result2) {
Field* fields = result2->Fetch();
number = fields[0].GetUInt32();
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);
}
CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+20000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
player->ModifyHonorPoints(-20000);
UpdateLevel(player);
ChatHandler(player->GetSession()).PSendSysMessage("Пожертвование прошло успешно! The donation was a success!");
player->CLOSE_GOSSIP_MENU();
}
void TakeHonor100(Player* player) {
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
if (player->GetHonorPoints() < 10000) {
ChatHandler(player->GetSession()).PSendSysMessage("У вас недостаточно очков чести! You have not enough honor points!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+50 WHERE guild = %u", guild);
std::string name = player->GetName();
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
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());
QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
uint32 number;
QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
if (result2) {
Field* fields = result2->Fetch();
number = fields[0].GetUInt32();
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);
}
CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+10000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
player->ModifyHonorPoints(-10000);
UpdateLevel(player);
ChatHandler(player->GetSession()).PSendSysMessage("Пожертвование прошло успешно! The donation was a success!");
player->CLOSE_GOSSIP_MENU();
}
void TakeFrostEmblem(Player* player)
{
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
if (!player->HasItemCount(38186, 100, true)) {
ChatHandler(player->GetSession()).PSendSysMessage("You not have |Hitem:38186:0:0:0:0:0:0:0:0|h|cfffcedbb[PvP Token]|r|hx200!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+1000 WHERE guild = %u", guild);
std::string name = player->GetName();
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
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());
QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
uint32 number;
QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
if (result2) {
Field* fields = result2->Fetch();
number = fields[0].GetUInt32();
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);
}
CharacterDatabase.PQuery("UPDATE guild_level_invested SET token = token+200 WHERE guild = %u AND name = '%s'", guild, name.c_str());
player->DestroyItemCount(38186, 100, true);
UpdateLevel(player);
ChatHandler(player->GetSession()).PSendSysMessage("Пожертвование прошло успешно! The donation was a success!");
player->CLOSE_GOSSIP_MENU();
}
void TakeTriumphEmblem(Player* player)
{
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
if (!player->HasItemCount(49426, 50, true)) {
ChatHandler(player->GetSession()).PSendSysMessage("У вас недостаточно эмблем льда!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+10 WHERE guild = %u", guild);
std::string name = player->GetName();
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
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());
QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
uint32 number;
QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
if (result2) {
Field* fields = result2->Fetch();
number = fields[0].GetUInt32();
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);
}
CharacterDatabase.PQuery("UPDATE guild_level_invested SET svitok = svitok+50 WHERE guild = %u AND name = '%s'", guild, name.c_str());
player->DestroyItemCount(49426, 50, true);
UpdateLevel(player);
ChatHandler(player->GetSession()).PSendSysMessage("Пожертвование прошло успешно! The donation was a success!");
player->CLOSE_GOSSIP_MENU();
}
void TakeHonor50(Player* player) {
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
if (player->GetHonorPoints() < 125000) {
ChatHandler(player->GetSession()).PSendSysMessage("У вас недостаточно очков чести! You have not enough honor points!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+25 WHERE guild = %u", guild);
std::string name = player->GetName();
QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
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());
QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
uint32 number;
QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
if (result2) {
Field* fields = result2->Fetch();
number = fields[0].GetUInt32();
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);
}
CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+125000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
player->ModifyHonorPoints(-125000);
UpdateLevel(player);
ChatHandler(player->GetSession()).PSendSysMessage("Пожертвование прошло успешно! +25 опыт гильдии. The donation was a success! +25 xp guild.");
player->CLOSE_GOSSIP_MENU();
}
void TakeArenaButtons(Player* player, Creature* creature) {
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
player->PlayerTalkClass->ClearMenus();
//player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Вложить гильдии 100 арены (+10 опыта)", GOSSIP_SENDER_MAIN, 9);
//player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Вложить гильдии 500 арены (+50 опыта)", GOSSIP_SENDER_MAIN, 10);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Вложить гильдии 2500 арены (+25 опыта) / Donate Guild 2500 arena points (+25 experience)", GOSSIP_SENDER_MAIN, 11);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Вложить гильдии 5000 арены (+50 опыта) / Donate Guild 5000 arena points (+50 experience)", GOSSIP_SENDER_MAIN, 12);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void GuildInfo(Player* player) {
if (!player->GetGuildId()) {
ChatHandler(player->GetSession()).PSendSysMessage("Вы не состоите в гильдии! You are not a member of a guild!");
player->CLOSE_GOSSIP_MENU();
return;
}
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result) {
Field *fields = result->Fetch();
uint16 level = fields[0].GetUInt16();
uint32 xp = fields[1].GetUInt32();
ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eУровень вашей гильдии | Your LvL Guild:|r %u", level);
ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eОпыт вашей гильдии для покупки гильдийских предметов:|r %u", xp);
ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eYour Guild Experience to purchase a guild items:|r %u", xp);
QueryResult result1 = CharacterDatabase.PQuery("SELECT xp FROM guild_xp_table WHERE level = %u", level);
if (result1) {
Field *fields = result1->Fetch();
uint32 reqXp = fields[0].GetUInt32();
uint32 ReqXp = reqXp-xp;
if (level < 40) ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eДо %u-го уровня гильдии осталось накопить:|r %u опыта", level+1, ReqXp);
if (level < 40) ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25ePrior to the %u-nd level of the guild left to accumulate:|r %u experience", level+1, ReqXp);
else ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eВаша гильдия имеет максимальный уровень! Your guild has a maximum level!|r");
}
}
player->CLOSE_GOSSIP_MENU();
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) {
switch (action) {
case 1:
TakeHonorButtons(player, creature);
break;
case 2:
TakeArenaButtons(player, creature);
break;
case 3:
GuildInfo(player);
break;
case 4:
player->CLOSE_GOSSIP_MENU();
break;
case 5:
TakeHonor50(player);
break;
case 6:
TakeHonor100(player);
break;
case 7:
TakeHonor150(player);
break;
case 8:
TakeHonor200(player);
break;
case 9:
TakeArena2500(player);
break;
case 10:
TakeArena5000(player);
break;
case 11:
TakeArena7500(player);
break;
case 12:
TakeArena10000(player);
break;
case 13:
AllGuilds1(player, creature);
break;
case 14:
AllGuilds2(player, creature);
break;
case 15:
AllGuilds3(player, creature);
break;
case 16:
AllGuilds4(player, creature);
break;
case 17:
AllGuilds5(player, creature);
break;
case 18:
player->CLOSE_GOSSIP_MENU();
break;
case 19:
AllGuilds1(player, creature);
break;
case 20:
AllGuilds2(player, creature);
break;
case 21:
AllGuilds3(player, creature);
break;
case 22:
AllGuilds4(player, creature);
break;
case 23:
CurrentSpellsMenu(player, creature);
break;
case 24:
ReplaceColorList(player, creature);
break;
case 25:
ReplaceColor(player, creature, 1);
break;
case 26:
ReplaceColor(player, creature, 2);
break;
case 27:
ReplaceColor(player, creature, 3);
break;
case 28:
ReplaceColor(player, creature, 4);
break;
case 29:
ReplaceColor(player, creature, 5);
break;
case 30:
ReplaceColor(player, creature, 6);
break;
case 31:
ReplaceColor(player, creature, 7);
break;
case 32:
ReplaceColor(player, creature, 8);
break;
case 33:
ReplaceColor(player, creature, 9);
break;
case 34:
ReplaceColor(player, creature, 10);
break;
case 35:
TakeTriumphEmblem(player);
break;
case 36:
TakeFrostEmblem(player);
break;
/*case 9998:
BuySpell5(player, creature);
break;
case 9900:
BuySpell10(player, creature);
break;
case 9901:
BuySpell15(player, creature);
break;
case 9902:
BuySpell20(player, creature);
break;
case 9903:
BuySpell25(player, creature);
break;
case 9904:
BuySpell30(player, creature);
break;
case 9905:
CurrentSpellsMenu(player, creature);
break;*/
case 9000:
InvestedRosterGold1(player, creature);
break;
case 9910:
InvestedRosterHonor2(player, creature);
break;
case 9911:
InvestedRosterHonor1(player, creature);
break;
case 9912:
InvestedRosterArena2(player, creature);
break;
case 9913:
InvestedRosterArena1(player, creature);
break;
case 9914:
InvestedRoster(player, creature);
break;
case 9917:
InvestedSvitok(player, creature);
break;
case 9918:
InvestedToken(player, creature);
break;
case 9915:
InvestedRosterHonor1(player, creature);
break;
case 9916:
InvestedRosterArena1(player, creature);
break;
}
if (action > 100 && action < 1000) AllGuilds1(player, creature);
if (action > 1000 && action < 2000) AllGuilds2(player, creature);
if (action > 2000 && action < 3000) AllGuilds3(player, creature);
if (action > 3000 && action < 4000) AllGuilds4(player, creature);
if (action > 4000 && action < 5000) AllGuilds5(player, creature);
if (action >= 10000) InvestedRoster(player, creature);
/*SelectSpell5(player, creature, action);
SelectSpell10(player, creature, action);
SelectSpell15(player, creature, action);
SelectSpell20(player, creature, action);
SelectSpell25(player, creature, action);
SelectSpell30(player, creature, action);*/
return true;
}
bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code)
{
switch(action)
{
case 200:
TakeGold(player, creature, code);
break;
}
return true;
}
};
class npc_guildhouse : public CreatureScript
{
public:
npc_guildhouse() : CreatureScript("npc_guildhouse") {}
bool OnGossipHello(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
uint16 count;
if (uint32 guild = player->GetGuildId())
{
if (player->GetRankFromDB(player->GetGUID()) == 0)
{
QueryResult result = CharacterDatabase.PQuery("SELECT COUNT(guild) FROM guildhouses WHERE guild = 0");
if (result)
{
QueryResult result2 = CharacterDatabase.PQuery("SELECT guild FROM guildhouses WHERE guild = %u", guild);
if (!result2)
{
Field* fields = result->Fetch();
count = fields[0].GetUInt16();
if (count > 0)
{
std::ostringstream psm;
psm << "|TInterface/ICONS/Spell_Arcane_TeleportTheramore:25:25:-18:0|tПосмотреть место для Дома Гильдии / View a place for the Guild House";
std::ostringstream kpt;
kpt << "|TInterface/ICONS/Spell_Arcane_TeleportSilvermoon:25:25:-18:0|tКупить место для Дома Гильдии / Buy a place for the Guild House";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, psm.str(), GOSSIP_SENDER_MAIN, 1);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, kpt.str(), GOSSIP_SENDER_MAIN, 2);
}
}
}
else
{
ChatHandler(player->GetSession()).PSendSysMessage("Свободных мест нет! No vacant tables!");
player->CLOSE_GOSSIP_MENU();
return false;
}
}
std::ostringstream tpd;
tpd << "|TInterface/ICONS/Spell_Arcane_TeleportThunderBluff:25:25:-18:0|tТелепорт в Дом своей гильдии / Teleport to GuildHouse";
QueryResult result5 = CharacterDatabase.PQuery("SELECT guild FROM guildhouses WHERE guild = %u", guild);
if (result5) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, tpd.str(), GOSSIP_SENDER_MAIN, 3);
std::ostringstream vxd;
vxd << "|TInterface/ICONS/Spell_ChargeNegative:25:25:-18:0|tExit.";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, vxd.str(), GOSSIP_SENDER_MAIN, 4);
}
else
{
player->SEND_GOSSIP_MENU(55004, creature->GetGUID());
return false;
}
player->SEND_GOSSIP_MENU(55001, creature->GetGUID());
return true;
}
void LookGuildHouses(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(4, "Список доступных ГХ / The list of available GH:", GOSSIP_SENDER_MAIN, 200);
QueryResult result = CharacterDatabase.PQuery("SELECT name, x, y, z, radius, cost, number, number2 FROM guildhouses WHERE guild = 0 ORDER BY cost");
if (result)
{
float x,y,z,radius;
uint32 cost, number, number_2;
const char* name;
uint16 go = 0;
do
{
Field* fields = result->Fetch();
name = fields[0].GetCString();
x = fields[1].GetFloat();
y = fields[2].GetFloat();
z = fields[3].GetFloat();
radius = fields[4].GetFloat();
cost = fields[5].GetUInt32();
number = fields[6].GetUInt32();
number_2 = fields[7].GetUInt32();
if (go == 30)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 101);
break;
}
std::stringstream buffer;
buffer << "Посмотреть ГХ / Select GH: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cffE024B4" << cost << " опыта / experience" << "|r";
if (i == 1) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
if (i == 2) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number_2);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void LookGuildHouses2(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(4, "Список доступных ГХ / The list of available GH:", GOSSIP_SENDER_MAIN, 201);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 100);
QueryResult result = CharacterDatabase.PQuery("SELECT name, x, y, z, radius, cost, number, number2 FROM guildhouses WHERE guild = 0 ORDER BY cost");
if (result)
{
float x,y,z,radius;
uint32 cost, number, number_2;
const char* name;
uint16 go = 0;
do
{
if (go < 30)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
x = fields[1].GetFloat();
y = fields[2].GetFloat();
z = fields[3].GetFloat();
radius = fields[4].GetFloat();
cost = fields[5].GetUInt32();
number = fields[6].GetUInt32();
number_2 = fields[7].GetUInt32();
if (go == 60) break;
std::stringstream buffer;
buffer << "Посмотреть ГХ / Select GH: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cffE024B4" << cost << " опыта / experience" << "|r";
if (i == 1) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
if (i == 2) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number_2);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
uint8 i;
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
{
switch (action)
{
case 1:
i = 1;
LookGuildHouses(player, creature);
break;
case 2:
i = 2;
LookGuildHouses(player, creature);
break;
case 3:
TeleportToGH(player);
break;
case 100:
LookGuildHouses(player, creature);
break;
case 101:
LookGuildHouses2(player, creature);
break;
case 4:
player->CLOSE_GOSSIP_MENU();
break;
case 200:
LookGuildHouses(player, creature);
break;
case 201:
LookGuildHouses2(player, creature);
break;
}
if (i == 1) TeleportToLook(player, action);
if (i == 2) BuyGuildHouse(player, action);
return true;
}
void BuyGuildHouse(Player* player, uint32 action)
{
QueryResult result = CharacterDatabase.PQuery("SELECT number2, cost FROM guildhouses WHERE guild = 0 ORDER BY cost");
if (result)
{
uint16 level, level_table;
uint32 number_2, cost, xp, xp_table;
uint32 guild = player->GetGuildId();
do
{
Field* fields = result->Fetch();
number_2 = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
if (action == number_2)
{
QueryResult result2 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result2)
{
Field *fields = result2->Fetch();
level = fields[0].GetUInt16();
xp = fields[1].GetUInt32();
if (xp >= cost)
{
CharacterDatabase.PQuery("UPDATE guildhouses SET guild = %u WHERE number2 = %u", guild, number_2);
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp - %u WHERE guild = %u", cost, guild);
if (!player->HasSpell(69541)) player->LearnSpell(69541,false);
UpdateLevel(player);
//ChatHandler(player->GetSession()).PSendSysMessage("Место для дома гильдии куплено!");
ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eВы купили место для дома гильдии. You bought the home place of the guild.|r");
ChatHandler(player->GetSession()).PSendSysMessage("Чтобы начать его обустраивать вызовите пандарена-монаха из списка небоевых спутников.");
ChatHandler(player->GetSession()).PSendSysMessage("To start a guild house building call Pandaren monk from the list of non-battle pets");
player->CLOSE_GOSSIP_MENU();
break;
}
else
{
ChatHandler(player->GetSession()).PSendSysMessage("Недостаточно опыта гильдии! Too little experience of the guild!");
ChatHandler(player->GetSession()).PSendSysMessage("YOUR GUILD EXP: %u", xp);
ChatHandler(player->GetSession()).PSendSysMessage("Need: %u/%u", xp, cost);
player->CLOSE_GOSSIP_MENU();
break;
}
}
}
}
while (result->NextRow());
}
}
void TeleportToGH(Player* player)
{
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT x, y, z, map FROM guildhouses WHERE guild = %u", guild);
if (result)
{
float x,y,z;
uint32 map;
std::string name;
Field* fields = result->Fetch();
x = fields[0].GetFloat();
y = fields[1].GetFloat();
z = fields[2].GetFloat();
map = fields[3].GetUInt32();
player->TeleportTo(map,x,y,z,0.0f,0U);
player->GetSpellHistory()->ResetCooldown(8690, true);
player->SetPhaseMask(1, true);
}
}
void TeleportToLook(Player* player, uint32 action)
{
QueryResult result = CharacterDatabase.PQuery("SELECT x, y, z, map, number, number2 FROM guildhouses WHERE guild = 0 ORDER BY cost");
if (result)
{
float x,y,z;
uint32 number, map;
std::string name;
do
{
Field* fields = result->Fetch();
x = fields[0].GetFloat();
y = fields[1].GetFloat();
z = fields[2].GetFloat();
map = fields[3].GetUInt32();
number = fields[4].GetUInt32();
if (action == number)
{
player->SaveRecallPosition();
player->TeleportTo(map,x,y,z,0.0f,0U);
player->RemoveArenaSpellCooldowns();
player->GetSpellHistory()->ResetCooldown(8690, true);
player->SetPhaseMask(1, true);
if (!player->HasSpell(69541)) player->LearnSpell(69541,false);
ChatHandler(player->GetSession()).PSendSysMessage("Вы решили посмотреть место для дома гильдии. You have chosen to look at the house of the guild.|r");
ChatHandler(player->GetSession()).PSendSysMessage("Чтобы телепортироваться обратно вызовите пандарена-монаха из списка небоевых спутников. To teleport callback Pandaren monk from the list of non-battle pets|r");
break;
}
}
while (result->NextRow());
}
}
};
class npc_guildhouse_builder : public CreatureScript
{
public:
npc_guildhouse_builder() : CreatureScript("npc_guildhouse_builder") {}
bool OnGossipHello(Player* player, Creature* creature) {
player->PlayerTalkClass->ClearMenus();
ChatHandler(player->GetSession()).PSendSysMessage("Это работает только для гильд мастера.");
ChatHandler(player->GetSession()).PSendSysMessage("This only works for the guild master.");
if (uint32 guild = player->GetGuildId()) {
if (player->GetRankFromDB(player->GetGUID()) == 0) {
QueryResult haveGuildHouse = CharacterDatabase.PQuery("SELECT * FROM guildhouses WHERE guild = %u", guild);
if (haveGuildHouse)
{
QueryResult result5 = CharacterDatabase.PQuery("SELECT guild FROM guildhouses WHERE guild = %u", guild);
std::ostringstream pnp;
//pnp << "|TInterface/ICONS/Spell_Holy_Rapture:25:25:-18:0|tПоставить НПС / Add NPC";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, pnp.str(), GOSSIP_SENDER_MAIN, 8);
std::ostringstream pob;
pob << "|TInterface/ICONS/Spell_Nature_NullWard:25:25:-18:0|tПоставить объект / Add Object";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, pob.str(), GOSSIP_SENDER_MAIN, 1);
std::ostringstream dnpc;
//dnpc << "|TInterface/ICONS/Spell_Shadow_DeathScream:25:25:-18:0|tУдалить НПС / Remove NPC";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, dnpc.str(), GOSSIP_SENDER_MAIN, 9);
std::ostringstream danpc;
//danpc << "|TInterface/ICONS/Spell_Shadow_DeadofNight:25:25:-18:0|tУдалить всех НПС в Доме Гильдии / Remove All NPC in Guild House";
//player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_BATTLE, danpc.str(), GOSSIP_SENDER_MAIN, 11, "Вы действительно хотите удалить всех НПС? Введите 123 для удаления! | Are you sure you want to remove all NPC? Enter 123 to remove!", 0, true);
std::ostringstream dobj;
dobj << "|TInterface/ICONS/Spell_Shadow_FingerOfDeath:25:25:-18:0|tУдалить ближайший объект / Remove the closest object";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE,dobj.str() , GOSSIP_SENDER_MAIN, 2);
std::ostringstream daobj;
daobj << "|TInterface/ICONS/Spell_Shadow_GrimWard:25:25:-18:0|tУдалить все объекты в Доме Гильдии / Remove all objects in the Guild House";
player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_BATTLE, daobj.str(), GOSSIP_SENDER_MAIN, 3, "Вы действительно хотите удалить все объекты? Введите 123 для удаления! | Are you sure you want to remove all objects? Enter 123 to remove!", 0, true);
std::ostringstream prad;
prad << "|TInterface/ICONS/Spell_ChargePositive:25:25:-18:0|tРасширить радиус ГХ на 10 ярдов(500 опыта) | Increase radius GH to 10 yards(500 XP)";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, prad.str(), GOSSIP_SENDER_MAIN, 5);
std::ostringstream zst;
zst << "|TInterface/ICONS/Spell_Fire_FelHellfire:25:25:-18:0|tЗАСТРЯЛ! STUCK!";
if (result5) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, zst.str(), GOSSIP_SENDER_MAIN, 7);
}
else player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Teleport back", GOSSIP_SENDER_MAIN, 15);
}
}
else
{
player->SEND_GOSSIP_MENU(55004, creature->GetGUID());
return false;
}
std::ostringstream vxd;
vxd << "|TInterface/ICONS/Spell_ChargeNegative:25:25:-18:0|tExit";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, vxd.str(), GOSSIP_SENDER_MAIN, 4);
player->SEND_GOSSIP_MENU(55002, creature->GetGUID());
return true;
}
void AddGobject1(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 30)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 101);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddGobject2(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 100);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 30)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 60)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 102);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddGobject3(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 101);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 60)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 90)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 103);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddGobject4(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 102);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 90)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 120)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 104);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddGobject5(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 103);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 120)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 150)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 105);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddGobject6(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 104);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 150)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 180)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 106);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddGobject7(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 105);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 180)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 210)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 107);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddGobject8(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 106);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 210)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 240)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 108);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddGobject9(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 107);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 240)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 270)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 109);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddGobject10(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 108);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 270)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 300) break;
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddNPC1(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 30)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 151);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddNPC2(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
//player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 150);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 30)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 60)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 152);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddNPC3(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 151);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 60)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 90)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 153);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddNPC4(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 152);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 90)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 120)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 154);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddNPC5(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 153);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 120)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 150)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 155);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddNPC6(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 154);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 150)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 180)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 156);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddNPC7(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 155);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 180)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 210)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 157);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddNPC8(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 156);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 210)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 240)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 158);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddNPC9(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 157);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 240)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 270)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Next", GOSSIP_SENDER_MAIN, 159);
break;
}
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void AddNPC10(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Back", GOSSIP_SENDER_MAIN, 158);
QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
if (result)
{
const char* name;
uint32 cost, number;
uint16 go = 0;
do
{
if (go < 270)
{
go++;
continue;
}
Field* fields = result->Fetch();
name = fields[0].GetCString();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (go == 300) break;
std::stringstream buffer;
buffer << "Поставить / Put: " << "|cff177245" << name << "|r" << ". Цена / Price: " << "|cff242DFF" << cost << " опыта / experience" << "|r";
player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
go++;
}
while (result->NextRow());
}
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
void PlusRadius(Player* player)
{
uint32 guild = player->GetGuildId();
QueryResult result15 = CharacterDatabase.PQuery("SELECT * FROM guildhouses WHERE guild = %u", guild);
if (!result15)
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("У вас нет Дома Гильдии! You do not have the Guild House!");
return;
}
QueryResult result10 = CharacterDatabase.PQuery("SELECT radius FROM guildhouses WHERE guild = %u AND radius >= 80", guild);
if (result10)
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("У вас максимальный радиус ГХ! You have the maximum radius of the GH!");
return;
}
uint32 level_table, xp_table, xp;
QueryResult result2 = CharacterDatabase.PQuery("SELECT xp FROM guild_level WHERE guild = %u", guild);
if (result2)
{
Field *fields = result2->Fetch();
xp = fields[0].GetUInt32();
}
if (xp < 500)
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Недостаточно гильдейского опыта! Your guild not enough guild experience!");
return;
}
CharacterDatabase.PQuery("UPDATE guildhouses SET radius = radius+10 WHERE guild = %u", guild);
ChatHandler(player->GetSession()).PSendSysMessage("Радиус вашего дома гильдии расширен на 10 ярдов!");
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-500 WHERE guild = %u", guild);
UpdateLevel(player);
}
void DeleteAllGobjects(Player* player, Creature* creature, char const* code)
{
uint32 da = atoi(code);
if (da != 123) return;
uint32 lowguid;
ObjectGuid leader_guid = player->GetGUID();
QueryResult result = CharacterDatabase.PQuery("SELECT guid FROM guildhouse_spawned WHERE leader_guid = %u", leader_guid);
if (!result)
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Вы не поставили не единого объекта! You did not add a single object!");
return;
}
if (result)
{
do
{
Field* fields = result->Fetch();
lowguid = fields[0].GetUInt32();
if(!lowguid)
return;
GameObject* obj = NULL;
// by DB guid
if(GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid))
obj = ChatHandler(player->GetSession()).GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id);
if(!obj)
{
ChatHandler(player->GetSession()).PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
ChatHandler(player->GetSession()).SetSentErrorMessage(true);
return;
}
QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_go WHERE id = %u", obj->GetEntry());
if (res)
{
Field* ff = res->Fetch();
uint32 cost = ff[0].GetUInt32();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u",cost ,player->GetGuildId());
UpdateLevel(player);
}
ObjectGuid owner_guid = obj->GetOwnerGUID();
if(owner_guid)
if (Unit* owner = ObjectAccessor::GetUnit(*player, owner_guid))
owner->RemoveGameObject(obj, false);
obj->SetRespawnTime(0); // not save respawn time
obj->Delete();
obj->DeleteFromDB();
player->CLOSE_GOSSIP_MENU();
}
while (result->NextRow());
CharacterDatabase.PQuery("DELETE FROM guildhouse_spawned WHERE leader_guid = %u", leader_guid);
ChatHandler(player->GetSession()).PSendSysMessage("Объекты были успешно удалены! The objects have been successfully removed!");
}
}
void DeleteAllNPC(Player* player, Creature* creature, char const* code)
{
uint32 da = atoi(code);
if (da != 123) return;
uint32 lowguid;
uint32 leader_guid = player->GetGUID();
QueryResult result = CharacterDatabase.PQuery("SELECT guid FROM guildhouse_npc_spawned WHERE leader_guid = %u", leader_guid);
if (!result)
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Вы не поставили не единого НПС! You did not add a single NPC!");
return;
}
if (result)
{
do
{
Field* fields = result->Fetch();
lowguid = fields[0].GetUInt32();
if(!lowguid) return;
Creature* unit = NULL;
if(CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid))
unit = player->GetMap()->GetCreature(ObjectGuid(HighGuid::Unit, cr_data->id, lowguid));
QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_npc WHERE id = %u", unit->GetEntry());
if (res)
{
Field* ff = res->Fetch();
uint32 cost = ff[0].GetUInt32();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u",cost ,player->GetGuildId());
UpdateLevel(player);
}
if(!unit || unit->IsPet() || unit->IsTotem()) return;
// Delete the creature
unit->CombatStop();
unit->DeleteFromDB();
unit->AddObjectToRemoveList();
CharacterDatabase.PQuery("DELETE FROM guildhouse_npc_spawned WHERE guid = %u", lowguid);
ChatHandler(player->GetSession()).PSendSysMessage("НПС успешно удален! NPC successfully deleted!");
player->CLOSE_GOSSIP_MENU();
}
while (result->NextRow());
CharacterDatabase.PQuery("DELETE FROM guildhouse_npc_spawned WHERE leader_guid = %u", leader_guid);
ChatHandler(player->GetSession()).PSendSysMessage("НПС были успешно удалены! All NPC's has been removed successfully!");
}
}
void DeleteNPC(Player* player, Creature* creature)
{
Creature* unit = player->GetSelectedUnit()->ToCreature();
if(!unit || unit->IsPet() || unit->IsTotem() || unit->GetTypeId() == TYPEID_PLAYER) return;
uint32 leader_guid = player->GetGUID();
// lowguid = unit->GetGUID().GetCounter();
ObjectGuid::LowType lowguid = unit->GetSpawnId();
QueryResult result = CharacterDatabase.PQuery("SELECT guid, leader_guid FROM guildhouse_npc_spawned WHERE leader_guid = %u AND guid = %u", leader_guid, lowguid);
if (!result)
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("НПС не найден! NPC Not Found!", lowguid, leader_guid);
return;
}
QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_npc WHERE id = %u", unit->GetEntry());
if (res)
{
Field* ff = res->Fetch();
uint32 cost = ff[0].GetUInt32();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u",cost ,player->GetGuildId());
UpdateLevel(player);
}
// Delete the creature
unit->CombatStop();
unit->DeleteFromDB();
unit->AddObjectToRemoveList();
CharacterDatabase.PQuery("DELETE FROM guildhouse_npc_spawned WHERE guid = %u", lowguid);
ChatHandler(player->GetSession()).PSendSysMessage("НПС успешно удален! NPC successfully deleted!");
player->CLOSE_GOSSIP_MENU();
}
void ActivateGobject(Player* player, Creature* creature)
{
QueryResult result;
GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList();
std::ostringstream eventFilter;
eventFilter << " AND (eventEntry IS NULL ";
bool initString = true;
for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
{
if (initString)
{
eventFilter << "OR eventEntry IN (" << *itr;
initString = false;
}
else
eventFilter << ',' << *itr;
}
if (!initString)
eventFilter << "))";
else
eventFilter << ')';
result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, phaseMask, "
"(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject "
"LEFT OUTER JOIN game_event_gameobject on gameobject.guid = game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10",
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), eventFilter.str().c_str());
if (!result)
{
ChatHandler(player->GetSession()).PSendSysMessage("Поблизости не найдено объектов вашего Дома Гильдии! Nearby objects not found your guild houses!");
return;
}
bool found = false;
float x, y, z, o;
uint32 guidLow;
uint32 id, phase;
uint16 mapId;
do
{
Field* fields = result->Fetch();
guidLow = fields[0].GetUInt32();
id = fields[1].GetUInt32();
x = fields[2].GetFloat();
y = fields[3].GetFloat();
z = fields[4].GetFloat();
o = fields[5].GetFloat();
mapId = fields[6].GetUInt16();
phase = fields[7].GetUInt32();
QueryResult result15 = CharacterDatabase.PQuery("SELECT guid FROM guildhouse_spawned WHERE leader_guid = %u AND guid = %u", player->GetGUID().GetCounter(), guidLow);
if (result15) found = true;
} while (result->NextRow() && !found);
if (!found)
{
ChatHandler(player->GetSession()).PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
ChatHandler(player->GetSession()).SetSentErrorMessage(true);
return;
}
GameObjectTemplate const* objectInfo = sObjectMgr->GetGameObjectTemplate(id);
if (!objectInfo)
{
ChatHandler(player->GetSession()).PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, id);
ChatHandler(player->GetSession()).SetSentErrorMessage(true);
return;
}
//GameObject* target = player->GetMap()->GetGameObject(ObjectGuid(HighGuid::GameObject, id, guidLow));
GameObject* target = NULL;
// by DB guid
if(GameObjectData const* go_data = sObjectMgr->GetGOData(guidLow))
target = ChatHandler(player->GetSession()).GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, go_data->id);
if(!target)
{
ChatHandler(player->GetSession()).PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
ChatHandler(player->GetSession()).SetSentErrorMessage(true);
return;
}
if (target)
{
QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_go WHERE id = %u", target->GetEntry());
if (res)
{
Field* ff = res->Fetch();
uint32 cost = ff[0].GetUInt32();
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u",cost ,player->GetGuildId());
UpdateLevel(player);
}
target->SetRespawnTime(0);
target->Delete();
target->DeleteFromDB();
ChatHandler(player->GetSession()).PSendSysMessage("Объект успешно удален! The object was successfully deleted!");
CharacterDatabase.PQuery("DELETE FROM guildhouse_spawned WHERE guid = %u AND leader_guid = %u", guidLow, player->GetGUID().GetCounter());
}
player->CLOSE_GOSSIP_MENU();
}
void SpawnNPC(Player* player, Creature* creature, uint32 action)
{
uint32 leader_guid = player->GetGUID();
float x_p,y_p,z_p, radius;
float p_x = player->GetPositionX();
float p_y = player->GetPositionY();
float p_z = player->GetPositionZ();
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT id, number, cost FROM guildhouse_npc ORDER BY cost");
if (result)
{
uint32 number, id, cost, level, xp, level_table, xp_table;
do
{
Field* fields = result->Fetch();
id = fields[0].GetUInt32();
number = fields[1].GetUInt32();
cost = fields[2].GetUInt32();
if (action == number)
{
QueryResult result10 = CharacterDatabase.PQuery("SELECT x, y, z, radius FROM guildhouses WHERE guild = %u", guild);
if (result10)
{
Field* fields = result10->Fetch();
x_p = fields[0].GetFloat();
y_p = fields[1].GetFloat();
z_p = fields[2].GetFloat();
radius = fields[3].GetFloat();
}
if (!result10)
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("У вас нет гильдхауса! You not have Guild House!");
return;
}
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)
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Вы не в своем ГХ! You are not in your GH!");
return;
}
QueryResult result2 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result2)
{
Field* fields = result2->Fetch();
level = fields[0].GetUInt32();
xp = fields[1].GetUInt32();
}
if (cost > xp)
{
ChatHandler(player->GetSession()).PSendSysMessage("Недостаточно гильдейского опыта! Your guild not enough guild experience!");
return;
}
Player* chr = player;
float x = chr->GetPositionX();
float y = chr->GetPositionY();
float z = chr->GetPositionZ();
float o = chr->GetOrientation();
Map *map = chr->GetMap();
Creature* creature1 = new Creature;
if(!creature1->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, x, y, z, o))
//if(!creature1->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, x, y, z, o))
{
delete creature1;
return;
}
creature1->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
uint32 db_guid = creature1->GetSpawnId();
//ObjectGuid::LowType db_guid = creature->GetSpawnId();
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
creature1->LoadFromDB(db_guid, map);
map->AddToMap(creature1);
sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp - %u WHERE guild = %u", cost, guild);
CharacterDatabase.PQuery("REPLACE INTO guildhouse_npc_spawned (guid, leader_guid) VALUES (%u, %u)", db_guid, leader_guid);
UpdateLevel(player);
AddNPC1(player, creature);
break;
}
}
while (result->NextRow());
}
}
void Recall(Player* player)
{
player->TeleportTo(player->m_recallMap, player->m_recallX, player->m_recallY, player->m_recallZ, player->m_recallO);
}
void SpawnGobject(Player* player, Creature* creature, uint32 action)
{
ObjectGuid leader_guid = player->GetGUID();
float x_p,y_p,z_p, radius;
float p_x = player->GetPositionX();
float p_y = player->GetPositionY();
float p_z = player->GetPositionZ();
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT id, number, cost FROM guildhouse_go ORDER BY cost");
if (result)
{
uint32 number, id, cost, level, xp, level_table, xp_table;
do
{
Field* fields = result->Fetch();
id = fields[0].GetUInt32();
number = fields[1].GetUInt32();
cost = fields[2].GetUInt32();
if (action == number)
{
QueryResult result10 = CharacterDatabase.PQuery("SELECT x, y, z, radius FROM guildhouses WHERE guild = %u", guild);
if (result10)
{
Field* fields = result10->Fetch();
x_p = fields[0].GetFloat();
y_p = fields[1].GetFloat();
z_p = fields[2].GetFloat();
radius = fields[3].GetFloat();
}
if (!result10)
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("У вас нет гильдхауса! You not have Guild House!");
return;
}
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)
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Вы не в своем ГХ! You are not in your GH!");
return;
}
QueryResult result2 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
if (result2)
{
Field* fields = result2->Fetch();
level = fields[0].GetUInt32();
xp = fields[1].GetUInt32();
}
if (cost > xp)
{
ChatHandler(player->GetSession()).PSendSysMessage("Недостаточно гильдейского опыта! Your guild not enough guild experience!");
return;
}
const GameObjectTemplate *gInfo = sObjectMgr->GetGameObjectTemplate(id);
if(!gInfo)
{
ChatHandler(player->GetSession()).PSendSysMessage("Неверный ID! Invalid ID");
return;
}
Player* chr = player;
float x = float(chr->GetPositionX());
float y = float(chr->GetPositionY());
float z = float(chr->GetPositionZ());
float o = float(chr->GetOrientation());
Map *map = chr->GetMap();
GameObject* pGameObj = new GameObject;
uint32 db_lowGUID = map->GenerateLowGuid<HighGuid::GameObject>();
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))
{
delete pGameObj;
return;
}
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
db_lowGUID = pGameObj->GetSpawnId();
if(!pGameObj->LoadFromDB(db_lowGUID, map))
{
delete pGameObj;
return;
}
map->AddToMap(pGameObj);
sObjectMgr->AddGameobjectToGrid(db_lowGUID, sObjectMgr->GetGOData(db_lowGUID));
CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp - %u WHERE guild = %u", cost, guild);
CharacterDatabase.PQuery("REPLACE INTO guildhouse_spawned (guid, leader_guid) VALUES (%u, %u)", db_lowGUID, leader_guid);
QueryResult result3 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_xp_table ORDER BY xp DESC");
if (result3)
{
do
{
Field *fields = result3->Fetch();
level_table = fields[0].GetUInt32();
xp_table = fields[1].GetUInt32();
if ((xp - cost) < xp_table) continue;
else if ((xp - cost) < 100)
{
CharacterDatabase.PQuery("UPDATE guild_level SET level = 1 WHERE guild = %u", guild);
break;
}
else
{
CharacterDatabase.PQuery("UPDATE guild_level SET level = %u WHERE guild = %u", level_table, guild);
break;
}
}
while (result3->NextRow());
}
AddGobject1(player, creature);
break;
}
}
while (result->NextRow());
}
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
{
switch (action)
{
case 8:
AddNPC1(player, creature);
break;
case 1:
AddGobject1(player, creature);
break;
case 100:
AddGobject1(player, creature);
break;
case 101:
AddGobject2(player, creature);
break;
case 102:
AddGobject3(player, creature);
break;
case 103:
AddGobject4(player, creature);
break;
case 104:
AddGobject5(player, creature);
break;
case 105:
AddGobject6(player, creature);
break;
case 106:
AddGobject7(player, creature);
break;
case 107:
AddGobject8(player, creature);
break;
case 108:
AddGobject9(player, creature);
break;
case 109:
AddGobject10(player, creature);
break;
case 150:
AddNPC1(player, creature);
break;
case 151:
AddNPC2(player, creature);
break;
case 152:
AddNPC3(player, creature);
break;
case 153:
AddNPC4(player, creature);
break;
case 154:
AddNPC5(player, creature);
break;
case 155:
AddNPC6(player, creature);
break;
case 156:
AddNPC7(player, creature);
break;
case 157:
AddNPC8(player, creature);
break;
case 158:
AddNPC9(player, creature);
break;
case 159:
AddNPC10(player, creature);
break;
case 2:
ActivateGobject(player, creature);
break;
case 4:
player->CLOSE_GOSSIP_MENU();
break;
case 5:
PlusRadius(player);
player->CLOSE_GOSSIP_MENU();
break;
case 7:
TeleportToGH(player);
break;
case 9:
DeleteNPC(player, creature);
break;
case 15:
Recall(player);
break;
}
if (action >= 10000) SpawnNPC(player, creature, action);
else SpawnGobject(player, creature, action);
return true;
}
void TeleportToGH(Player* player)
{
uint32 guild = player->GetGuildId();
QueryResult result = CharacterDatabase.PQuery("SELECT x, y, z, map, radius FROM guildhouses WHERE guild = %u", guild);
if (result)
{
float x,y,z,radius;
float p_x = player->GetPositionX();
float p_y = player->GetPositionY();
float p_z = player->GetPositionZ();
uint32 map;
std::string name;
Field* fields = result->Fetch();
x = fields[0].GetFloat();
y = fields[1].GetFloat();
z = fields[2].GetFloat();
map = fields[3].GetUInt32();
radius = fields[4].GetFloat();
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)
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("Вы не в своем ГХ! You are not in your GH!");
return;
}
player->TeleportTo(map,x,y,z,0.0f,0U);
}
}
bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code)
{
switch(action)
{
case 3:
DeleteAllGobjects(player, creature, code);
break;
case 11:
DeleteAllNPC(player, creature, code);
break;
}
return true;
}
};
class npc_guildspell : public CreatureScript
{
public:
npc_guildspell() : CreatureScript("npc_guildspell") { }
uint8 IsSpell;
bool OnGossipHello(Player* player, Creature* creature)
{
player->PlayerTalkClass->ClearMenus();
ChatHandler(player->GetSession()).PSendSysMessage("Это работает только для гильд мастера.");
ChatHandler(player->GetSession()).PSendSysMessage("This only works for the guild master.");
if (player->GetRankFromDB(player->GetGUID()) == 0 && player->GetGuildId())
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Купить гильдейское заклинание / Buy spell for guild", GOSSIP_SENDER_MAIN, 99000);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Купить гильдейское звание / Buy title for guild", GOSSIP_SENDER_MAIN, 99002);
}
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Exit", GOSSIP_SENDER_MAIN, 99001);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
return true;
}
void BuySpellOrTitle(Player* player, Creature* creature, uint8 isSpell)
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Back:", GOSSIP_SENDER_MAIN, 99005);
uint32 spell;
uint32 cost;
uint32 number;
const char* name;
QueryResult result = CharacterDatabase.PQuery("SELECT spellortitle, cost, number FROM guild_level_spell WHERE isSpell = %u", isSpell);
if (result)
{
do
{
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (isSpell == 1)
{
if (player->HasSpell(spell))
continue;
const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
name = (spellEntry->SpellName[0]);
}
else
{
const CharTitlesEntry* titleEntry = sCharTitlesStore.LookupEntry(spell);
if (player->HasTitle(titleEntry))
continue;
name = (const char*)titleEntry->nameMale[0];
}
std::stringstream buffer;
buffer << "|cff084E13" << name << "|r" << ". Стоимость : " << "|cFF1E90FF" << cost << " PvP Token" << "|r";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
}
while (result->NextRow());
IsSpell = isSpell;
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
}
}
void SelectSpellOrTitle(Player* player, Creature* creature, uint32 action)
{
uint32 spell;
uint32 cost;
uint32 number;
uint32 guild = player->GetGuildId();
uint32 guid;
QueryResult result = CharacterDatabase.PQuery("SELECT spellortitle, cost, number FROM guild_level_spell WHERE isSpell = %u AND number = %u", IsSpell, action);
if (result)
{
Field* fields = result->Fetch();
spell = fields[0].GetUInt32();
cost = fields[1].GetUInt32();
number = fields[2].GetUInt32();
if (number == action)
{
// learn spell
QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
if (result2)
{
if (!player->HasItemCount(38186, cost))
{
player->CLOSE_GOSSIP_MENU();
ChatHandler(player->GetSession()).PSendSysMessage("You not have |Hitem:38186:0:0:0:0:0:0:0:0|h|cfffcedbb[PvP Token]|r|hx%u!",cost);
return;
}
do
{
Field* fields = result2->Fetch();
guid = fields[0].GetUInt64();
if (Player* onlinePlayer = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, guid)))
{
if (IsSpell == 1) onlinePlayer->LearnSpell(spell, false);
else onlinePlayer->SetTitle(sCharTitlesStore.LookupEntry(spell));
}
CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spellortitle, isSpell) VALUES (%u, %u, %u)", guild, spell, IsSpell);
}
while (result2->NextRow());
}
player->DestroyItemCount(38186, cost, true);
// learn spell
player->CLOSE_GOSSIP_MENU();
if (IsSpell == 1)
ChatHandler(player->GetSession()).PSendSysMessage("Гильдейское заклинание успешно куплено! Теперь каждый новый участник гильдии автоматически выучит его в книгу заклинаний. Guild spell successfully bought! Now every new member of the guild will automatically learn it in a book of spells.");
else
ChatHandler(player->GetSession()).PSendSysMessage("Гильдейское звание успешно куплено! Теперь каждый новый участник гильдии автоматически получит это звание. Guild title successfully bought! Now every new member of the guild will automatically receive the title.");
}
}
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
{
switch(action)
{
case 99000:
BuySpellOrTitle(player, creature, 1);
break;
case 99002:
BuySpellOrTitle(player, creature, 0);
break;
case 99001:
player->CLOSE_GOSSIP_MENU();
break;
case 99005:
OnGossipHello(player, creature);
break;
}
if (action < 5000) SelectSpellOrTitle(player, creature, action);
return true;
}
};
class Login_spellguild : public PlayerScript
{
public:
Login_spellguild() : PlayerScript("Login_spellguild") { }
void OnLogin(Player* player/*, bool firstLogin*/)
{
uint32 guild = player->GetGuildId();
if (!guild) return;
QueryResult result = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_learn_spell WHERE guild = %u And isSpell = 1", guild);
if (result)
{
do
{
Field* fields = result->Fetch();
uint32 spell = fields[0].GetUInt32();
if (!player->HasSpell(spell)) player->LearnSpell(spell, false);
}
while (result->NextRow());
}
else
{
QueryResult result2 = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_level_spell WHERE isSpell = 1");
if (result2)
{
do {
Field* fields = result2->Fetch();
uint32 Spell = fields[0].GetUInt32();
if (player->HasSpell(Spell)) player->RemoveSpell(Spell);
}
while (result2->NextRow());
}
}
QueryResult result3 = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_learn_spell WHERE guild = %u And isSpell = 0", guild);
if (result3)
{
do
{
Field* fields = result3->Fetch();
uint32 title = fields[0].GetUInt32();
if (!player->HasTitle(sCharTitlesStore.LookupEntry(title))) player->SetTitle(sCharTitlesStore.LookupEntry(title));
}
while (result3->NextRow());
}
else
{
QueryResult result4 = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_level_spell WHERE isSpell = 0");
if (result4)
{
do {
Field* fields = result4->Fetch();
uint32 title = fields[0].GetUInt32();
if (player->HasTitle(sCharTitlesStore.LookupEntry(title)))
{
player->SetTitle(sCharTitlesStore.LookupEntry(title), true);
if (!player->HasTitle(player->GetInt32Value(PLAYER_CHOSEN_TITLE))) player->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
}
}
while (result4->NextRow());
}
}
}
};
class guildMasterChat : public PlayerScript
{
public:
guildMasterChat() : PlayerScript("guildMasterChat") {}
void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Guild* guild)
{
if (player->GetRank() == 0) msg = "|cFFFF0000[Guild Master]|r " + msg + "|r";
if (player->GetRank() == 1) msg = "|cFF00FF91[Officier]|r " + msg + "|r";
}
};