I'm not making anything, currently. But all four of my own custom plugins have faced this scope issue:
1) The "invite" plugin. It parses HTTP_REFERER, so needs to run at
global_start to collect the search engine and search terms, which are stored in variables. However, I use these within the
forumrules template, which is scoped to a function.
2) I use a private section of my forum to handle client projects. Each client has a sub-forum. I've written a billing system, and log my hours into it. Each post in this category has an option to attach a billing code, and it automatically gives them a running total on each of my posts. When I close a thread, they get an invoice, automatically, as the last post in the thread and also via email. Some of my variables are used on
FORUMDISPLAY, and yet others are used inside
postbit, which is scoped to the postbit_factory function.
3) Analysis & Opinion. If you go to my site,
http://www.tgreer.com/cmps_index.php , click the blue navigational buttons along the top. See how each category lists the sub-forums, and also lists any associated articles? Lots of code there, spread across lots of functions. So my variables are always out of scope.
4) phpAdsNew integration. Currently this is turned off, but I run the invocation code/plugin at
global_start, but display the ads in
showthread, which means the showthread template... but I had to add another plugin at
postbit_display_start to globalize the ad variable.
It's just a mess, and I know there has to be a better mechanism than this. I just can't find any documentation/discussion.