ApexDocs
Developers

Weapons (WeaponGuard)

How Apex knows which weapons a player may hold, and how to control that list yourself.

WeaponGuard compares the weapon a player holds with the weapons they are allowed to have. A weapon that isn't in the list is a spawned weapon (antiWeaponSpawn / antiWeaponSpoofer).

WeaponGuard reads the allowed list from your inventory automatically. Supported out of the box:

  • ox_inventory
  • qs-inventory
  • codem-inventory
  • qb-inventory
  • ESX loadout / inventory

If your server uses one of these, you don't need to do anything. If no list can be read for a player, that player isn't checked at all (no false bans).

Manual control#

For custom inventories, set the list yourself from the server:

lua
-- replace the whole list
exports['ApexAC']:SetAuthorizedWeapons(source, { 'WEAPON_PISTOL', `WEAPON_STUNGUN` })

-- add / remove one weapon
exports['ApexAC']:AddAuthorizedWeapon(source, 'WEAPON_CARBINERIFLE')
exports['ApexAC']:RemoveAuthorizedWeapon(source, 'WEAPON_PISTOL')
Export Parameters Description
SetAuthorizedWeapons (playerId, list) Replaces the player's allowed weapons. Names or hashes.
AddAuthorizedWeapon (playerId, weapon) Adds one weapon.
RemoveAuthorizedWeapon (playerId, weapon) Removes one weapon.

Manual takes over

As soon as you call any of these for a player, Apex stops reading that player's inventory automatically until they disconnect. You then own the complete list — add every weapon they're allowed to carry.

Timing#

Update the list before you give the weapon (or in the same server event), then give it right away.

Weapon give (temporary)#

For a one-off weapon given by a script without an inventory (for example an event or minigame), you can also use allow(source, 'weapons', ms).