Jump to content

C++ redemption code SD2


Recommended Posts

Posted

Hello i have error with Redemption coder in SD2

Code is :

#include "precompiled.h"

typedef DatabaseMysql DatabaseType;
extern DatabaseType WorldDatabase;
extern DatabaseType CharacterDatabase;
extern DatabaseType loginDatabase;


bool GossipHello_npc_redemption(Player* pPlayer, Creature* pCreature)
{
   pPlayer->ADD_GOSSIP_ITEM_EXTENDED(0, "Enter Code - Vloz Kod", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true);
   pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Nashledanou", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);

   pPlayer->PlayerTalkClass->SendGossipMenu(1, pCreature->GetGUID());

   return true;
}

bool GossipSelect_npc_redemption(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)
{
   if (uiAction == GOSSIP_ACTION_INFO_DEF+2)
   {
       pPlayer->CLOSE_GOSSIP_MENU();
   }

   return true;
}

bool GiveItem(uint32 itemId, int32 count, Creature* pCreature, Player* pPlayer) 
{     
   uint32 noSpaceForCount = 0; 
   ItemPosCountVec dest; 
   uint8 msg = pPlayer->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, count &noSpaceForCount ); 

   if( msg != EQUIP_ERR_OK )      
       count -= noSpaceForCount; 

   if( count == 0 || dest.empty())   
   { 
       pCreature->MonsterWhisper("Nemuzes obdrzet Item", pPlayer->GetGUID()); 
               return false;
   } 

   Item* item = pPlayer->StoreNewItem( dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); 

   if(count > 0 && item) 
   { 
       pPlayer->SendNewItem(item,count,false,true); 
   } 

   if(noSpaceForCount > 0) 
       {
       pCreature->MonsterWhisper("Nemuzes obdrzet Item", pPlayer->GetGUID()); 
               return false;
       }
       return true;
}  


bool GossipSelectWithCode_npc_redemption(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction, const char* sCode)
{
   if (uiSender == GOSSIP_SENDER_MAIN)
   {
       switch (uiAction)
       {
                       case GOSSIP_ACTION_INFO_DEF+1:
           QueryResult* result;
                       result = WorldDatabase.PQuery("SELECT `item`, `amount`, `uses` FROM `redemption_codes` WHERE `code` = %s",
                       //                                       0        1        2      
                                       sCode);

                       if (result)
                       {
                               do 
                               {
                                       Field *fields = result->Fetch();
                                       if(GiveItem(fields[0].GetInt32(), fields[1].GetInt32(), pCreature, pPlayer))
                                       {
                                               if (fields[2].GetInt32() > 1)
                                                       WorldDatabase.PExecute("UPDATE `redemption_codes` SET `uses` = %u WHERE `code` = %s AND `item` = %u", fields[2].GetInt32() - 1, sCode, fields[0].GetInt32());
                                               else
                                                       WorldDatabase.PExecute("DELETE FROM `redemption_codes` WHERE `code` = %s AND `item` = %u", sCode, fields[0].GetInt32());
                                       }

                               }   while (result->NextRow()); /* \\n */ delete result;

                               return true;
                       }
                       else
                       {
                               pCreature->MonsterWhisper("Spatny kod.", pPlayer->GetGUID());
                               return true;
                       }
               }
   }

   return false;
}

void AddSC_npc_redemption()
{
   Script* newscript;

   newscript = new Script;
   newscript->Name = "npc_redemption";
   newscript->pGossipHello = &GossipHello_npc_redemption;
   newscript->pGossipSelect = &GossipSelect_npc_redemption;
   newscript->pGossipSelectWithCode = &GossipSelectWithCode_npc_redemption;
   newscript->RegisterSelf();
}

Error is :

1>redempt-coder.obj : error LNK2001: unresolved external symbol "class DatabaseMysql WorldDatabase" (?WorldDatabase@@3VDatabaseMysql@@A)
1>..\\..\\..\\..\\bin\\win32_release/MaNGOSScript.dll : fatal error LNK1120: 1 unresolved externals

Rev is : 9839

OS: Windows 7

×
×
  • 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