Context Actions
When to use each method:
Method 1: Adding buttons to a single item
['water'] = {
label = 'Water',
weight = 1.0,
stackable = true,
close = true,
description = 'A bottle of water',
maxStack = 10,
contextActions = {
{
label = 'Drink', -- Button text that players see
icon = 'bi-droplet', -- Icon (Bootstrap Icons)
callback = function(inventoryId, slotIndex)
-- Your code here - this runs when the button is clicked
TriggerServerEvent('myserver:drinkWater', inventoryId, slotIndex)
end
},
{
label = 'Check expiration',
icon = 'bi-calendar-check',
callback = function(inventoryId, slotIndex)
print('Checking expiration date...')
-- Add your logic here
end
}
}
},Method 2: Adding buttons to all items of a specific type
Adding global buttons to ALL items
Last updated

