Allow mods to extend the context menu when clicking on players or NPCs
To do this from a mod:
this.events.on('onBeforeGetContextMenuActions', this.onBeforeGetContextMenuActions.bind(this));
onBeforeGetContextMenuActions: function (config) { }
The config objects has two arrays that can be appended to: player
and npc
that are initially defined in src/server/config/clientConfig.js
Adding Player Context Actions
onBeforeGetContextMenuActions: function (actions) {
actions.player.push({
text: 'menu item text',
threadModule: 'myModule',
method: 'myMethod'
});
}
Adding NPC Context Actions
onBeforeGetContextMenuActions: function (actions) {
actions.npc.push({
text: 'menu item text',
threadModule: 'myModule',
method: 'myMethod'
});
}
Lasly
You can call any kind of method here. It can be a module
, threadModule
or cpn
call.
NB If the method is performAction
(when you specify a cpn
and want to call a specific method in that component, you will construct the action like this:
{
cpn: 'player',
method: 'performAction',
data: {
cpn: 'yourComponent',
method: 'yourMethod',
data: {}
}
}
The target player's ID will automatically be attached to data as playerId
Edited by Big Bad Waffle