-
-
Notifications
You must be signed in to change notification settings - Fork 44
Plugin Development
You can extend the functionality of IW4MAdmin by writing your own plugins.
The NuGet package for IW4MAdmin's "Shared Library" can be obtained from the NuGet Gallery Referencing this package will give you the ability to write plugins against IW4MAdmin's core library.
IW4MAdmin's functionality can be extended by writing additional plugins in C#.
Each class library must implement the IPluginV2 interface.
See the existing plugins for examples.
IW4MAdmin functionality can also be extended using JavaScript. The JavaScript parser supports these ECMA Features. JavaScript plugins use C# classes behind the scenes and as such there is interop between the C# backing.
In order to be properly parsed by the JavaScript engine, every plugin must conform to the following template.
const init = (registerNotify, serviceResolver, config) => {
return plugin;
};
const plugin = {
author: 'Author',
version: '1.0',
name: 'PluginName'
}
const commands = [];
const init = (registerNotify, serviceResolver, config) => {
registerNotify('IManagementEventSubscriptions.ClientStateInitialized', (clientEvent, _) => plugin.onClientEnteredMatch(clientEvent));
plugin.onLoad(serviceResolver, config);
return plugin;
};
Name | Description |
---|---|
registerNotify | Helper to subscribe to events |
serviceResolver | IScriptPluginServiceResolver |
config | ScriptPluginConfigurationWrapper |
IManagementEventSubscriptions
IGameServerEventSubscriptions
IGameEventSubscriptions
const plugin = {
author: 'Raidmax',
version: '1.0',
name: 'Example PLugin',
eventManager: null,
onLoad: function(serviceResolver, config) {
// use pseudo dependency injection to get IManager
this.eventManager = serviceResolver.resolveService('IManager');
},
requestExecuteCommand: function(command, server) {
const serverEvents = importNamespace('SharedLibraryCore.Events.Server');
const requestEvent = new serverEvents.ServerCommandExecuteRequested(command, server);
requestEvent.timeoutMs = 2000;
requestEvent.source = this.name;
// queue our request on the event manager
this.eventManager.queueEvent(requestEvent);
}
}
IManager
ServerCommandExecuteRequested
IPluginV2
const commands = [{
name: 'example',
description: 'executes example command',
alias: 'ex',
permission: 'User',
targetRequired: false,
arguments: [],
execute: (gameEvent) => {
plugin.requestExecuteCommand('example', gameEvent.owner);
}
}];
IManagerCommand
Permission
GameEvent
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.