[Home] [Downloads] [Search] [Help/forum]


Script function


Read about scripting




Broadcasts a message to all installed plugins


long BroadcastPlugin(long Message, BSTR Text);

View list of data type meanings


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)

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.

Available in MUSHclient version 3.67 onwards.

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.

See Also ...




(CallPlugin) Calls a routine in a plugin
(EnablePlugin) Enables or disables the specified 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.
(GetPluginName) Returns the name of the current plugin
(GetPluginTimerInfo) Gets details about a named timer for a specified plugin
(GetPluginTimerList) Gets the list of timers in a specified plugin
(GetPluginVariable) Gets the contents of a variable belonging to a plugin
(GetPluginVariableList) Gets the list of variables in a specified plugin
(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
(ReloadPlugin) Reloads an installed plugin
(SaveState) Saves the state of the current plugin
(UnloadPlugin) Unloads an installed plugin

(Help topic: function=BroadcastPlugin)

Documentation contents page

Search ...

Enter a search string to find matching documentation.

Search for:   

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]