View Single Post
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-29-2012 , 00:52   Re: [ANY|TF2] Advanced Advertisements
Reply With Quote #15

I wonder if it's possible to make the TF2 extension an optional dependency and detect if TF2 is being used that way.

This might address the tf_beta issue as well.

The code would look something like this:

PHP Code:
#undef REQUIRE_EXTENSIONS
#tryinclude <tf2>

new bool:g_bIsTF2 false;

public 
OnAllPluginsLoaded()
{
    
g_bIsTF2 LibraryExists("tf2");
}

public 
OnLibraryAdded(const String:name[])
{
    if (
StrEqual(name"updater"))
    {
        
Updater_AddPlugin(UPDATE_URL);
    }
    else if (
StrEqual(name"tf2"))
    {
        
g_bIsTF2 true;
    }
}

public 
OnLibraryRemoved(const String:name[])
{
    if (
StrEqual(name"tf2"))
    {
        
g_bIsTF2 false;
    }

and then you'd use if (g_bIsTF2) blocks everywhere you currently have #if defined TF2COLORS.

Note: I didn't test this, not even in PawnStudio, so there may be syntax errors in it.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-29-2012 at 00:53.
Powerlord is offline