Raised This Month: $51 Target: $400
 12% 

[solved] get that plugin id what called native


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 09-20-2014 , 11:05   [solved] get that plugin id what called native
Reply With Quote #1

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.

Last edited by .Dare Devil.; 09-20-2014 at 19:44.
.Dare Devil. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-20-2014 , 12:11   Re: get that plugin id what called native
Reply With Quote #2

Describe this "set_task-like" function.
__________________
fysiks is online now
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 09-20-2014 , 17:38   Re: get that plugin id what called native
Reply With Quote #3

Simple solution: Don't use style 1 natives.
__________________
In Flames we trust!
Nextra is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-20-2014 , 18:15   Re: get that plugin id what called native
Reply With Quote #4

Deja vu! . . . I'm sure we've had this discussion before. . .
__________________
fysiks is online now
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 09-20-2014 , 19:43   Re: get that plugin id what called native
Reply With Quote #5

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!
.Dare Devil. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-20-2014 , 20:36   Re: [solved] get that plugin id what called native
Reply With Quote #6

For reference, here is the thread that discussed this previously.
__________________
fysiks is online now
Reply



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 02:22.


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