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

ForwardEx - A more extensive forward management system


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
minimoney1
SourceMod Donor
Join Date: Dec 2010
Old 11-25-2012 , 15:49   ForwardEx - A more extensive forward management system
Reply With Quote #1

Hello everyone.
For Simple Chat Processor (Redux), I needed a way to call each forward one by one (as the current forward manager's methods call either the first or the highest depending on your settings set in CreateForward).
So here it is!

Note: This is for private forwards

Sample Plugin:
PHP Code:
#include <sourcemod>
#include <forwardex>

new Forward:g_fMyForward INVALID_FORWARD;

public 
APLRes:AskPluginLoad2(Handle:pluginbool:lateString:err[], err_max)
{
    
CreateNative("AddToMyForward"Native_Add);
    
CreateNative("RemoveFromMyForward"Native_Remove);
    return 
APLRes_Success;
}

public 
Native_Add(Handle:pluginnumParams)
{
    if (
g_fMyForward != INVALID_FORWARD)
    {
        
FwdEx_AddToForward(g_fMyForwardplugin, Function:GetNativeCell(1));
    }
}

public 
Native_Remove(Handle:pluginnumParams)
{
    if (
g_fMyForward != INVALID_FORWARD)
    {
        
FwdEx_RemoveFromForward(g_fMyForwardplugin, Function:GetNativeCell(1));
    }
}

public 
OnPluginStart()
{
    
FwdEx_Init();
    
g_fMyForward FwdEx_CreateForward();
}

public 
OnMapStart()
{
    if (
g_fMyForward != INVALID_FORWARD)
    {
        new 
bool:finish false;
        new 
bool:isTrue true;
        new 
count FwdEx_GetFwdCount(g_fMyForward);
        for (new 
0counti++)
        {
            
finish false;
            
Call_StartPrivateForward(g_fMyForwardForwardId:i);
            
Call_PushCellRef(isTrue);
            
Call_Finish(finish);
            if (!
finish)
            {
                
isTrue true;
            }
        }
    }
}

public 
OnPluginEnd()
{
    
FwdEx_End();

Please let me know of any bugs/questions/suggestions.

Thank you
Attached Files
File Type: sp Get Plugin or Get Source (fwdex_sample.sp - 174 views - 1.2 KB)
File Type: inc forwardex.inc (3.1 KB, 189 views)
__________________
Need help? PM me or add me on Steam.
My Steam




Quote:
Originally Posted by Rp.KryptoNite View Post
For some reason his Plugin never worked for me ,
@credits were added
im not stealing any plugins dude its my THING

Last edited by minimoney1; 11-25-2012 at 22:55.
minimoney1 is offline
minimoney1
SourceMod Donor
Join Date: Dec 2010
Old 11-25-2012 , 22:54   Re: ForwardEx - A more extensive forward management system
Reply With Quote #2

*Reserved*

11-25: Fixed a small bug.
__________________
Need help? PM me or add me on Steam.
My Steam




Quote:
Originally Posted by Rp.KryptoNite View Post
For some reason his Plugin never worked for me ,
@credits were added
im not stealing any plugins dude its my THING
minimoney1 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-27-2012 , 10:21   Re: ForwardEx - A more extensive forward management system
Reply With Quote #3

Quote:
Originally Posted by minimoney1 View Post
Hello everyone.
For Simple Chat Processor (Redux), I needed a way to call each forward one by one (as the current forward manager's methods call either the first or the highest depending on your settings set in CreateForward).
Are you talking about return values here?

The forward manager is supposed to call all private forwards registered. The value it returns depends on the execution type.

ET_Ignore doesn't return anything.
ET_Single returns the value from the last forward.
ET_Event runs all forwards until it hits a forward that returns something other than Plugin_Continue (or runs all of them). It then returns that value.
ET_Hook runs all forwards until it hits a forward that returns Plugin_Stop (or runs all of them). It then returns the highest value that was returned.

By highest value, I mean out of these values:
Code:
    Plugin_Continue = 0,    /**< Continue with the original action */
    Plugin_Changed = 1,        /**< Inputs or outputs have been overridden with new values */
    Plugin_Handled = 3,        /**< Handle the action at the end (don't call it) */
    Plugin_Stop = 4,        /**< Immediately stop the hook chain and handle the original */
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 11-27-2012 at 10:24.
Powerlord is offline
minimoney1
SourceMod Donor
Join Date: Dec 2010
Old 11-27-2012 , 20:03   Re: ForwardEx - A more extensive forward management system
Reply With Quote #4

Quote:
Originally Posted by Powerlord View Post
Are you talking about return values here?

The forward manager is supposed to call all private forwards registered. The value it returns depends on the execution type.

ET_Ignore doesn't return anything.
ET_Single returns the value from the last forward.
ET_Event runs all forwards until it hits a forward that returns something other than Plugin_Continue (or runs all of them). It then returns that value.
ET_Hook runs all forwards until it hits a forward that returns Plugin_Stop (or runs all of them). It then returns the highest value that was returned.

By highest value, I mean out of these values:
Code:
    Plugin_Continue = 0,    /**< Continue with the original action */
    Plugin_Changed = 1,        /**< Inputs or outputs have been overridden with new values */
    Plugin_Handled = 3,        /**< Handle the action at the end (don't call it) */
    Plugin_Stop = 4,        /**< Immediately stop the hook chain and handle the original */
Yes, I needed to get the return value of every single forward to change things based on its return value, hence why I made this library.
__________________
Need help? PM me or add me on Steam.
My Steam




Quote:
Originally Posted by Rp.KryptoNite View Post
For some reason his Plugin never worked for me ,
@credits were added
im not stealing any plugins dude its my THING
minimoney1 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 10:54.


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