Summary

Hooks

Returns whether any random item has an item category containing the text.
Called when an entity has been breached; lets anyone open a password protected container for two minutes.
Called when an entity is about to be removed automatically; keeps containers that have been opened or named.
Called when a player picks an entity menu option; opens a container or lockers for the "Open" option.
Called when an entity is removed; drops the container's items and cash on the ground, unless the entity is a belongings bag or the server is shutting down.
Adds random items to a container until it weighs at least a share of its capacity.
Called when an entity's menu options are collected; adds an "Open" option to containers.
Picks a random entry from cwStorage:GetRandomItems, optionally limited to one item category.
Returns the entries random container filling picks from.
Returns the random item entries whose item category contains a text.
Called when an entity's target ID is painted; labels containers with their custom or default name and an "open" hint.
LoadStorage()server deprecated
Does nothing; containers are loaded by the Static Entities plugin.
Opens a container's storage for a player.
Called when a player's prop cost is worked out; names the charge after the container type.
Called when a player attempts to breach an entity; allows breaching password protected containers.
Called when the local player's storage panel is rebuilt; shows the container's message above its contents.
SaveStorage()server deprecated
Does nothing; containers are saved by the Static Entities plugin.

Hooks

cwStorage:CategoryExists(uniqueID)

server gamemodes/catwork/plugins/storage/plugin/sv_plugin.lua:94

Returns whether any random item has an item category containing the text.

Parameters

  • uniqueID String Text to look for in item categories, ignoring case

Returns

  • Boolean Whether a matching item exists; false when uniqueID is nil

cwStorage:EntityBreached(entity, activator)

server gamemodes/catwork/plugins/storage/plugin/sv_hooks.lua:60

Implements hook EntityBreached

Called when an entity has been breached; lets anyone open a password protected container for two minutes.

Parameters

  • entity Entity The breached entity
  • activator Entity The entity that breached it

cwStorage:EntityCanAutoRemove(entity)

server gamemodes/catwork/plugins/storage/plugin/sv_hooks.lua:21

Called when an entity is about to be removed automatically; keeps containers that have been opened or named.

Parameters

  • entity Entity The entity to remove

Returns

  • Boolean false to keep the entity

cwStorage:EntityHandleMenuOption(player, entity, option, arguments)

server gamemodes/catwork/plugins/storage/plugin/sv_hooks.lua:34

Implements hook EntityHandleMenuOption

Called when a player picks an entity menu option; opens a container or lockers for the "Open" option.

Password protected containers that are not breached ask the player for the password first.

Parameters

  • player Player The player who picked the option
  • entity Entity The entity the menu was for
  • option String The option label
  • arguments Any The option's arguments; 'cwContainerOpen' for the "Open" option

cwStorage:EntityRemoved(entity)

server gamemodes/catwork/plugins/storage/plugin/sv_hooks.lua:75

Called when an entity is removed; drops the container's items and cash on the ground, unless the entity is a belongings bag or the server is shutting down.

Parameters

  • entity Entity The removed entity

cwStorage:FillContainer(entity, scale, category)

server gamemodes/catwork/plugins/storage/plugin/sv_plugin.lua:110

Adds random items to a container until it weighs at least a share of its capacity.

The target weight is the container's capacity divided by 6 - scale. A prop without an inventory is made into storage first.

Parameters

  • entity Entity The container, a prop whose model is in cwStorage.containerList
  • scale Number How full to make it, from 1 (a fifth of the capacity) to 5 (all of it)
  • category String optional, defaults to nil Text the items' categories must contain, ignoring case

Returns

  • Boolean false when no item of that category exists, which leaves the container as it was

cwStorage:GetEntityMenuOptions(entity, options)

client gamemodes/catwork/plugins/storage/plugin/cl_hooks.lua:32

Implements hook GetEntityMenuOptions

Called when an entity's menu options are collected; adds an "Open" option to containers.

Parameters

  • entity Entity The entity the menu is for
  • options Map Option labels mapped to their arguments; changed in place

cwStorage:GetRandomItem(uniqueID)

server gamemodes/catwork/plugins/storage/plugin/sv_plugin.lua:83

Picks a random entry from cwStorage:GetRandomItems, optionally limited to one item category.

Parameters

  • uniqueID String optional, defaults to nil Text the item's category must contain, ignoring case

Returns

  • List The { uniqueID, weight } entry, or nil when no item matches

Returns the entries random container filling picks from.

The list holds every item that is not a base item and not marked isRareItem, and is built the first time it is needed.

Returns

  • List<List> { uniqueID, weight } entries

cwStorage:GetRandomItemsByCategory(category)

server gamemodes/catwork/plugins/storage/plugin/sv_plugin.lua:58

Returns the random item entries whose item category contains a text.

Parameters

  • category String optional, defaults to nil Text the item's category must contain, ignoring case; every entry when nil or empty

Returns

  • List<List> { uniqueID, weight } entries

cwStorage:HUDPaintEntityTargetID(entity, info)

client gamemodes/catwork/plugins/storage/plugin/cl_hooks.lua:10

Implements hook HUDPaintEntityTargetID

Called when an entity's target ID is painted; labels containers with their custom or default name and an "open" hint.

Parameters

  • entity Entity The entity being looked at
  • info Map Drawing state with x, y and alpha; y is advanced past the drawn lines

cwStorage:LoadStorage()

server deprecated gamemodes/catwork/plugins/storage/plugin/sv_plugin.lua:150

Deprecated

Saving and loading are handled by the Static Entities plugin.

Does nothing; containers are loaded by the Static Entities plugin.

cwStorage:OpenContainer(player, entity, weight)

server gamemodes/catwork/plugins/storage/plugin/sv_plugin.lua:160

Opens a container's storage for a player.

Creates the container's inventory and cash the first time, names the storage after the entity's custom name or its type, sends the container's message to the player and opens it with cw.storage:Open within a range of 192 units. Cash moved in or out is stored on the entity.

Parameters

  • player Player The player opening the container
  • entity Entity The container
  • weight Number optional, defaults to 8 The container's weight capacity

cwStorage:PlayerAdjustPropCostInfo(player, entity, info)

server gamemodes/catwork/plugins/storage/plugin/sv_hooks.lua:91

Implements hook PlayerAdjustPropCostInfo

Called when a player's prop cost is worked out; names the charge after the container type.

Parameters

  • player Player The player spawning the prop
  • entity Entity The spawned prop
  • info Map Prop cost info with cost and name; changed in place

cwStorage:PlayerCanBreachEntity(player, entity)

server gamemodes/catwork/plugins/storage/plugin/sv_hooks.lua:11

Implements hook PlayerCanBreachEntity

Called when a player attempts to breach an entity; allows breaching password protected containers.

Parameters

  • player Player The player breaching
  • entity Entity The entity to breach

Returns

  • Boolean true for a container with a password

cwStorage:PlayerStorageRebuilt(panel, categories)

client gamemodes/catwork/plugins/storage/plugin/cl_hooks.lua:46

Implements hook PlayerStorageRebuilt

Called when the local player's storage panel is rebuilt; shows the container's message above its contents.

Parameters

  • panel Panel The storage panel list
  • categories List The item categories shown in the panel

cwStorage:SaveStorage()

server deprecated gamemodes/catwork/plugins/storage/plugin/sv_plugin.lua:147

Deprecated

Saving and loading are handled by the Static Entities plugin.

Does nothing; containers are saved by the Static Entities plugin.

Defined in