world.BroadcastPlugin
Broadcasts a message to all installed plugins
Prototype
long BroadcastPlugin(long Message, BSTR Text);
Description
Broadcasts the message to all installed plugins.
The intention here is for one plugin to catch an event and "notify" all other plugins of that event.
You supply 2 arguments, a number and a string.
The number is intended to be a "message number", to indicate the type of message (eg. trigger has fired = 1, alias matched = 2).
The string is intended to allow you to supply free-format data to the plugin.
All installed plugins are checked for a function OnPluginBroadcast. If present, it is called with 4 arguments:
1 - the message number (supplied above).
2 - the ID of the calling plugin, or an empty string if BroadcastPlugin was called from the main script file.
3 - the name of the calling plugin, or an empty string if BroadcastPlugin was called from the main script file.
4 - the Text argument (supplied above)
An example of a plugin handler might be (in Lua):
function OnPluginBroadcast (msg, id, name, text)
Note ("msg = " .. msg)
Note ("id = " .. id)
Note ("name = " .. name)
Note ("text = " .. text)
end
The calling plugin ID and name are supplied so that plugin writers can verify which plugin originated a particular message. This cannot be spoofed as it is supplied automatically by MUSHclient.
Thus, a sensible test might be for a plugin that incorporates an OnPluginBroadcast handler, to test the id supplied to match the id of the plugin that it expects to be doing the broadcast.
VBscript example
world.BroadcastPlugin 100, "Some message"
Jscript example
world.BroadcastPlugin (100, "some message");
PerlScript example
$world->BroadcastPlugin (100, "some message");
Python example
world.BroadcastPlugin (100, "some message")
Lua example
BroadcastPlugin (100, "some message")
Lua notes
The Text parameter is optional, and defaults to an empty string.
Return value
The number of plugins that had an OnPluginBroadcast handler.
Related topic
See also
| Function | Description |
|---|---|
| CallPlugin | Calls a routine in a plugin |
| GetPluginID | Returns the 24-character ID of the current plugin |
| GetPluginInfo | Gets details about a specified plugin |
| GetPluginList | Gets a list of installed plugins. |
| IsPluginInstalled | Checks to see if a particular plugin is installed |
| LoadPlugin | Loads a plugin from disk |
| PluginSupports | Checks if a plugin supports a particular routine |