Problems with my C++ script menu

Shout-Out

User Tag List

Results 1 to 6 of 6
  1. #1
    Sylex's Avatar Active Member
    Reputation
    101
    Join Date
    May 2007
    Posts
    141
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with my C++ script

    Here are the files:


    SlayerNPC.cpp
    Code:
    #include "StdAfx.h"
    #include "Setup.h"
    
    #define MARKID 90909 //ID for the mark
    #define TOKENID 56462 //ID for the token.
    #define TRADERATE 5 //This much marks = 1 token
    #define SUCMSG "Enjoy your prize" //Message when user gets his prize
    #define TOKMSG "You don't have enough tokens to buy this"
    #define MRKMSG "You don't have enough marks to get a token"
    #define NPCID 113 //ID of the vendor NPC
    
    class SCRIPT_DECL Coin : public GossipScript
    {
    public:
    void GossipHello(Object * pObject, Player* Plr, bool AutoSend);
    void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code);
    void GossipEnd(Object * pObject, Player* Plr);
    void Destroy()
    {
    delete this;
    }
    };
    
    void Coin::GossipHello(Object * pObject, Player* Plr, bool AutoSend)
    {
    //-----------------------------
    //Setup Main Categories/Items
    //-----------------------------
    GossipMenu *Menu;
    objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
    Menu->AddItem(0, "Weapons", 1);
    Menu->AddItem(0, "Armor", 2);
    Menu->AddItem(0, "Other", 3);
    
    if(AutoSend)
    Menu->SendTo(Plr);
    }
    
    bool TradeForCoins(uint32 ItemId, uint8 reqAmt, Player* Plr)
    {
    if(Plr->GetItemInterface()->GetItemCount(TOKENID, false)>=reqAmt) {
    //remove tokens
    Plr->GetItemInterface()->RemoveItemAmt(TOKENID, reqAmt);
    //add item
    Item * pItem = objmgr.CreateItem(ItemId, Plr);
    Plr->GetItemInterface()->AddItemToFreeSlot(pItem);
    return true;
    }else{
    //not enough tokens
    return false;
    }
    }
    
    bool TradeMarks(Player* Plr)
    {
    if(Plr->GetItemInterface()->GetItemCount(MARKID,false)>=TRADERATE){
    //remove marks
    Plr->GetItemInterface()->RemoveItemAmt(MARKID, TRADERATE);
    //add tokens
    Item * pItem = objmgr.CreateItem(TOKENID,Plr);
    Plr->GetItemInterface()->AddItemToFreeSlot(pItem);
    return true;
    }else{
    //not enough marks to buy a token
    return false;
    }
    }
    bool TradeSet(uint32 ItemIdStart, uint32 ItemIdEnd, uint8 reqAmt, Player* Plr)
    {
    //Assuming ItemIdStart is lower than ItemIdEnd
    //Double check your code or else infinite loop will occur
    //And we certainly don't want that.
    if(Plr->GetItemInterface()->GetItemCount(TOKENID, false) >= reqAmt){
    //Remove coin
    Plr->GetItemInterface()->RemoveItemAmt(TOKENID, reqAmt);
    //Add set
    for(int i=ItemIdStart; i<=ItemIdEnd; i++){
    Item * pItem = objmgr.CreateItem(i, Plr);
    Plr->GetItemInterface()->AddItemToFreeSlot(pItem);
    }
    return true;
    }else{
    //Not enough tokens
    return false;
    }
    }
    
    void Coin::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
    {
    Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL;
    if(pCreature==NULL)
    return;
    
    GossipMenu * Menu;
    switch(IntId)
    {
    case 0: // Return to start
    GossipHello(pCreature, Plr, true);
    break;
    
    case 1: //Weapons
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(5, "Galacios, Axe of the Frostwolf", 10);
    Menu->AddItem(5, "The Sword of a Thousand Truths", 11);
    Menu->AddItem(5, "Menethil`s Charge", 12);
    Menu->AddItem(5, "Frostfathom", 13);
    Menu->AddItem(5, "Frostfathom Arrow", 14);
    Menu->AddItem(5, "Gorehowl, Greataxe of Hellscream", 15);
    Menu->AddItem(5, "Staff of the Burning Sun", 16);
    Menu->AddItem(0, "[Back]", 99);
    Menu->SendTo(Plr);
    break;
    
    case 2: //Armor
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(5, "", 20);
    Menu->AddItem(5, "", 21);
    Menu->AddItem(0, "[Back]", 99);
    Menu->SendTo(Plr);
    break;
    
    case 3: //Other
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(5, "Flying Carpet", 50);
    Menu->AddItem(5, "Scary Murloc Mask", 51);
    Menu->AddItem(0, "[Back]", 99);
    Menu->SendTo(Plr);
    break;
    
    case 10: //Item 1
    if (TradeForCoins(49750, 750, Plr))
    {Plr->BroadcastMessage(SUCMSG);}
    else {Plr->BroadcastMessage(TOKMSG);}
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(0, "[Back]", 1);
    Menu->SendTo(Plr);
    break;
    
    case 11: //Item 2
    if (TradeForCoins(49751, 450, Plr))
    {Plr->BroadcastMessage(SUCMSG);}
    else {Plr->BroadcastMessage(TOKMSG);}
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(0, "[Back]", 1);
    Menu->SendTo(Plr);
    break;
    
    case 12:
    if (TradeForCoins(49752, 750, Plr))
    {Plr->BroadcastMessage(SUCMSG);}
    else {Plr->BroadcastMessage(TOKMSG);}
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(0, "[Back]", 1);
    Menu->SendTo(Plr);
    break;
    
    case 13:
    if (TradeForCoins(49753, 550, Plr))
    {Plr->BroadcastMessage(SUCMSG);}
    else {Plr->BroadcastMessage(TOKMSG);}
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(0, "[Back]", 1);
    Menu->SendTo(Plr);
    break;
    
    case 14: 
    if (TradeForCoins(49755, 1, Plr))
    {Plr->BroadcastMessage(SUCMSG);}
    else {Plr->BroadcastMessage(TOKMSG);}
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(0, "[Back]", 1);
    Menu->SendTo(Plr);
    break;
    
    case 15: 
    if (TradeForCoins(49754, 650, Plr))
    {Plr->BroadcastMessage(SUCMSG);}
    else {Plr->BroadcastMessage(TOKMSG);}
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(0, "[Back]", 1);
    Menu->SendTo(Plr);
    break;
    
    case 16: 
    if (TradeForCoins(117001, 650, Plr))
    {Plr->BroadcastMessage(SUCMSG);}
    else {Plr->BroadcastMessage(TOKMSG);}
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(0, "[Back]", 1);
    Menu->SendTo(Plr);
    break;
    
    case 50: //OTHER
    if (TradeForCoins(23, 1250, Plr))
    {Plr->BroadcastMessage(SUCMSG);}
    else {Plr->BroadcastMessage(TOKMSG);}
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(0, "[Back]", 1);
    Menu->SendTo(Plr);
    break;
    
    case 51: //OTHER
    if (TradeForCoins(112013, 350, Plr))
    {Plr->BroadcastMessage(SUCMSG);}
    else {Plr->BroadcastMessage(TOKMSG);}
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(0, "[Back]", 1);
    Menu->SendTo(Plr);
    break;
    
    
    case 98: //Convert Marks to Token
    if (TradeMarks(Plr))
    {Plr->BroadcastMessage("Have fun with your token!");}
    else {Plr->BroadcastMessage(MRKMSG);}
    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
    Menu->AddItem(0, "[Back]", 1);
    Menu->SendTo(Plr);
    break;
    
    case 99: //main menu
    objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
    Menu->AddItem(0, "Weapons", 1);
    Menu->AddItem(0, "Armor", 2);
    Menu->AddItem(0, "Other", 3);
    Menu->SendTo(Plr);
    break;
    } //end switch
    } //end void
    
    void Coin::GossipEnd(Object * pObject, Player* Plr)
    {
    GossipScript::GossipEnd(pObject, Plr);
    }
    
    void SetupCoin(ScriptMgr * mgr)
    {
    GossipScript * gs = (GossipScript*) new Coin();
    
    mgr->register_gossip_script(NPCID, gs);
    }
    Setup.cpp
    Code:
    #include "StdAfx.h"
    #include "Setup.h"
    
    extern "C" SCRIPT_DECL uint32 _exp_get_version()
    {
        return MAKE_SCRIPT_VERSION(SCRIPTLIB_VERSION_MAJOR, SCRIPTLIB_VERSION_MINOR);
    }
    
    extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
    {
        SetupSlayerNPC(mgr);
    }
    
    #ifdef WIN32 
    
    extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
    {
    return SCRIPT_TYPE_MISC;
    }
    
    #endif
    Setup.h
    Code:
    #ifndef INSTANCE_SCRIPTS_SETUP_H
    #define INSTANCE_SCRIPTS_SETUP_H
    
    void SetupSlayerNPC(ScriptMgr * mgr);
    
    #endif
    I am getting these following errors:

    -SlayerNPC error LNK2019: unresolved external symbol "void __cdecl SetupSlayerNPC(class ScriptMgr *)" (?SetupSlayerNPC@@YAXPAVScriptMgr@@@Z) referenced in function __exp_script_register

    -SlayerNPC fatal error LNK1120: 1 unresolved externals

    Thanks for the help!



    Problems with my C++ script
  2. #2
    Pragma's Avatar Contributor
    Reputation
    261
    Join Date
    Feb 2007
    Posts
    630
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make setup.cpp and setup.h like this:
    setup.cpp
    Code:
    #include "StdAfx.h"
    #include "Setup.h"
    
    extern "C" SCRIPT_DECL uint32 _exp_get_version()
    {
        return MAKE_SCRIPT_VERSION(SCRIPTLIB_VERSION_MAJOR, SCRIPTLIB_VERSION_MINOR);
    }
    
    extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
    {
        SetupCoin(mgr);
    }
    
    #ifdef WIN32 
    
    extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
    {
    return SCRIPT_TYPE_MISC;
    }
    
    #endif
    setup.h
    Code:
    #ifndef INSTANCE_SCRIPTS_SETUP_H
    #define INSTANCE_SCRIPTS_SETUP_H
    
    void SetupCoin(ScriptMgr * mgr);
    
    #endif


  3. #3
    Sylex's Avatar Active Member
    Reputation
    101
    Join Date
    May 2007
    Posts
    141
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    YES! Thanks it worked! +rep x5

  4. #4
    SectorSeven's Avatar Banned
    Reputation
    444
    Join Date
    Oct 2007
    Posts
    1,948
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lol you cant do +5 rep

  5. #5
    Sylex's Avatar Active Member
    Reputation
    101
    Join Date
    May 2007
    Posts
    141
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shh, I can do it over a 5 day radius =p

  6. #6
    Tinky's Avatar Contributor
    Reputation
    176
    Join Date
    Dec 2006
    Posts
    855
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but you have to spread it first

Similar Threads

  1. Problem with online players script and vote system
    By Obly in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 09-29-2010, 03:16 AM
  2. [ArcEmu] Problem with C++ House Script!
    By BloodgultchWoW in forum WoW EMU Questions & Requests
    Replies: 9
    Last Post: 03-11-2010, 10:43 PM
  3. Problem with my C++ script
    By XxCyanidexX in forum WoW EMU Questions & Requests
    Replies: 18
    Last Post: 04-07-2009, 12:05 AM
  4. [Help Plzzzz] LUA Problem with KJ Script
    By Arthas117 in forum WoW EMU Questions & Requests
    Replies: 3
    Last Post: 08-16-2008, 05:25 PM
  5. Problem with lua boss script
    By nickeg in forum WoW EMU Questions & Requests
    Replies: 13
    Last Post: 08-16-2008, 09:22 AM
All times are GMT -5. The time now is 05:06 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search