CityRP Documentation Repository

cityrp.limits

Per-player spawn and ownership limit overrides. Each type is a cityrp.layers stack published to a cityrp.network var; every write lives in sv_playerlimits.lua. Named for load order: the Register calls below need sh_network.lua first.

Functions

Sharedcityrp.limits:CanSet(ply, name) → booleanSource ☍

Check whether a player is allowed to adjust a limit type on someone else. Moderator S2 and above get every type; Assistants and Event Managers only the team ones. Server-side only: HasAccess is accurate on the client for LocalPlayer alone.

Parameters

  • plyPlayerThe player running the command.
  • namestring|LIMIT_TYPEThe limit type, or its id/alias.

Returns

  1. booleanTrue if they may adjust this type.
Sharedcityrp.limits:CanSpawn(ply, name, counter) → boolean, stringSource ☍

Check whether a player is under their limit of a given type, by its spawn counter.

Parameters

  • plyPlayerThe player to check.
  • namestring|LIMIT_TYPEThe limit type, or its id/alias.
  • counterstring?The Player:GetCount counter to compare against. Defaults to the type's id.

Returns

  1. 1booleanTrue if they are below the limit.
  2. 2stringThe limit they were checked against, ready to show them.
Servercityrp.limits:DefineLayer(limit)Source ☍

Define a limit type's layer stack, unless it brings its own (props) or already has one: the combine reads the type at call time, so a re-registration needs no new stack.

Parameters

Sharedcityrp.limits:Describe(limit, value) → stringSource ☍

Describe a limit value the way it should be shown to a player.

Parameters

  • limitLIMIT_TYPEThe limit type the value belongs to.
  • valuenumberThe value to describe.

Returns

  1. stringEither "unlimited", or the value with the type's singular/plural name.
Sharedcityrp.limits:Get(ply, name) → numberSource ☍

Get a player's current effective limit of a given type.

Parameters

  • plyPlayerThe player to read the limit off.
  • namestring|LIMIT_TYPEThe limit type, or its id/alias.

Returns

  1. numberThe effective limit; cityrp.limits.UNLIMITED when they have none.
Sharedcityrp.limits:GetAll() → LIMIT_TYPE[]Source ☍

List every registered limit type, sorted by id.

Returns

  1. LIMIT_TYPE[]Every registered type.
Sharedcityrp.limits:GetSettable(ply) → LIMIT_TYPE[]Source ☍

List the limit types a player is allowed to adjust, sorted by id.

Parameters

  • plyPlayerThe player running the command.

Returns

  1. LIMIT_TYPE[]Every type they may adjust.
Sharedcityrp.limits:IsUnlimited(ply, name) → booleanSource ☍

Check whether a player has been left with no limit of a given type.

Parameters

  • plyPlayerThe player to read the limit off.
  • namestring|LIMIT_TYPEThe limit type, or its id/alias.

Returns

  1. booleanTrue if the player may spawn/own as many as they like.
Sharedcityrp.limits.PlayerCheckLimit(ply, counter) → boolean?Source ☍

Apply the light limit to the sandbox light and lamp counters, where the tools actually check. Never lifts a counter above its own sbox_max*: the two share one limit type, so a light override must not become a lamp allowance.

Parameters

  • plyPlayerThe player spawning a light or lamp.
  • counterstringThe sandbox counter being checked.

Returns

  1. boolean?True/false to override the sandbox limit, nil to let it decide.
Servercityrp.limits:RefreshDefaults(ply)Source ☍

Recompute every limit's base layer for a player. Call wherever an input to a default changes - rank, REP, membership, playtime, data load. An !limit override sits above the layer this touches, so a refresh never discards one.

Parameters

  • plyPlayerThe player to recompute.
Sharedcityrp.limits:Register(id, data) → LIMIT_TYPESource ☍

Register an adjustable limit type, and the network var its resolved value is published to.

