# Adding the Stungrenade as an item

{% hint style="danger" %}
**IMPORTANT NOTE:** If you use an escrowed inventory that doesn’t support addon-throwing weapons then I can’t help you. It’s a problem with the inventory script, not with this script.
{% endhint %}

## QB-Core (qb-core)

**Note**: This is for version 1.2.6 of qb-core (March 2023).

1. Set `Config.UseGameEvent` to **false** in Config.lua inside the stungrenade resource.
2. Add `weapon_stungrenade` as an item inside [qb-core/shared/items.lua](https://github.com/qbcore-framework/qb-core/blob/main/shared/items.lua) like this:

```lua
weapon_stungrenade = { name = 'weapon_stungrenade', label = 'Stun Grenade', weight = 1000, type = 'weapon', ammotype = nil, image = 'weapon_stungrenade.png', unique = true, useable = false, description = 'This blinds people!' },
```

3. Add `weapon_stungrenade` as an item inside [qb-core/shared/weapons.lua](https://github.com/qbcore-framework/qb-core/blob/main/shared/weapons.lua) like this:

```lua
[`weapon_stungrenade`] = { name = 'weapon_stungrenade', label = 'Stun Grenade', weight = 1000, type = 'weapon', ammotype = nil, image = 'weapon_stungrenade.png', unique = true, useable = false, description = 'This blinds people!' },
```

3. Add it in qb-weapons:

**NOTE:** This step (3) can be skipped if you are using OX Inventory.

***If you are using an older version (pre-February 16th 2023 / v. 1.2.0) then do the following:***\
Add the following code to the `prison:server:checkThrowable` callback in server/main.lua:

```lua
elseif QBCore.Shared.Weapons[weapon]["name"] == "weapon_stungrenade" then
    Player.Functions.RemoveItem("weapon_stungrenade", 1)
```

And add `weapon_stungrenade` inside `Config.DurabilityMultiplier` in the config.lua file.

***Or if you are using a newer version (version 1.2.1 or newer) then do the following:***\
Add `stungrenade` inside `Config.Throwables` and `weapon_stungrenade` inside `Config.DurabilityMultiplier` in the config.lua file.

4. Add it to your inventory script (See [#qb-inventory](#qb-inventory "mention") or [#ox-inventory](#ox-inventory "mention")).

## QB-Inventory

1. Add `or weaponName == "weapon_stungrenade" then` inside [qb-inventory/client/main.lua](https://github.com/qbcore-framework/qb-inventory/blob/main/client/main.lua#L564) on line 564 (line might be different) so the line looks like this:

```lua
elseif weaponName == 'weapon_stickybomb' or weaponName == 'weapon_pipebomb' or weaponName == 'weapon_smokegrenade' or weaponName == 'weapon_flare' or weaponName == 'weapon_proxmine' or weaponName == 'weapon_ball' or weaponName == 'weapon_molotov' or weaponName == 'weapon_grenade' or weaponName == 'weapon_bzgas' or weaponName == 'weapon_stungrenade' then
```

2. Add an image named `weapon_stungrenade.png` inside [qb-inventory/html/images](https://github.com/qbcore-framework/qb-inventory/tree/main/html/images).

## PS-Inventory

1. Add `or weaponName == "weapon_stungrenade" then` inside [ps-inventory/client/main.lua](https://github.com/Project-Sloth/ps-inventory/blob/main/client/main.lua#L597) on line 597 (line might be different) so the line looks like this:

```lua
elseif weaponName == "weapon_stickybomb" or weaponName == "weapon_pipebomb" or weaponName == "weapon_smokegrenade" or weaponName == "weapon_flare" or weaponName == "weapon_proxmine" or weaponName == "weapon_ball" or weaponName == "weapon_molotov" or weaponName == "weapon_grenade" or weaponName == "weapon_bzgas" or weaponName == "weapon_stungrenade" then
```

2. Add an image named `weapon_stungrenade.png` inside [ps-inventory/html/images](https://github.com/Project-Sloth/ps-inventory/tree/main/html/images).

## QS Inventory (qs-inventory)

Thanks to psycomantisx for providing info on adding throwable weapons to qs-inventory!

1. Similar to both ps and qb inventory you need to add the following: `or weaponName == "weapon_stungrenade" then` inside qs-inventory/client/custom/misc/UseWeapon.lua. If you are unsure of what line this is on then search for `weapon_grenade` and copy-paste it and replace the weapon name with `weapon_stungrenade`.&#x20;
2. Add `stungrenade` inside the `Config.Throwables` table inside qs-inventory/config/weapons.lua.
3. Add `weapon_stungrenade` inside qs-inventory/config/weapons.lua, again you can search for and copy-paste the `weapon_grenade` entry.
4. Add `weapon_stungrenade` inside qs-inventory/shared/items.lua, again you can search and copy-paste `weapon_grenade` and then simply replace the needed data.
5. Add `weapon_stungrenade` inside qs-inventory/shared/weapons.lua (again use the search and copy-paste tactic).

## Qbox (qbx\_core)

**Note 13.03.2024: This guide is outdated! I will update it soon!**

Note: Since Qbox is in active development the following steps may be different in the future. This was last tested in late November 2023. The following steps are pretty close to the qbcore steps as of now.

1. Set `Config.UseGameEvent` to **false** in Config.lua inside the stungrenade resource.
2. Add `weapon_stungrenade` as an item inside [qbx\_core/shared/items.lua](https://github.com/Qbox-project/qbx_core/blob/main/shared/items.lua) like this:

```lua
['weapon_stungrenade'] = {['name'] = 'weapon_stungrenade', ['label'] = 'Stun Grenade', ['weight'] = 1000, ['type'] = 'weapon', ['ammotype'] = nil, ['image'] = 'weapon_stungrenade.png', ['unique'] = true, ['useable'] = false, ['description'] = 'This blinds people!'},
```

3. Add it inside a shop (or make some other way of getting it, eg. a command)
4. Add it to your inventory script (See [#ox-inventory](#ox-inventory "mention"))

## ESX (es\_extended)

**Note:** This is for version 1.10.2 of ESX Legacy, yours may be different depending on the version of esx that you are running.

1. Set `Config.UseGameEvent` to **false** in Config.lua inside the stungrenade resource (you can try with it on, but it may not work properly).
2. Find the es\_extended resource and open [config.weapons.lua](https://github.com/esx-framework/esx_core/blob/main/\[core]/es_extended/config.weapons.lua).
3. Add the following inside `Config.Weapons`:

```lua
{ name = 'WEAPON_STUNGRENADE', label = TranslateCap('weapon_stungrenade'), components = {}, ammo = { label = TranslateCap('ammo_stungrenade'), hash = `AMMO_STUNGRENADE` } }
```

4. Then add `["weapon_stungrenade"] = "Stun Grenade",` and `["ammo_stungrenade"] = "stun grenade(s)",` inside your preferred localization file ([es\_extended/locales/en.lua](https://github.com/esx-framework/esx_core/blob/main/\[core]/es_extended/locales/en.lua) for example). You can skip this step if you put the text directly into the [config.weapons.lua](https://github.com/esx-framework/esx_core/blob/main/\[core]/es_extended/config.weapons.lua) file (replacing the TranslateCap functions), however, I do recommend that you use esx's localization system if you can.

## OX Inventory

{% hint style="warning" %}
Only add WEAPON\_STUNGRENADE as a weapon, and NOT an item.
{% endhint %}

1. Set `Config.OxInventory` to **true** inside Config.lua inside the stungrenade resource.
2. Add 'WEAPON\_STUNGRENADE' inside ox\_inventory/data/weapons.lua like so (inside the Weapons table, NOT the Ammo table!):

```lua
['WEAPON_STUNGRENADE'] = {
    label = 'Stun Grenade',
    weight = 600,
    throwable = true
},
```

3. Add an image named `WEAPON_STUNGRENADE.png` inside [ox\_inventory/web/images](https://github.com/overextended/ox_inventory/tree/main/web/images).

## Standalone/vMenu

The spawn code/name for the stungrenade is `WEAPON_STUNGRENADE`.  For adding this to vMenu please read their docs: [https://docs.vespura.com/vmenu/configuration/addons.json](https://docs.vespura.com/vmenu/configuration/addons.json/).
