Jump to content

[Help] For a scripts c++ comparison with database ...


Guest Morphau

Recommended Posts

Hello all, I want make a "simple scripts" who can verify it's a tester have allready one or more level 80 in his account ...

I am not a good of scripts and the gestion with the database it's hard for me ^^

Please can i have help ?

I have one error for the comparison of the sql result:

../../../../src/bindings/ScriptDev2/scripts/custom/npc_level_reroll.cpp: In function 'bool GossipSelect_ok_npc_level_reroll(Player*, Cre   onst char*)':
../../../../src/bindings/ScriptDev2/scripts/custom/npc_level_reroll.cpp:64: error: ISO C++ forbids comparison between pointer and intege

How do make this part properly ? :

          QueryResult *result;
          result = CharactersDatabase.PQuery("SELECT count(*) as guid from characters WHERE account = '%u' and level = '80'", pPlayer->GetSession()->GetAccountId());
          Field *Fields = result->Fetch();
          int32 count = Fields[0].GetUInt32(); //Get if have a level 80 from database

          if (result == 1) // test if have a level 80 in the account of player, HERE YES
          {

:)

Link to comment
Share on other sites

i think it should be

QueryResult *result = CharactersDatabase.PQuery("SELECT count(*) FROM characters WHERE account = %u AND level = 80", pPlayer->GetSession()->GetAccountId());
          if (result) {
          Field *Fields = result->Fetch();
          uint32 count = Fields[0].GetUInt32(); //Get if have a level 80 from database

          if (count >= 1) // test if have a level 80 in the account of player, HERE YES
          {

Link to comment
Share on other sites

Thanks it's work it at the compilation but what it's the good : extern DatabaseMysql XXXXXXXXXXXXDatabase; for the characters database please ?

Thanks :)

you want to know why you have to make the exern DatabaseMysql CharactersDatabase; ?

the definition of the variable isn't make in the SD2 scope and to use you have to import it.

( i think its not correct definition but i hobe understandable for beginners)

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use