Raised This Month: $51 Target: $400
 12% 

Help! Link Errors!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
InsidiousGnomes
Member
Join Date: Nov 2008
Old 11-27-2008 , 12:02   Help! Link Errors!
Reply With Quote #1

I'm trying to write an extension that hooks the OnTakeDamage event for CS: S and gives more damage for certain weapons for certain players. I've tried to do this with a plugin but it seems that there is no other way to do it other than an extension since both the hacks extension and the hooker extension won't do it. I successfully hooked the event but when I try to write code to check the weapon I get link errors that I'm having a real problem resolving.



Code:
int MyExtension::OnTakeDamage(const CTakeDamageInfo &info)
{
     int AttackerIndex = engine->IndexOfEdict(serverents->BaseEntityToEdict(info.GetAttacker()));

}
This code above compiles OK, but then doesn't link. Here's the link error:
Code:
error LNK2001: unresolved external symbol "class CBaseEntityList * g_pEntityList" (?g_pEntityList@@3PAVCBaseEntityList@@A)
Here's the other piece of code that's causing link errors:
Code:
void MyDelagate::OnDoDamage(CTakeDamageInfo& info){
    
    int client = engine->IndexOfEdict(serverents->BaseEntityToEdict(info.GetAttacker()));
    CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
    if (!pPlayer)
    {
        g_pSM->LogMessage(g_VAH.getIExtension(), "Client index %d is invalid", client);
        return;
    } else if (!pPlayer->IsInGame()) {
        g_pSM->LogMessage(g_VAH.getIExtension(), "Client %d is not in game", client);
        return;
    }

    IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
    if (!pInfo)
    {
        g_pSM->LogMessage(g_VAH.getIExtension(), "IPlayerInfo not supported by game");
        return;
    }

    const char *weapon = pInfo->GetWeaponName();
    g_pSM->LogMessage(g_VAH.getIExtension(), "weapon is %s", weapon);
    if (strcmp(weapon, "weapon_knife") == 0){
        info.SetDamage(1000);
    }
}
And here are the link errors caused by the above code:

Code:
error LNK2001: unresolved external symbol "class CBaseEntityList * g_pEntityList" 
error LNK2019: unresolved external symbol "public: class CPlayer * __thiscall PlayerManager::GetPlayerByIndex(int)const " (?GetPlayerByIndex@PlayerManager@@QBEPAVCPlayer@@H@Z) referenced in function "public: virtual void __thiscall MyDelegate::OnDoDamage(class CTakeDamageInfo &)" 
error LNK2001: unresolved external symbol "class PlayerManager g_Players"
The thing is that I know where some of these these unresolved symbols are defined:

g_pEntityList is defined in entitylist.cpp
g_Players is defined in PlayerManager.cpp

I've done everything I can think of to get these files to be included in the build process. I went to Tools -> options -> vc++ directories and added the path to both the include files and the source files. I include the .h files for the corresponding cpp files at in the files that use the code. I even went into the project settings -> linker -> additional dependencies and added every single lib file I could find in the HL2SDK.

Note that I have #define GAME_DLL in my project so it might be looking for the definition of these symbols in a dll somewhere. However if I don't #define GAME_DLL I get literally like 1000 errors... so there's no way I can compile without that.

Can anyone give me some suggestions as to what to do?

Last edited by InsidiousGnomes; 11-27-2008 at 12:27.
InsidiousGnomes is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode