Hooks called by Containers

Summary

Hooks

Called on the server when a container prop is removed from a running server.
Called on the server before a container is opened for a player who has asked for it, and once more after they have entered its password.
Called on the server when a player has entered the password of a container, before the container is opened or the player is told that the password is wrong.
Called on the server when a container is opened for a player, after its inventory has been created or found and its opening sound played, right before the inventory is shown to the player.
Called on the server when a player is about to be asked for the password of a container that they may otherwise open.

Hooks

OnContainerRemoved(entity, spilled)

server plugins/containers/plugin/sv_plugin.lua:638

Called on the server when a container prop is removed from a running server. It is run for every removed prop with a container model, whether it held anything or not. The prop is still valid at this point and its inventory is not registered anymore; its items are dropped on the ground or destroyed on the next tick. It is not run when the map unloads or is cleaned up.

Parameters

  • entity Entity The container prop that is being removed
  • spilled Boolean true if the items are dropped on the ground, false if they are destroyed

Called from

Call sites

No documentation available.

Call sites

PlayerCanOpenContainer(actor, entity)

server plugins/containers/plugin/sv_plugin.lua:384

Called on the server before a container is opened for a player who has asked for it, and once more after they have entered its password. The entity is a container within reach of the player at this point.

Parameters

  • actor Player The player who wants to open the container
  • entity Entity The container prop

Returns

  • Boolean Return false to keep the container closed for the player
  • String Error phrase to notify the player with

Called from

Call sites

PlayerEnteredContainerPassword(actor, entity, correct)

server plugins/containers/plugin/sv_plugin.lua:455

Called on the server when a player has entered the password of a container, before the container is opened or the player is told that the password is wrong.

Parameters

  • actor Player The player who entered the password
  • entity Entity The container prop
  • correct Boolean Whether the password was right; also true if the password of the container was removed while the player was typing

Called from

  • submit_password

Call sites

PreContainerOpen(entity, actor)

server plugins/containers/plugin/sv_plugin.lua:414

Called on the server when a container is opened for a player, after its inventory has been created or found and its opening sound played, right before the inventory is shown to the player.

Parameters

  • entity Entity the container prop; its inventory is entity.inventory
  • actor Player the player the container is opened for

Called from

Call sites

ShouldAskContainerPassword(actor, entity)

server plugins/containers/plugin/sv_plugin.lua:531

Called on the server when a player is about to be asked for the password of a container that they may otherwise open.

Parameters

  • actor Player The player who wants to open the container
  • entity Entity The container prop

Returns

  • Boolean Return false to open the container for the player without the password

Called from

Call sites

Defined in