⚠️
If the action is registered server-side, it will be executed server-side, as
well as the restricted function.
RegisterAction
Adds a new action to the menu.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| name | string | Name of the action | Yes |
| func | fun(source: number, arguments: (number | string | nil)[], rawCommand?: string) | Function to be executed | Yes |
| argumentTypes | { name: string; type: 'string' | 'playerId' | 'number'; required?: boolean; choices: { label: string, value: string | number }[] }[] | The arguments of the action | No |
| isCommand | boolean | Whether a command should be created or not | No |
| restricted | boolean | fun(source: number): boolean | Do not make the action available to everyone. If it is a function, the action will only be executed if the function returns a true value | No |
Example
-- TriggerEvent('cmdmenu:RegisterAction', ...) also works
local action = exports['monolith-cmdmenu']:RegisterAction('test', function(source, arguments, raw)
local msg = ('%s says %s is the coolest player and prefers %s')
print(msg:format(GetPlayerName(source), GetPlayerName(arguments[1]), arguments[2]))
end, {
{
name = 'Player',
type = 'playerId',
required = true
},
{
name = 'Preference',
type = 'string',
required = true,
choices = {
{
label = 'Pizza',
value = 'Pizza'
},
{
label = 'Burger',
value = 'Burger'
}
}
}
})