Raised This Month: $ Target: $400
 0% 

Forwards vs Stocks?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 09-02-2018 , 16:02   Forwards vs Stocks?
Reply With Quote #1

My question is pretty simple. Lets say I'm using a stock function to catch a tank spawn. I need this in 4 different plugins of mine. Should I be better of creating a forward and it will update all the plugins or would it be a better idea to create a stock function and add it either in all plugins or in an include file?

I'm tilting towards a forward as according to my understanding. It will run the code to detect the tank spawn once and all plugins can use it, as opposed to stock where each plugin will run the same function to get to mid way point and then do their thing.

Thoughts?
__________________
Spirit_12 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 09-02-2018 , 18:48   Re: Forwards vs Stocks?
Reply With Quote #2

I would recommend a forward if you're catching/using the same data across multiple plugins, especially if you want to use those plugins to work with the same exact data.

I think your question is similar to this: https://forums.alliedmods.net/showthread.php?t=310052
__________________
Psyk0tik is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 09-02-2018 , 20:30   Re: Forwards vs Stocks?
Reply With Quote #3

How would a forward react to me changing the value in one plugin compared to the other? What order does a forward fire up, if I want to lets say switch data in between plugins?
__________________
Spirit_12 is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 09-02-2018 , 21:08   Re: Forwards vs Stocks?
Reply With Quote #4

Registering your forward callbacks in the same forward (e.g., OnPluginStart) should be the same as plugin load order. Not strictly defined, but it appears to be alphabetical.

You may want to go with a pre/post forward approach if you have callbacks that only do reads.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop 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 22:43.


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