Skip to content
David edited this page Mar 11, 2022 · 4 revisions

✈️ Jump to section

🔗 Hooks

As various events occur within MPR, hooks will be fired to notify other plugins. Perhaps the most useful is ConfigApply.

⚠️ NOTE: At this time, hooks do not take any return values; they only notify of the event happening. ⚠️

ConfigApply - (id)

Fired when a user clicks the "Apply config" button in a plugin's config window. This is technically more of a config refresh alert, since the config is always saved as the user modifies it.

  • id: ID of the plugin where the configuration was applied

ConfigChange - (id, key, value, old)

Fired whenever any config value on a plugin is changed, by both user input and the function. You probably don't want to rely on this hook for refreshing your plugin if an option was changed, instead use ConfigApply. This is called after UserConfigChange when applicable.

  • id: ID of the plugin where the configuration is changed
  • key: Key of the changed option
  • value: New value
  • old: Old value

MenuVGUIReady

Fired once on the first DrawOverlay hook, ported for legacy plugins.
When fired, this means pnlMainMenu exists, so long as the stock main menu is being used.
(Keep in mind this is only fired once, so also check IsValid(pnlMainMenu) in case your plugin was enabled after the menu was loaded.)

PluginDisabled - (manifest)

Fired after the manifest's enabled is set to false, but before the unload function is run.

PluginEnabled - (manifest)

Fired after the manifest's enabled is set to true, but before the plugin is run.

PluginLoaded - (manifest)

Fired when a plugin has successfully loaded and registered within MPR.

PluginReset - (manifest)

Fired after the user confirms to reset a plugin's config & store, but before it's actually wiped from the database.

PluginRun - (manifest)

Fired before a plugin is executed.

PluginUndo - (manifest)

Fired before a plugin's unload function is run if present.

ShutDown

Fired one frame before the game is closed after the user clicks the "Quit" button.
Returning a value WILL NOT prevent the game from closing!

UserConfigChange - (id, key, value, old)

Fired ONLY whenever the user changes a config value, else identical to ConfigChange. You probably don't want to rely on this hook for refreshing your plugin if an option was changed, instead use ConfigApply. This is called before ConfigChange.

  • id: ID of the plugin where the configuration is changed
  • key: Key of the changed option
  • value: New value
  • old: Old value