Summary
Hooks
cwStorage:GetRandomItems, optionally limited to one item category.Hooks
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;
falsewhenuniqueIDisnil
cwStorage:EntityBreached(entity, activator)
server gamemodes/catwork/plugins/storage/plugin/sv_hooks.lua:60Implements 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:21Called 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
falseto keep the entity
cwStorage:EntityHandleMenuOption(player, entity, option, arguments)
server gamemodes/catwork/plugins/storage/plugin/sv_hooks.lua:34Implements 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
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:110Adds 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
nilText the items' categories must contain, ignoring case
Returns
- Boolean
falsewhen 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:32Implements 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
Picks a random entry from cwStorage:GetRandomItems, optionally limited to one item category.
Parameters
- uniqueID String optional, defaults to
nilText the item's category must contain, ignoring case
Returns
- List The
{ uniqueID, weight }entry, ornilwhen 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:58Returns the random item entries whose item category contains a text.
Parameters
- category String optional, defaults to
nilText the item's category must contain, ignoring case; every entry whennilor empty
Returns
- List<List>
{ uniqueID, weight }entries
cwStorage:HUDPaintEntityTargetID(entity, info)
client gamemodes/catwork/plugins/storage/plugin/cl_hooks.lua:10Implements 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,yandalpha;yis advanced past the drawn lines
cwStorage:LoadStorage()
server deprecated gamemodes/catwork/plugins/storage/plugin/sv_plugin.lua:150Deprecated
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:160Opens 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
8The container's weight capacity
cwStorage:PlayerAdjustPropCostInfo(player, entity, info)
server gamemodes/catwork/plugins/storage/plugin/sv_hooks.lua:91Implements 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
costandname; changed in place
cwStorage:PlayerCanBreachEntity(player, entity)
server gamemodes/catwork/plugins/storage/plugin/sv_hooks.lua:11Implements 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
truefor a container with a password
cwStorage:PlayerStorageRebuilt(panel, categories)
client gamemodes/catwork/plugins/storage/plugin/cl_hooks.lua:46Implements 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:147Deprecated
Saving and loading are handled by the Static Entities plugin.
Does nothing; containers are saved by the Static Entities plugin.