Addon Weapons

Welcome to Addon weapon

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 you have to add your weapon as an item to the ESX system and validate that the weapon you are adding the owners of the store or the weapon they sold you or offer you add a small basic guide to add the weapon to the ESX system.

  • As a second step now we will begin the configuration of the new weapon in the quasar inventory, so we will proceed to go to [inventory]\qs-inventory-inventory-shared-items.lua and add the weapon, as an example we will take the name of the AK47 weapon.

['weapon_ak47'] = {
    ['name'] = 'weapon_ak47',
    ['label'] = 'AK47',
    ['weight'] = 1000,
    ['type'] = 'weapon',
    ['ammotype'] = 'AMMO_RIFLE',
    ['image'] = 'weapon_ak47.png',
    ['unique'] = true,
    ['useable'] = false,
    ['description'] = 'AK47'
},
  • As a third step, we will now add the weapon in [inventory]\qs-inventory\inventory\shared\weapons.lua following the same example above with the name AK47

[`weapon_ak47`] = {
    ['name'] = 'weapon_ak47',
    ['label'] = 'AK47',
    ['ammotype'] = 'AMMO_RIFLE',
    ['damagereason'] = 'Ended / Rifled / Shot down / Floored'
},
  • In the fourth 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