Back to TPG

TPG.Weapons.Discover

S🏷️ Weapons

Part of TPG namespace

TPG.Weapons.Discover()
View on GitHub|gamemode/config/sh_weapons.lua:187-280
📋 Has LDoc👁️ 0 viewsUpdated 1 month ago

Description

Rebuild TPG.Weapons.Primary/Secondary/Special from currently installed SWEPs. Starts each category with a "none" entry (always enabled, zero cost), then walks weapons.GetList() and keeps only SWEPs whose Base is allowed (cfg.Bases) and that pass passesExclude (explicit class exclusion, SubCategory exclusion, or a class-name pattern match). A kept SWEP is filed under the category from an explicit override or from its Slot; if neither maps to a known bucket, it is dropped silently rather than filed under something wrong. Virtual entries from cfg.Virtual (for multi-class or fallback weapons) are added on top of the discovered ones. Ammo counts (rounds) are computed once here via the local roundsFor, mirroring TopUpAmmo in player/sv_loadout.lua; nil means "does not consume ammo" (ACE's ClipSize -1 marker for tools/melee), not "zero ammo" -- callers must not print "nil rounds" as "0 rounds". After rebuilding, re-applies TPG.Weapons._state if a state was previously loaded via TPG.Weapons.ApplyState, so admin enable/override choices survive a rediscovery. On the server only, also logs any raw SubCategory strings seen that have no entry in SubCategoryAlias, as an operator note (nothing a player can act on). Called once at load and again on InitPostEntity; safe to call any time after that (e.g. tpg_weapons_refresh).

Parameters

No parameters.

Returns

No return values documented.

Examples

No examples available.

Used In

No usages found in the codebase.