bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override { player->PlayerTalkClass->ClearMenus(); Battleground* bg = player->GetBattleground(); if (!bg) return true; BattlegroundVoteOption const* bgvote = sBattlegroundMgr->GetVoteOptionById(action); if (!bgvote) return false; if (bgvote->phase != bg->GetVotePhase()) creature->Whisper("The voting period for that vote has closed. Please cast a new vote.", LANG_UNIVERSAL, player); else if (!bg->HasVoted(player->GetGUID())) bg->CastVote(player->GetGUID(), action); player->CLOSE_GOSSIP_MENU(); return true; };
void CreateVoteOptionsList(Player* player) { Battleground* bg = player->GetBattleground(); if (!bg) return; uint8 id; uint8 phase; int8 mode; std::string name; BattlegroundVoteOptionMap bgvotemap = sBattlegroundMgr->GetVoteOptions(); for (BattlegroundVoteOptionMap::const_iterator itr = bgvotemap.begin(); itr != bgvotemap.end(); ++itr) { phase = itr->second.phase; mode = itr->second.mode; if (phase != bg->GetVotePhase()) continue; if (mode != bg->GetMode() && mode != -1) continue; id = itr->first; name = itr->second.name; player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, name, 100, id); } }