Raised This Month: $ Target: $400
 0% 

Making "cstrike" module optional


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 08-09-2008 , 14:12   Making "cstrike" module optional
Reply With Quote #1

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"?
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-09-2008 , 14:16   Re: Making "cstrike" module optional
Reply With Quote #2

The best way is to use conditional compiling. Like This:
Code:
#define USING_CSTRIKE
#if USING_CSTRIKE
    #include <cstrike>
#else
    #include <dodx>
#endif
danielkza is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 08-09-2008 , 14:21   Re: Making "cstrike" module optional
Reply With Quote #3

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;
 }
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 08-09-2008 , 15:07   Re: Making "cstrike" module optional
Reply With Quote #4

Thanks Emp`!
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
Reply


Thread Tools
Display Modes

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:34.


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