Back to TPG

TPG.Gear.Claim

S🏷️ Gearsystem

Part of TPG namespace

TPG.Gear.Claim(ply, kind, id)
View on GitHub|gamemode/systems/sv_gear.lua:119-196
📋 Has LDoc👁️ 0 viewsUpdated 1 month ago

Description

Take an item, paying whatever this round's price is. Free items (no TPG.Gear.Price entry) always succeed and cost nothing, so callers can run every pick through here without checking first. Already bought this life? Then it's yours, and re-spawning to change a different slot doesn't buy it again. This is what makes the loadout menu's respawn button safe to press: it used to charge once per SPAWN, which meant tweaking your sidearm and respawning billed you a second time for the Javelin you'd bought and never fired -- and in a team-budget round it denied the Javelin outright, because the cooldown it had started ten seconds earlier was still running. pState.gearPaidThisLife is what fixes that; it's cleared on a real death (see the PlayerDeath hook below), so it only ever covers the life actually paid for. "invalid" for an invalid player), absent on success. the cost, so the caller can say something useful instead of "denied".

Parameters

NameTypeDescription
plyPlayer
kindstring
idstring

Returns

TypeDescription
booleanTrue on success.
stringFailure reason, `"cooldown"` or `"afford"` (also
numberThe number that goes with the reason: seconds left, or

Examples

No examples available.

Used In

No usages found in the codebase.