From 17dea2a42e6a5e82e4061f8553ac05e045fe792a Mon Sep 17 00:00:00 2001 From: Chase Hall Date: Thu, 6 Aug 2020 08:10:06 -0500 Subject: [PATCH] + Extending Pages --- Plugins.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/Plugins.md b/Plugins.md index bc22bd7..233a1d3 100644 --- a/Plugins.md +++ b/Plugins.md @@ -58,4 +58,54 @@ The following options can be configured by modifying `ActionOnReport.js` #### Shared GUID Kicker [Script Plugin] - This plugin kicks users using a specific GUID -- GUID `F4D2C30B712AC6E3` on IW4x was packed into a torrent version of the game. \ No newline at end of file +- GUID `F4D2C30B712AC6E3` on IW4x was packed into a torrent version of the game. + +--- + +### Extending Plugins + +#### NuGet Package +The NuGet package for **IW4MAdmin's** "Shared Library" can be obtained from the [NuGet Gallery](https://www.nuget.org/packages/RaidMax.IW4MAdmin.SharedLibraryCore) +Referencing this package will give you the ability to write plugins against **IW4MAdmin's** core library. +#### Code +**IW4MAdmin's** functionality can be extended by writing additional plugins in C#. +Each class library must implement the `IPlugin` interface. +See the existing [plugins](https://github.com/RaidMax/IW4M-Admin/tree/master/Plugins) for examples. +#### JavaScript +**IW4MAdmin** functionality can also be extended using JavaScript. +The JavaScript parser supports [ECMA 5.1](https://ecma-international.org/ecma-262/5.1/) standards. +#### Plugin Object Template +In order to be properly parsed by the JavaScript engine, every plugin must conform to the following template. +```js +var plugin = { + author: 'YourHandle', + version: 1.0, + name: 'Sample JavaScript Plugin', + + onEventAsync: function (gameEvent, server) { + }, + + onLoadAsync: function (manager) { + }, + + onUnloadAsync: function () { + }, + + onTickAsync: function (server) { + } +}; +``` +#### Required Properties +- `author` — [string] Author of the plugin (usually your name or online name/alias) +- `version` — [float] Version number of your plugin (useful if you release several different versions) +- `name` — [string] Name of your plugin (be descriptive!) +- `onEventAsync` — [function] Handler executed when an event occurs + - `gameEvent` — [parameter object] Object containing event type, origin, target, and other info (see the GameEvent class declaration) + - `server` — [parameter object] Object containing information and methods about the server the event occured on (see the Server class declaration) +- `onLoadAsync` — [function] Handler executed when the plugin is loaded by code + - `manager` — [parameter object] Object reference to the application manager (see the IManager interface definition) +- `onUnloadAsync` — [function] Handler executed when the plugin is unloaded by code (see live reloading) +- `onTickAsync` — [function] Handler executed approximately once per second by code *(unimplemented as of version 2.\*)* + - `server` — [parameter object] Object containing information and methods about the server the event occured on (see the Server class declaration) +### Live Reloading +Thanks to JavaScript's flexibility and parsability, the plugin importer scans the plugins folder and reloads the JavaScript plugins on demand as they're modified. This allows faster development/testing/debugging. \ No newline at end of file