AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Making "cstrike" module optional (https://forums.alliedmods.net/showthread.php?t=75644)

Shaman 08-09-2008 14:12

Making "cstrike" module optional
 
When I include "cstrike.inc" like this:
PHP Code:

#define AMXMODX_NOAUTOLOAD
#include <cstrike> 

I get this error:
Code:

Module/Library "cstrike" required for plugin.  Check modules.ini.
When I add this:
PHP Code:

public plugin_natives()
    {
    
register_library("cstrike")
    } 

then I get this error:
Code:

Plugin uses an unknown function (name "cs_set_user_money") - check your modules.ini.
I only use "cs_get_user_money" and "cs_set_user_money" when the mod is Counter-Strike so I don't want it to load "cstrike" module in other mods. How can I do that without editing "cstrike.inc"?

danielkza 08-09-2008 14:16

Re: Making "cstrike" module optional
 
The best way is to use conditional compiling. Like This:
Code:

#define USING_CSTRIKE
#if USING_CSTRIKE
    #include <cstrike>
#else
    #include <dodx>
#endif


Emp` 08-09-2008 14:21

Re: Making "cstrike" module optional
 
From EAM
Code:

public plugin_natives()
 {
        //we need to block things, if they aren't going to be used, that will pause the plugin
        set_native_filter( "native_trapper" );
        set_module_filter( "module_filter" );
 }
 public module_filter(const module[])
 {
        if( equali(module, "cstrike") ) return PLUGIN_HANDLED;
        return PLUGIN_CONTINUE;
 }

 public native_trapper(const name[], index, trap)
 {
        if(!trap) return PLUGIN_HANDLED;
        return PLUGIN_CONTINUE;
 }


Shaman 08-09-2008 15:07

Re: Making "cstrike" module optional
 
Thanks Emp`!


All times are GMT -4. The time now is 05:34.

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