PDA

View Full Version : TrinityCore 3.3.5 Fetch from specific Field CPP



zhier
09-11-2016, 06:28 AM
Hi, i wanna get the value from an specific field when I'm doing a SQL request.

This is my code:



int itemsBD = 5;
QueryResult id_items = WorldDatabase.PQuery("SELECT entry_item,nombre_item,valor_en_tickets FROM gm_recompensa");

int64 id_itemsDB = 0;
int64 valor_BD = 0;
std::string nombre_itemDB = "";

if(id_items){

for(int i = 0; i < itemsBD; ++i){
id_itemsDB = id_items->Fetch()[0].GetInt64();
nombre_itemDB = id_items->Fetch()[1].GetString();
valor_BD = id_items->Fetch()[2].GetInt64();

player->ADD_GOSSIP_ITEM(10,std::string(nombre_itemDB) + std::string(" [") + std::to_string(valor_BD) + std::string(" tickets]"), id_itemsDB, 500);
}
}

At this moment, the Gossip Menu shows me 3 times (I have 3 rows) the first row.

Ex:

Hello [0 tickets]
Hello [0 tickets]
Hello [0 tickets]

But in my DB there are something like this:

Hello [0 tickets]
Whats [10 tickets]
Yo [3 tickets]

How can I add to the gossip menu 1 by 1?

thanks