Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add optional buttons for metadata #1840

Open
Mesrine67 opened this issue Nov 19, 2024 · 1 comment
Open

add optional buttons for metadata #1840

Mesrine67 opened this issue Nov 19, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Mesrine67
Copy link

exemple

lib.addCommand('giveClothingBag', {
    help = 'Give a bag (component 5) as clothing',
    restricted = 'group.admin',
}, function(source, args)
    -- Metadata for the "Clothing" item
    local metadata = {
        type = 'Clothing',      -- Item type
        component = 5,          -- Component (bags and parachutes)
        drawable = 0,           -- Default drawable variant
        texture = 0,            -- Default texture
		buttons = {
			{
				label = 'Open Bag',
				action = function(slot)
					print('open bag')
				end
			},
		},
    }

    -- Add the item to the player's inventory
    local success, response = exports.ox_inventory:AddItem(source, 'clothing', 1, metadata)

    if not success then
        -- Handle errors with a chat message
        TriggerClientEvent('chat:addMessage', source, {
            args = { 'Error', ('Failed to add the item: %s'):format(response) }
        })
        return
    end

    -- Success confirmation in the chat
    TriggerClientEvent('chat:addMessage', source, {
        args = { 'Success', ('You have received a bag (component 5) in your inventory.') }
    })
end)
@Mesrine67 Mesrine67 added the enhancement New feature or request label Nov 19, 2024
@SleezyPrime
Copy link

Thanks bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants