Adding the Stungrenade as an item
If you use a framework or an inventory script, you may need to make some changes to allow the stungrenade to work as an item.
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.
QB-Core (qb-core)
Note: This is for version 1.2.6 of qb-core (March 2023).
Set
Config.UseGameEvent
to false in Config.lua inside the stungrenade resource.Add
weapon_stungrenade
as an item inside qb-core/shared/items.lua like this:
Add
weapon_stungrenade
as an item inside qb-core/shared/weapons.lua like this:
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:
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.
Add it to your inventory script (See QB-Inventory or OX Inventory).
QB-Inventory
Add
or weaponName == "weapon_stungrenade" then
inside qb-inventory/client/main.lua on line 564 (line might be different) so the line looks like this:
Add an image named
weapon_stungrenade.png
inside qb-inventory/html/images.
PS-Inventory
Add
or weaponName == "weapon_stungrenade" then
inside ps-inventory/client/main.lua on line 597 (line might be different) so the line looks like this:
Add an image named
weapon_stungrenade.png
inside ps-inventory/html/images.
QS Inventory (qs-inventory)
Thanks to psycomantisx for providing info on adding throwable weapons to qs-inventory!
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 forweapon_grenade
and copy-paste it and replace the weapon name withweapon_stungrenade
.Add
stungrenade
inside theConfig.Throwables
table inside qs-inventory/config/weapons.lua.Add
weapon_stungrenade
inside qs-inventory/config/weapons.lua, again you can search for and copy-paste theweapon_grenade
entry.Add
weapon_stungrenade
inside qs-inventory/shared/items.lua, again you can search and copy-pasteweapon_grenade
and then simply replace the needed data.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.
Set
Config.UseGameEvent
to false in Config.lua inside the stungrenade resource.Add
weapon_stungrenade
as an item inside qbx_core/shared/items.lua like this:
Add it inside a shop (or make some other way of getting it, eg. a command)
Add it to your inventory script (See OX Inventory)
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.
Set
Config.UseGameEvent
to false in Config.lua inside the stungrenade resource (you can try with it on, but it may not work properly).Find the es_extended resource and open config.weapons.lua.
Add the following inside
Config.Weapons
:
Then add
["weapon_stungrenade"] = "Stun Grenade",
and["ammo_stungrenade"] = "stun grenade(s)",
inside your preferred localization file (es_extended/locales/en.lua for example). You can skip this step if you put the text directly into the config.weapons.lua file (replacing the TranslateCap functions), however, I do recommend that you use esx's localization system if you can.
OX Inventory
Only add WEAPON_STUNGRENADE as a weapon, and NOT an item.
Set
Config.OxInventory
to true inside Config.lua inside the stungrenade resource.Add 'WEAPON_STUNGRENADE' inside ox_inventory/data/weapons.lua like so (inside the Weapons table, NOT the Ammo table!):
Add an image named
WEAPON_STUNGRENADE.png
inside ox_inventory/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.
Last updated