This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Access SourceMod core?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
ajr1234
Senior Member
Join Date: Mar 2011
Location: Chicago, IL, U.S.A.
Old 06-10-2012 , 16:23   Access SourceMod core?
Reply With Quote #1

I'm really new to SourceMod extensions, but I'm well versed with c++. How would I access the g_Players global from an extension? For example:

PHP Code:
static cell_t SomeExtensionFunction(IPluginContext *pContext, const cell_t *params)
{
    
int client params[1];

// g_Players is inside another class-- can't do it
// Is CPlayer in the HL2SDK-l4d2?
    
CPlayer *pPlayer g_Players.GetPlayerByIndex(client);
    if (!
pPlayer)
    {
        return 
pContext->ThrowNativeError("Client index %d is invalid"client);
    }

    
// etc.

    
return 1;

I guess what I'm really trying to ask is if it's possible to use the nifty functions Sourcemod already provides. Instead of hooking void Hook_ClientPutInServer(edict_t *pEntity, char const *playername) with SH_ADD_HOOK_STATICFUNC/SH_DECL_HOOK2_void etc to reinvent the wheel. Do we use the interface system? I was reading the tutorial but it was very vague.

Also, I know about forwarding to plugins, but is it possible the other way around? Can we use natives created by plugins in extensions?

Thanks

Last edited by ajr1234; 06-10-2012 at 18:10.
ajr1234 is offline
 



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 05:18.


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