bridge/[your framework]/player_actions/actions_list.lua
---@class PlayerAction
---@field label string
---@field permission? string
---@field args? PlayerActionArgument[]
---@field onClick fun(player, args)
---@class PlayerActionArgument
---@field label? string
---@field placeholder? string Only for "text" inputs
---@field type 'text' | 'number' | 'range'
---@field value? string | number You can set default value
---@field min? number
---@field max? number
---@field step? number Only for "range" inputs
---@type PlayerAction[]
return {
...,
{
label = 'Give Item',
permission = 'give_item',
args = {
{
label = 'Item name',
placeholder = 'bread',
type = 'text'
},
{
label = 'Amount',
type = 'range',
value = 1,
min = 1,
max = 250
}
},
onClick = function(player, args)
--[[
args[1] - Item name
args[2] - Amount
]]
if #args[1] == 0 then
return false, 'Invalid item name'
end
local attempt_give_item = lib.callback.await('lc_admin:player_actions:esx:attemptGiveItem', 100, player.source, args[1], args[2])
if not attempt_give_item then
return false, 'Invalid item name'
end
return true
end
},
{
label = 'Custom action',
onClick = function(player)
print(json.encode(player, {indent=true}))
TriggerServerEvent('example:customAction', player)
end
}
}