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

SM Extension error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xerox8521
Senior Member
Join Date: Sep 2011
Old 12-20-2015 , 18:58   SM Extension error
Reply With Quote #1

Hi,

so i have been trying to add a native which calls
PHP Code:
CHL2MP_Player::InfectPlayer(float time
got that all setup no compile errors however when i try to load it it gives the error
PHP Code:
undefined symbolg_RegNatives 
Thing is now as you can see there is no line information about it. I did it based on the cstrike extension using CS_RespawnPlayer and CS_SwitchTeam.

Game is ZPS if that any helps.

RegNatives.cpp
PHP Code:
#include "extension.h"
#include "RegNatives.h"

RegNatives g_RegNatives;

void RegNatives::Register(ICallWrapper *pWrapper)
{
    
m_List.push_back(pWrapper);
}

void RegNatives::UnregisterAll()
{
    
SourceHook::List<ICallWrapper *>::iterator iter;
    for(
iter m_List.begin(); iter != m_List.end(); iter++)
    {
        (*
iter)->Destroy();
    }
    
m_List.clear();

RegNatives.h
PHP Code:
#ifndef _INCLUDE_ZPS_REGNATIVES_H
#define _INCLUDE_ZPS_REGNATIVES_H
#include <sh_list.h>
class RegNatives
{
public:
    
void Register(ICallWrapper *pWrapper);
    
void UnregisterAll();
private:
    
SourceHook::List<ICallWrapper *> m_List;
};

extern RegNatives g_RegNatives;
#endif 
PHP Code:
g_RegNatives.UnregisterAll(); 
gets called in the
PHP Code:
NotifyInterfaceDrop 
and on the
PHP Code:
SDK_OnUnload 
function.

In natives.cpp
PHP Code:
#define REGISTER_NATIVE_ADDR(name, code) \
    
void *addr; \
    if (!
g_pGameConf->GetMemSig(name, &addr) || !addr) \
    { \
        return 
pContext->ThrowNativeError("Failed to locate function"); \
    } \
    
code; \
    
g_RegNatives.Register(pWrapper);

#define GET_MEMSIG(name) \
    
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
    { \
        return 
pContext->ThrowNativeError("Failed to locate function"); \
    }

inline CBaseEntity *GetCBaseEntity(int numbool isplayer)
{
    
edict_t *pEdict gamehelpers->EdictOfIndex(num);
    if (!
pEdict || pEdict->IsFree())
    {
        return 
NULL;
    }

    if (
num && num <= playerhelpers->GetMaxClients())
    {
        
IGamePlayer *pPlayer playerhelpers->GetGamePlayer(pEdict);
        if (!
pPlayer || !pPlayer->IsConnected())
        {
            return 
NULL;
        }
    }
    else if (
isplayer
    {
        return 
NULL;
    }

    
IServerUnknown *pUnk;
    if ((
pUnk=pEdict->GetUnknown()) == NULL)
    {
        return 
NULL;
    }

    return 
pUnk->GetBaseEntity();
}

// Inside the Native function body

static ICallWrapper *pWrapper NULL;
    if(!
pWrapper)
    {
        
REGISTER_NATIVE_ADDR("CHL2MP_Player::InfectPlayer",
            
PassInfo pass[1]; \
            
pass[0].flags PASSFLAG_BYVAL; \
            
pass[0].size sizeof(float); \
            
pass[0].type PassType_Float; \
            
pWrapper g_pBinTools->CreateCall(addrCallConv_ThisCallNULLpass1));
    } 
I cannot post the entire extension as this is a private one (not made by me).
xerox8521 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-20-2015 , 21:40   Re: SM Extension error
Reply With Quote #2

You're not linking in RegNatives.cpp when compiling.
__________________
asherkin is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 12-20-2015 , 22:33   Re: SM Extension error
Reply With Quote #3

thanks, totally forgot that

Last edited by xerox8521; 12-20-2015 at 22:33.
xerox8521 is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-20-2015 , 22:36   Re: SM Extension error
Reply With Quote #4

Additionally, there's little point in an SM extension for that call since you can do it in SM itself via the SDKTools extension and the "SDKCall" native.
psychonic 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 22:51.


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