View Full Version : [SOLVED] [C++ Script] Error

11-21-2013, 01:37 PM
Hello Emudev's

i had this script on my pc for some time now and today i tried to compile it but i get this Error

2>..\..\..\..\Z_TriCore\TrinityCore\src\server\scrip ts\Custom\VoterShop.cpp(63) : error C2065: 'dp' : undeclared identifier
2>..\..\..\..\Z_TriCore\TrinityCore\src\server\scrip ts\Custom\VoterShop.cpp(70) : error C2065: 'dp' : undeclared identifier
2>..\..\..\..\Z_TriCore\TrinityCore\src\server\scrip ts\Custom\VoterShop.cpp(79) : error C2065: 'dp' : undeclared identifier
2>..\..\..\..\Z_TriCore\TrinityCore\src\server\scrip ts\Custom\VoterShop.cpp(80) : error C2065: 'vp' : undeclared identifier

and i now its a small Fix but i don't have any c++ Skills what so ever so i hope anyone could help me out here :D

the Script Pastebin (http://pastebin.com/BJgxRQ6A)

11-21-2013, 01:46 PM
define DP and VP somewhere outside the scope of OnGossipSelect.

11-21-2013, 04:10 PM
If i do so , i get a bunch of Errors -_-

11-21-2013, 04:22 PM
"undeclared identifier" means that the variable doesn't exist in that function. What you can do is define it in your "example_gossip_codebox" class like:

uint32 dp;
uint32 vp;

But it isn't needed considering the corrections I made to the script.

I corrected everything. I removed the headers because they aren't needed, corrected indentation, fixed up code, etc. HOWEVER, the script won't work regardless considering you aren't using 'extended menu' to get to the other menus. Honestly, you aren't using code, so everything should be used in OnGossipSelect. I corrected that. Anyway, here's the script:

class example_gossip_codebox : public CreatureScript
example_gossip_codebox() : CreatureScript("example_gossip_codebox") { }

bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
player->ADD_GOSSIP_ITEM(0, "Weapons", GOSSIP_SENDER_MAIN, 1);
player->ADD_GOSSIP_ITEM(0, "Item Sets", GOSSIP_SENDER_MAIN, 2);
player->PlayerTalkClass->SendGossipMenu(907, creature->GetGUID());
return true;

bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE

QueryResult select = LoginDatabase.PQuery("SELECT dp, vp FROM account WHERE id = '%u'", player->GetSession()->GetAccountId());
player->GetSession()->SendAreaTriggerMessage("Internal error!");
return false;

Field* fields = select->Fetch();
uint32 dp = fields[0].GetUInt32();
uint32 vp = fields[1].GetUInt32();

if (action == 1)
if (dp < 1)
player->GetSession()->SendAreaTriggerMessage("You don't have the required points.");
LoginDatabase.PExecute("UPDATE account SET dp = '%u' -1 WHERE id = '%u'", dp, player->GetSession()->GetAccountId()); // DP Exchange 1
player->AddItem(999, 1);
else if (action == 999)
player->GetSession()->SendAreaTriggerMessage("Donor Points: %u", dp);
player->GetSession()->SendAreaTriggerMessage("Voter Points: %u", vp);

return true;

void AddSC_example_gossip_codebox()
new example_gossip_codebox();