This module exposes a forwards system to its own plug-ins. The system is separate from the forwards system in SourceMod – that is, you can’t create a forward in Viper and have it call SourcePawn functions.
| Exec Type | Description |
|---|---|
|
Ignore all return values and return None |
|
This is no longer used and will act like ET_Ignore |
|
Acts as an event, allowing callbacks to return Plugin result types. Mid-stops are not allowed, meaning returning Plugin_Stop will not stop the forward. Returns the highest number value returned by the callbacks. |
|
Acts as a hook, allowing callbacks to return Plugin result types. Mid-stops are allowed, meaning returning Plugin_Stop will stop the forward. Returns the highest number value returned by the callbacks. |
|
Same as ET_Event, except that it returns the lowest number value returned. |
Creates a new forward. All the arguments after et should be the types of the objects that will be passed to the forward’s hooks. For example:
>>> myforward = create("", None, ET_Ignore, int, int, str)
<anonymous Forward: 0x819c12d>
>>> def myhook(num1, num2, name):
... print num1, num2, name
... return Plugin_Continue
...
>>> myforward.add_function(myhook)
>>> myforward.fire(3, 1337, "elite")
3 1337 elite
To reduce ambiguity, the callbacks that are called when myforward.fire() is run (added by myforward.add_function()) are called hooks or registered callbacks.
Note
Pass a blank forward name to create an anonymous forward.
| Parameters: |
|
|---|---|
| Returns: | A Forward object |
Registers a callback for the global forward specified in forward.
| Returns: | True if successful; False if the specified forward could not be found or if the forward name passed is blank. |
|---|
Calling len() on a forward will return the number of hooks registered to the forward. Also, you can use myforward[x] to retrieve the registered callback at index x, and use the in syntax: if myhook in myforward
The name of the forward. This is blank for anonymous forwards.
Returns the number of callbacks registered to this forward. Interchangeable with get_function_count
Adds a function to the forward’s registered callback list. func should be able to handle all of the arguments of the forward, but that is NOT checked automatically.
Fires the forward, passing all arguments to the registered callbacks of the forward. The argument types will be checked against the types passed on creation of the forward. The return type depends on the exec type of the forward.
Returns the number of callbacks registered to this forward. This is the same as len(myforward).
Removes the first instance of func registered to this forward. Returns True if the function was found and removed, but False if the function was not in the registered callbacks list.