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

Efficient callbacks


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadows In Rain
Senior Member
Join Date: Apr 2010
Location: Russia::Siberia
Old 02-18-2011 , 20:58   Efficient callbacks
Reply With Quote #1

How to get name or id of plugin that calls dynamic native in my plugin? How modules do it? I'm interested in efficient callbacks for my subplugins with using callfunc_* (rather than multi forwards).

UPD
Thanx, solved. And i agree: single forwards probably more useful than callfunc_*s.
__________________
I'm using Google translator, yarrr. |.◕‿‿◕.|

Last edited by Shadows In Rain; 02-19-2011 at 09:45.
Shadows In Rain is offline
Send a message via ICQ to Shadows In Rain
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-19-2011 , 00:34   Re: Efficient callbacks
Reply With Quote #2

Are you saying that callfunc is more efficient than using a forward? I would think the difference might not be much (someone who knows more might want to comment).

On topic:

Quote:
Originally Posted by Hawk552 View Post
In all dynamic natives, unless registered with style=1, we see something to the effect of (id,params), which I decided to rename in the header. The first param is the plugin id - this is useful in case you want to send it back a callfunc or a CreateOneForward/ExecuteForward, or have an array that stores data for each plugin loaded.
+ get_plugin()
__________________
fysiks is offline
Shadows In Rain
Senior Member
Join Date: Apr 2010
Location: Russia::Siberia
Old 02-19-2011 , 06:15   Re: Efficient callbacks
Reply With Quote #3

fysiks, when i use forwards, many subplugins must check passed handle and/or indexes. It's not so efficient, i think, both for program and for programing. And also often i need many subsequent broadcasts (f.e. for shared-and-injected menu generation — each menu item, header, footer), or place handles into arrays, but this way leads to copy-paste programming style.
Thanx for suggestion. This way still boring, but quite useful.
__________________
I'm using Google translator, yarrr. |.◕‿‿◕.|

Last edited by Shadows In Rain; 02-19-2011 at 06:24.
Shadows In Rain is offline
Send a message via ICQ to Shadows In Rain
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-19-2011 , 06:44   Re: Efficient callbacks
Reply With Quote #4

You talk about therory, but let's take a concrete example to explain what you mean.
callfunc needs to send begin and end native + all params natives when dynamic natives need to be sent only once, also, if you want to filter forward by plugins, then use single forwards.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Shadows In Rain
Senior Member
Join Date: Apr 2010
Location: Russia::Siberia
Old 02-19-2011 , 09:35   Re: Efficient callbacks
Reply With Quote #5

ConnorMcLeod, i don't care what to use — callfunc_*s or single forwards (so when i told about "fowards" i really mean "multi forwards"), i just want get caller id. And now know how. I will consider bot methods to compare usability and perfomance. Thanx for your suggestion also (draw your attention to first post). Real example, since you asked:
Code:
public anymal_mb_processing(MBH:handle, player, first, last)
{
	if(handle != g_injection_handle)
		return
	
	for(new realitem = first, menuitem = 1; realitem <= last; realitem++, menuitem++)
	{
		if(realitem != g_injection_index) // annoying copy-paste
			continue

...
__________________
I'm using Google translator, yarrr. |.◕‿‿◕.|

Last edited by Shadows In Rain; 02-19-2011 at 09:42.
Shadows In Rain is offline
Send a message via ICQ to Shadows In Rain
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-19-2011 , 10:43   Re: Efficient callbacks
Reply With Quote #6

I don't understand what you do, anyway, you know which plugin you send a forward from, if the foward is single you know which plugin you send the forward to, and when a plugin receive a dynamic native, the first param is the plugin id.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
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 14:56.


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