Interaction Creation And Usage

Interaction system usage via exports with examples

Creating an interaction

        -- Register interaction
        _Interactions = {}
        
        local cargoInteraction = {
            name = 'Cargo Loading',
            text = 'Collect Cargo [E]',
            pos = vec3(0,0,0),
            action = function() -- Function that will be executed
                if not _attachedBox then
                    _StoreUtils.pickupCargo() 
                else
                    _QBCore.Functions.Notify('You already have a box in your hands!', 'error', 3000)
                end
            end
        }
        
        -- The export will return an Interaction ID that can be used later
        _Interactions.cargo = exports['h-interactions']:registerInteraction(cargoInteraction)
        
        -- Example usage of ID
        exports['h-interactions']:removeInteraction(_Interactions.cargo)

Last updated