CityRP Documentation Repository

ITEM.Spawnable

The spawnable item base. For items which produce an in-world entity.

Registration ID
base_spawnable
Inherits
ITEM → ITEM.Spawnable

Functions

SharedITEM:canDestroy(ply, pos) → boolean, stringSource ☍

canDestroy hook/override for this item base.

Parameters

  • plyPlayer
  • posunknown) return self:canReduce(ply any

Returns

  1. 1boolean
  2. 2string
SharedITEM:canDrop(ply, pos) → boolean, stringSource ☍

canDrop hook/override for this item base.

Parameters

  • plyPlayer
  • posunknown) return self:canReduce(ply any

Returns

  1. 1boolean
  2. 2string
SharedITEM:canGive(ply, to, amt) → boolean, stringSource ☍

canGive hook/override for this item base.

Parameters

  • plyPlayer
  • toPlayer
  • amtnumber) return self:canReduce(ply any

Returns

  1. 1boolean
  2. 2string
SharedITEM:canReduce(ply, action, count) → boolean, string?Source ☍

Checks if a player can reduce the number of items in their inventory.

Parameters

  • plyPlayerPlayer reducing.
  • actionstringThe action they're taking (giving, dropping, etc)
  • countnumber?The number of items being removed.

Returns

  1. 1booleanthe reduction was allowed.
  2. 2string?message if reduction failed.
SharedITEM:canSpawn(ply) → boolean, string?Source ☍

Rank/access/skill eligibility gate for this item, independent of where or how it's being placed. canUse always defers to this first, so an override here covers both normal placement and an AdvDupe2 paste (which has no meaningful aim position to distance-check) from one place. Defaults to always allowed.

Parameters

Returns

  1. 1boolean
  2. 2string?
SharedITEM:canUse(ply) → boolean, string|unknown|nilSource ☍

canUse hook/override for this item base.

Parameters

Returns

  1. 1boolean
  2. 2string|unknown|nil
SharedITEM:getSpawnLimit(ply) → numberSource ☍

Resolves the max number of this item a player may have placed at once - reused by AdvDupe2 paste validation so the cap has one source of truth.

Parameters

Returns

  1. number-1 for unlimited.
SharedITEM:onDestroy()Source ☍

onDestroy hook/override for this item base.

SharedITEM:onDrop()Source ☍

onDrop hook/override for this item base.

SharedITEM:onGive()Source ☍

onGive hook/override for this item base.

SharedITEM:onSpawned(ply, ent, meta)Source ☍

onSpawned hook/override for this item base. Runs after the entity has spawned and been assigned its owner/limiter count, before the single-use inventory removal, letting a spawnable item do post-spawn setup (e.g. contraband tracking) without overriding onUse entirely.

Parameters

SharedITEM:onUse(ply, pos, meta) → booleanSource ☍

onUse hook/override for this item base.

Parameters

Returns

  1. boolean

Fields

SharedITEM.SetAutoOwnerSource ☍

Sets if the spawned entity is automatically owned by the player for prop protection.

SharedITEM.SetClassSource ☍

Sets the SENT ID which this item spawns.

SharedITEM.SetInvLimitedSource ☍

Sets if this item is limited by the number of items currently available in the inventory. See fire alarms for example.

SharedITEM.SetLimitSource ☍

Sets if a limited number of these items can be spawned. See fire alarms for example.

SharedITEM.SetLimiterSource ☍

Sets the Limter class which limits the total count of this item. When set, spawning calls ply:GetCount(data). Could be more aptly defined as SetCounter.

SharedITEM.SetMaxSpawnDistSource ☍

Set the maximum distance away that this item can be spawned.

SharedITEM.SetSingleUseSource ☍

Sets if this item is single use (removed from the inventory after placing)