Parameters

  • idstringCanonical id, used as the !limit type argument.
  • datatableThe type's definition. aliases is consumed here rather than stored on the type.

Returns

  1. LIMIT_TYPEThe registered type.
Servercityrp.limits:Reset(ply, name) → booleanSource ☍

Clear a player's limit override, putting them back on the default for their rank/REP.

Parameters

  • plyPlayerThe player to reset.
  • namestring|LIMIT_TYPEThe limit type, or its id/alias.

Returns

  1. booleanFalse if the type isn't registered.
Sharedcityrp.limits:Resolve(name) → LIMIT_TYPE?Source ☍

Resolve a player-supplied type name to its registered limit type.

Parameters

  • namestring?The type name or alias to look up. Case insensitive.

Returns

  1. LIMIT_TYPE?The matching type, or nil if the name isn't a known limit.
Servercityrp.limits:Set(ply, name, value) → booleanSource ☍

Set or clear a player's limit override.

Parameters

Returns

  1. booleanFalse if the type isn't registered.

Tables

Sharedcityrp.limits.LIGHT_COUNTERSSource ☍

Sandbox counters a light limit applies to, each with the ConVar sandbox would have capped it by. The light and lamp tools are unlocked together (cityrp.BlockedTools, GM:CanTool), so they are limited together, but they keep their own sbox ceilings.

Fields

Sharedcityrp.limitsSource ☍
Sharedcityrp.limits.aliasesSource ☍

Alias lookup, mapping every accepted spelling (including each id itself) to a canonical id.

Sharedcityrp.limits.DEFAULT_MAXSource ☍

Ceiling for a type that doesn't set its own max. Nobody needs 200 boomboxes, and the network var's codec is sized off this, so it is a real bound rather than advice.

Sharedcityrp.limits.FULL_ACCESSSource ☍

Access flag required to adjust any limit type.

Sharedcityrp.limits.LAYER_ADMINSource ☍

Layer holding the !limit override. Absent unless one has been set.

Sharedcityrp.limits.LAYER_DEFAULTSource ☍

Layer holding the base limit for the player's rank/REP/configuration.

Sharedcityrp.limits.loggerSource ☍

A namespaced, level-filterable logger. Obtain instances via cityrp.logging.GetLogger rather than constructing directly.

Sharedcityrp.limits.TEAM_ACCESSSource ☍

Access flag required to adjust the types marked team (Assistants and Event Managers).

Sharedcityrp.limits.typesSource ☍

Registered limit types, keyed by canonical id.

Sharedcityrp.limits.UNLIMITEDSource ☍

Value meaning "no limit at all".

LIMIT_TYPE

12 fields Source ☍

A single adjustable limit.

SharedLIMIT_TYPE.defaultSource ☍

The base value pushed onto the default layer. Omitted by types whose stack builds its base from several layers of its own.

SharedLIMIT_TYPE.fallbackSource ☍

The limit before any layer has resolved, and this var's registered network default.

SharedLIMIT_TYPE.idSource ☍

Canonical id, as registered. This is what !limit takes as its type argument.

SharedLIMIT_TYPE.layerSource ☍

The cityrp.layers attribute the limit stacks on.

SharedLIMIT_TYPE.maxSource ☍

Highest explicit value that may be set, and what the network codec is sized to.

SharedLIMIT_TYPE.minSource ☍

Lowest explicit value that may be set.

SharedLIMIT_TYPE.nameSource ☍

Singular display name.

SharedLIMIT_TYPE.pluralSource ☍

Plural display name.

SharedLIMIT_TYPE.refreshSource ☍

Recomputes this type's base layer(s) instead of the plain default push. Server only.

SharedLIMIT_TYPE.setSource ☍

Writes the admin override instead of the plain layer write. Server only.

SharedLIMIT_TYPE.teamSource ☍

Whether Assistants/Event Managers may adjust it, rather than Moderator S2+ only.

SharedLIMIT_TYPE.varSource ☍

The cityrp.network var the resolved limit is published to.