AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   if module doesn't exists don't use it (https://forums.alliedmods.net/showthread.php?t=88806)

Empowers 03-29-2009 10:05

if module doesn't exists don't use it
 
I wanna make in my plugin if csdm module doesn't exists so don't use it:
PHP Code:

public plugin_natives()
{        
    
set_module_filter("module_filter")
    
set_native_filter("native_filter")
}

public 
module_filter(const module[])
{
    if(
module_exists("csdm"))        
        
g_Csdm true
        
    
if (!g_Csdm && equali(module"csdm"))
        return 
PLUGIN_HANDLED

    
return PLUGIN_CONTINUE
}

public 
native_filter(const name[], indextrap)
{
    if (!
trap) return PLUGIN_HANDLED

    
return PLUGIN_CONTINUE


but module_exists("csdm") function always return false. Why? And maybe there is other way to do the same


Sorry for Bad English

ConnorMcLeod 03-29-2009 10:09

Re: if module doesn't exists don't use it
 
Quote:

Originally Posted by Empowers (Post 792170)
but module_exists("csdm") function always return false. Why? And maybe there is other way to do the same


Sorry for Bad English

Try to do the check in plugin_init()

Empowers 03-29-2009 10:15

Re: if module doesn't exists don't use it
 
plugin_init() is called after native_filter() and module_filter(),
and I need to check it before so I could trap the module.

Any Suggestions?

ConnorMcLeod 03-29-2009 11:37

Re: if module doesn't exists don't use it
 
You are wrong, return HANDLED if module checked is csdm, then, in plugin_init, check if module is loaded and set the global var that will tell later to your plugin wheter he should use csdm natives or not.
I suggest you to have a look at plmenu.sma from default package.

Empowers 03-29-2009 12:02

Re: if module doesn't exists don't use it
 
sh*t I found the problem... in my csdm server native_filter
and modul_filter O_o never gets called and if I pass it other server it works fine..
I check that using this code:
PHP Code:

public plugin_natives() 
{         
    
set_module_filter("module_filter"
    
set_native_filter("native_filter"


public 
module_filter(const module[]) 
    
server_print("module_filter called")

public 
native_filter(const name[], indextrap
    
server_print("native_filter called"

but what's wron??


All times are GMT -4. The time now is 09:03.

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