Back to TPG

TPG.Util.GetPData

S🏷️ Util

Part of TPG namespace

TPG.Util.GetPData(ply, key, default)
View on GitHub|gamemode/core/sh_utils.lua:250-254
📋 Has LDoc👁️ 0 viewsUpdated 1 month ago

Description

Read a persistent per-player value. This is GMod's PData, so it lives in the server's sv.db keyed by SteamID and survives map changes and restarts. It is where a player's own choices go -- their loadout, their armor -- as opposed to their lifetime record, which is a file so that a leaderboard can see players who aren't connected (see tpg.stats). Every key is prefixed with TPG_ so the gamemode can never collide with another addon's PData on the same server. PData stores strings. The value comes back as a number if it looks like one, which is what lets the callers store an armor id and get an armor id back rather than "3". else default.

Parameters

NameTypeDescription
plyPlayer
keystringKey, without the TPG_ prefix.
default?anyReturned when nothing is stored.

Returns

TypeDescription
anyThe stored value as a number where possible, else a string,

Examples

No examples available.

Used In

No usages found in the codebase.