> For the complete documentation index, see [llms.txt](https://docs.deltarix.store/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.deltarix.store/paid-assets/mdt-v2/exports/server/createweapon.md).

# CreateWeapon

***

Register a weapon

```lua
---@param serial string Serial of the weapon
---@param owner {source?: number, stateid?: string} Owner of the weapon (either a player server id or a stateid)
---@param model string Model name of the weapon (eg; weapon_assaultrifle)
---@param label string Name of the weapon (eg; AK 47)
exports.drx_mdt:CreateWeapon()
```

***

Example using source

```lua
local function createWeaponBySource(source)
  local serial = '123456789'
  local model = 'weapon_assaultrifle'
  local label = 'AK 47'

  exports.drx_mdt:CreateWeapon(serial, { source = source }, model, label)
end
```

Example using stateid

```lua
local function createWeaponByStateid(source)
  local stateid = exports.drx_mdt:GetStateId({ source = source })

  local serial = '123456789'
  local model = 'weapon_assaultrifle'
  local label = 'AK 47'

  exports.drx_mdt:CreateWeapon(serial, { stateid = stateid }, model, label)
end
```
