/********************************************************
Possible icons:
0, //white chat bubble
1, //brown bag
2, //flight
3, //book
4, //interaction wheel
5, //interaction wheel
6, //brown bag with yellow dot
7, //white chat bubble with black dots
8, //tabard
9, //two swords
10, //yellow dot
Example Gossip Option: {iconID (see above), "title name", honorable_kills_required (set to whatever you require the player to have to get this rank), titleID (from database)}
***********************************************************/
// npc_text ID
Greetings_A = 1,
Greetings_H = 2,
};
#define ERROR_HASTITLE "|cffff0000You already have this title|r" // Error message that shows up when a player already has the title
#define ERROR_CASH "|cffff0000You don't have enough honorable kills|r" // Error message if player does not have enough honorable kills
class Title_gossip_codebox : public CreatureScript
{
public:
Title_gossip_codebox()
: CreatureScript("Title_gossip_codebox")
{
}
bool OnGossipHello(Player* pPlayer, Creature* pCreature)
{
uint32 txt = Greetings_A;
uint32 i = 0;
uint32 m = Amount/2;
if(pPlayer->GetTeam() == HORDE)
{
txt = Greetings_H;
i = Amount/2;
m = Amount;
}
for (i; i<m; i++)
{
std::ostringstream ss;
ss << Titles.name << " - " << Titles.HK << " HKs";
std::string showcoolshit = ss.str();
ss.str(" ");
ss.clear();
ss << "Are you sure? You will be granted the title: " << Titles.name;
std::string showcoolshit2 = ss.str();
// ADD_GOSSIP_ITEM_EXTENDED Parameters: (icon, label, GOSSIP_SENDER_MAIN (Sender), Title ID ? (action - Sends info to OnGossipSelect), popup, coppercost, code (codebox))
pPlayer->ADD_GOSSIP_ITEM_EXTENDED(Titles.icon, showcoolshit.c_str(), GOSSIP_SENDER_MAIN, i, showcoolshit2, 0, false);
}
pPlayer->PlayerTalkClass->SendGossipMenu(txt, pCreature->GetGUID());
return true;
}
bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 i)
{
pPlayer->PlayerTalkClass->ClearMenus(); // clear the menu
if (CharTitlesEntry const* Title = sCharTitlesStore.LookupEntry(Titles.titleID)) // Get title
{
if(pPlayer->HasTitle(Title)) // If has title
pPlayer->GetSession()->SendAreaTriggerMessage(ERROR_HASTITLE);
else if(Titles.HK > pPlayer->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS)) // If doesnt have enough honored kills
pPlayer->GetSession()->SendAreaTriggerMessage(ERROR_CASH);
else
{
pPlayer->SetTitle(Title);
pPlayer->SaveToDB();
}
OnGossipHello(pPlayer, pCreature);
}
return true;
}
};
void AddSC_Title_gossip_codebox()
{
new Title_gossip_codebox();
}