AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [solved] get that plugin id what called native (https://forums.alliedmods.net/showthread.php?t=248612)

.Dare Devil. 09-20-2014 11:05

[solved] get that plugin id what called native
 
Hello Alliedmodders!

I was wondering...
PHP Code:

// plugin1.amxx
public plugin_natives()
{
    
register_native("test_nat""test_nat_handle"1)
    
}

public 
test_nat_handle( )
{
    
// here i need plugin2.amxx id yet we dont know what is plugin name 
    // and ohter plugins can call this native as well
}

plugin2.amxx
native test_nat
()
public 
plugin_init()
{
      
test_nat()


What i wish to do is a native something like this:
PHP Code:

mythingfunction_name[] ) // that function will be called when something happens 

i dont want to register MultiForward since the function should be only for that plugin what calls the mything.

It is pretty annoying to manually call CreateOneForward each time i wish to use costom functions.
Basically i want to create function like set_task is.


Also if it is impossible to do with pawn then i can also create module but i also don't know how to catch plugin id in module.


there is one way i know but then i have to use one param to pass plugin id.
function will be something like this:
PHP Code:

mythingget_plugin(), "my_returnfunc" )
// just found out that get_plugin() does not work that way as i thought.
// i thought it would return correct plugin id... nice fail tho... 

Well, that is one way but i really wish that there's a other way so i can check plugin id in native handle instead of getting plugin id in that plugin. It just that the format of function looks ugly and wasting one param for that, i find it terrible.

Thanks!

Edit:
Here's one terrible stock i made:
PHP Code:

stock find_funcfuncname[], &plugin_id )
{
    new 
r
    
for( new 0get_pluginsnum(); a++  )
    {
        
get_func_id(funcnamea)
        if( 
!= -
        {
            
plugin_id a
            
return r
        
}
    }
    return -
1


This will get func id and plugin id but fails when 2 plugins share same function name.
Also its a kind of stock i want to call only one time for each function.

If however i wish to make set_task like function i then need to store the function and plugin index somewhere i can get it fast without calling the stock again and it will become bit complicated then.

fysiks 09-20-2014 12:11

Re: get that plugin id what called native
 
Describe this "set_task-like" function.

Nextra 09-20-2014 17:38

Re: get that plugin id what called native
 
Simple solution: Don't use style 1 natives.

fysiks 09-20-2014 18:15

Re: get that plugin id what called native
 
Deja vu! . . . I'm sure we've had this discussion before. . .

.Dare Devil. 09-20-2014 19:43

Re: get that plugin id what called native
 
the thing is that i have never worked with natives style 0, i didin't know that it passes plugins id.
Thanks for the hint, problem solved!

fysiks 09-20-2014 20:36

Re: [solved] get that plugin id what called native
 
For reference, here is the thread that discussed this previously.


All times are GMT -4. The time now is 01:20.

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