Addon weapons

Welcome to Addon weapons

For this section, if you do not have the minimum knowledge, or an experienced developer, avoid modifying or integrating custom weapons to your server to avoid errors, or problems with the inventory resource, with this we make clear that a support will not help you to configure a section like this to your server.

Now knowing that some basic skills are expected for this, we will make it as a brief guide and explained in the best way for users of our inventory can get to get varieties of weapons.

  • With the first step make sure to add the weapon and attachments in qb-core/shared/items and add only the weapon in qb-core/shared/weapons.lua. After these 2 steps, you must add the weapons in the qb-smallresources/client/weapondrop.lua and in qb-smallresources/client/weapondraw.lua, when you have these steps ready with the examples of each file, we can continue with the following steps to make it compatible with the inventory.

  • In the second step we have the integration of the Usable Items, and for this in the Addon attachments section is fully explained for you to understand them, but to continue with the tutorial of implementation of a custom weapon, we will make the example that our example weapon comes with 4 attachments so this will add it in [inventory]\qs-inventory\server\custom\misc\CreateUsableItem.lua

-- Mag
CreateUsableItem('custom-ak47-mag1', function(source, item)
    TriggerClientEvent('weapons:client:EquipAttachment', source, item, 'clip1')
end)

-- Scopes
CreateUsableItem('custom-ak47-scope1', function(source, item)
    TriggerClientEvent('weapons:client:EquipAttachment', source, item, 'scope1')
end)

-- Body
CreateUsableItem('custom-ak47-body1', function(source, item)
    TriggerClientEvent('weapons:client:EquipAttachment', source, item, 'frame1')
end)

CreateUsableItem('custom-ak47-body2', function(source, item)
    TriggerClientEvent('weapons:client:EquipAttachment', source, item, 'frame2')
end)

In the addon attachments section, you will find the different categories that you can assign to your attachments, this to be able to place some of these items in the attachment slot of the weapon.

  • And as last step, we have the configuration of the weapon in the weapons.lua, where we will assign the durability of the weapon and assign the corresponding attachments that can be assigned, you can find the file mentioned in [inventory]\qs-inventory\config\weapons.lua

-- weapon is added in the durability system
Config.DurabilityMultiplier = {
    ['weapon_ak47']                = 0.10,
}

-- and add the weapon with the attachments it comes with and configure in CreateUsableItems.lua
Config.WeaponAttachments = {
    ['WEAPON_MB47'] = {
        -- Mag
        ['clip1'] = {
            component = 'COMPONENT_CUSTOM_AK47_CLIP_01',
            label = 'AK47 Mag 1',
            item = 'custom-ak47-mag1',
        },
        ['scope1'] = {
            component = 'COMPONENT_CUSTOM_AK47_SCOPE_01',
            label = 'AK47 Scope 2',
            item = 'custom-ak47-scope1',
        },
        ['frame1'] = {
            component = 'COMPONENT_CUSTOM_AK4_BODY_01',
            label = 'AK47 Body 2',
            item = 'custom-ak47-body1',
        },
        ['frame2'] = {
            component = 'COMPONENT_CUSTOM_AK4_BODY_02',
            label = 'AK47 Body 2',
            item = 'custom-ak47-body2',
        },
    }
}

And if all goes well, you now have a custom weapon with 4 attachments ready to use with our inventory system, so we hope this will motivate the community to bring varied content.

Last updated