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:
mything( function_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:
mything( get_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_func( funcname[], &plugin_id )
{
new r
for( new a = 0; a < get_pluginsnum(); a++ )
{
r = get_func_id(funcname, a)
if( r != -1 )
{
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.