Back to TPG

TPG.Weapons.ApplyState

S🏷️ Weapons

Part of TPG namespace

TPG.Weapons.ApplyState(state)
View on GitHub|gamemode/config/sh_weapons.lua:311-338
📋 Has LDoc👁️ 0 viewsUpdated 1 month ago

Description

Apply admin enable/override state on top of the discovered weapon lists. Shape of state: { bases = { [base] = bool }, weapons = { [id] = bool }, overrides = { [id] = { speedBonus = n, cost = n, name = s } } } Precedence per weapon: a base-level disable turns enabled off, then an explicit per-weapon entry in weapons overrides that either way, so a single weapon can be re-enabled even when its whole base is off. The "none" entry in each category is never touched -- it is always enabled and always free, regardless of state. Mutates the entry tables in TPG.Weapons.Primary/Secondary/Special IN PLACE rather than replacing them, so any table reference a caller already holds from TPG.GetWeapon changes under it when this runs; nothing here hands back a snapshot. Stores state on TPG.Weapons._state unconditionally (even before doing anything else), which is what lets TPG.Weapons.Discover re-apply it after a rebuild -- but it also means a bad or partial state table is kept as "current" the moment this is called, not only once applied successfully.

Parameters

NameTypeDescription
state?tableAdmin state, or nil/falsy to no-op.

Returns

No return values documented.

Examples

No examples available.

Used In

No usages found in the codebase.