Build and install
Installing on your server
Drop the folder into resources, add one line to server.cfg and restart. Then give the weapon with a native, your framework or your inventory.
What is in the resource
The zip holds one folder, named weapon_ plus your weapon: weapon_sandstormrifle for the Sandstorm Rifle. It is a complete resource; this is the rifle with four parts:
weapon_sandstormrifle/client.lua
weapon_sandstormrifle/fxmanifest.lua
weapon_sandstormrifle/meta/pickups.meta
weapon_sandstormrifle/meta/weaponanimations.meta
weapon_sandstormrifle/meta/weaponarchetypes.meta
weapon_sandstormrifle/meta/weaponcomponents.meta
weapon_sandstormrifle/meta/weapons.meta
weapon_sandstormrifle/stream/w_ar_sandstormrifle.ydr
weapon_sandstormrifle/stream/w_ar_sandstormrifle.ytd
weapon_sandstormrifle/stream/w_ar_sandstormrifle_hi.ydr
weapon_sandstormrifle/stream/w_at_sandstormrifle_extendedcu.ydr
weapon_sandstormrifle/stream/w_at_sandstormrifle_extendedcu.ytd
weapon_sandstormrifle/stream/w_at_sandstormrifle_holographi.ydr
weapon_sandstormrifle/stream/w_at_sandstormrifle_holographi.ytd
weapon_sandstormrifle/stream/w_at_sandstormrifle_tacticalsu.ydr
weapon_sandstormrifle/stream/w_at_sandstormrifle_tacticalsu.ytd
weapon_sandstormrifle/stream/w_at_sandstormrifle_verticalfo.ydr
weapon_sandstormrifle/stream/w_at_sandstormrifle_verticalfo.ytdfxmanifest.luaRegisters every meta file with the game (below). Nothing to edit.client.luaGives the weapon and each part its display name in the weapon wheel.meta/weapons.metaThe weapon itself: base behaviour, your stats, fire mode and the attach points.meta/weaponarchetypes.metaLinks the weapon and part models to their textures.meta/weaponanimations.metaThe animation set, taken from the base weapon.meta/pickups.metaThe pickup that appears when the weapon is dropped.meta/weaponcomponents.metaThe attachments. Only in weapons with parts.stream/The model (w_ar_sandstormrifle.ydr), its textures (.ytd), the first-person model (_hi.ydr) and one model per part.
The manifest loads the meta files with these lines:
data_file 'WEAPONINFO_FILE' 'meta/weapons.meta'
data_file 'WEAPON_METADATA_FILE' 'meta/weaponarchetypes.meta'
data_file 'WEAPON_ANIMATIONS_FILE' 'meta/weaponanimations.meta'
data_file 'DLC_WEAPON_PICKUPS' 'meta/pickups.meta'
data_file 'WEAPONCOMPONENTSINFO_FILE' 'meta/weaponcomponents.meta'Install the resource
- 1
Unzip the download
Unzip
weapon_sandstormrifle.zip. You get the folderweapon_sandstormrifle. - 2
Copy it into resources
Put the whole folder into your server's
resourcesdirectory. Keep the folder name;fxmanifest.luamust sit directly inside it. - 3
Add it to server.cfg
ensure weapon_sandstormrifle - 4
Restart and reconnect
Restart the server and reconnect. Weapon meta files are read when the game loads them, so a player who stayed connected does not get the new weapon.
Note
Nothing in your existing weapon setup is overwritten. The base weapon, here the Assault Rifle, keeps working as before.
Give it to a player
The result page lists the lines for your weapon under Add-on weapon ready: the weapon with GiveWeaponToPed, and each part with GiveWeaponComponentToPed.
- 1. ensure: the line for server.cfg
- 2. GiveWeaponToPed: gives the weapon to a player
For a quick test without a framework, add a chat command to client.lua of the resource. Remove it again before players join:
RegisterCommand('sandstorm', function()
local ped = PlayerPedId()
local weapon = GetHashKey('WEAPON_SANDSTORMRIFLE')
GiveWeaponToPed(ped, weapon, 250, false, true)
GiveWeaponComponentToPed(ped, weapon, GetHashKey('COMPONENT_SANDSTORMRIFLE_TACTICALSUPPRESSOR'))
GiveWeaponComponentToPed(ped, weapon, GetHashKey('COMPONENT_SANDSTORMRIFLE_HOLOGRAPHICSIGHT'))
GiveWeaponComponentToPed(ped, weapon, GetHashKey('COMPONENT_SANDSTORMRIFLE_EXTENDEDCURVEDMAGAZINE'))
GiveWeaponComponentToPed(ped, weapon, GetHashKey('COMPONENT_SANDSTORMRIFLE_VERTICALFOREGRIP'))
end, false)After a restart, type /sandstorm in the chat. The magazine part is on the weapon from the start; the other parts come with their component lines.
ESX, QBCore and ox_inventory
Frameworks and inventories only hand out weapons they know, and they keep their own list. Add your weapon there. The easiest way: copy the entry of the base weapon, then change the name and the label.
In ox_inventory/data/weapons.lua, add an entry under Weapons. Use the ammoname of the base weapon's entry in the same file:
['WEAPON_SANDSTORMRIFLE'] = {
label = 'Sandstorm Rifle',
weight = 3500,
durability = 0.03,
ammoname = 'ammo-rifle2',
},Each part is an item under Components with the component name from the result page:
['at_sandstorm_suppressor'] = {
label = 'Tactical Suppressor',
type = 'muzzle',
weight = 280,
client = {
component = { `COMPONENT_SANDSTORMRIFLE_TACTICALSUPPRESSOR` },
usetime = 2500,
},
},For the icon, copy the base weapon's image in ox_inventory/web/images as WEAPON_SANDSTORMRIFLE.png. Restart, then give it with /giveitem 1 WEAPON_SANDSTORMRIFLE 1.
QBCore treats weapons as items, in lowercase. Add the item to qb-core/shared/items.lua:
['weapon_sandstormrifle'] = {
name = 'weapon_sandstormrifle',
label = 'Sandstorm Rifle',
weight = 1000,
type = 'weapon',
ammotype = 'AMMO_RIFLE',
image = 'weapon_assaultrifle.png',
unique = true,
useable = false,
description = 'Add-on rifle',
},and the weapon to qb-core/shared/weapons.lua:
[`weapon_sandstormrifle`] = {
name = 'weapon_sandstormrifle',
label = 'Sandstorm Rifle',
weapontype = 'Assault Rifle',
ammotype = 'AMMO_RIFLE',
damagereason = 'Ended / Rifled / Shot down / Floored',
},Restart, then give it with /giveitem 1 weapon_sandstormrifle 1.
Without ox_inventory, ESX keeps weapons in es_extended/config.weapons.lua. Add an entry to Config.Weapons:
{
name = 'WEAPON_SANDSTORMRIFLE',
label = 'Sandstorm Rifle',
ammo = { label = TranslateCap('ammo_rounds'), hash = `AMMO_RIFLE` },
tints = Config.DefaultWeaponTints,
components = {
{ name = 'suppressor', label = 'Tactical Suppressor', hash = `COMPONENT_SANDSTORMRIFLE_TACTICALSUPPRESSOR` },
},
},Restart, then give it with /giveweapon 1 WEAPON_SANDSTORMRIFLE 250, or in a server script with xPlayer.addWeapon('WEAPON_SANDSTORMRIFLE', 250).
Good to know
The ammo type is the one of the base, AMMO_RIFLE for the Sandstorm Rifle. Your existing rifle ammo items fill it, so ammo needs no new entry.
Several weapons on one server
Every weapon is its own resource with its own weapon name, model and slot, so any number can run side by side. Add one ensure line per weapon.
Keep them as separate resources. The Resource Merger is for props and does not take weapons.