Shared definition of the cw_rationdispenser entity (print name Ration Dispenser), with its ration time, flash time and locked data table variables and ENT:IsLocked.

Summary

Methods

Prepares a ration for a player and dispenses it after a delay that depends on their tier.
Blocks every toolgun action on the dispenser.
Spawns a ration packet prop in front of the dispenser.
Draw()client
Draws the dispenser's status light.
Plays one random Combine button sound from the dispenser.
Sets up the invisible collision box and the parented Combine dispenser model.
Returns whether the dispenser is locked.
Lock()server
Locks the dispenser and plays a random button sound.
Keeps the dispenser still while nobody holds it and it is not constrained.
Flashes the status light red and plays the denied sound.
Declares the ration ready time, flash time and locked state data table variables.
Toggle()server
Locks the dispenser when it is unlocked and unlocks it when it is locked.
Unlock()server
Unlocks the dispenser and plays a random button sound.
Always transmits the dispenser to every client.
Dispenses a ration to a citizen or lets Combine lock and unlock the dispenser.

Methods

ENT:ActivateRation(activator, duration, force)

server gamemodes/cwhl2rp/schema/entities/entities/cw_rationdispenser/init.lua:102

Prepares a ration for a player and dispenses it after a delay that depends on their tier.

The ration tier and delay come from the player's loyalist tier (CWU get the orange tier): red ration_highest in 4 seconds down to ration_minimal in 26 seconds for unranked citizens. When the delay ends, the dispenser plays its animation and the packet prop becomes a frozen ration item owned by the player. Does nothing while a previous ration is still being prepared, unless forced.

Parameters

  • activator Player The player the ration is for
  • duration Number optional, defaults to nil Unused; the delay is always set from the tier
  • force Boolean optional, defaults to nil Whether to dispense even while another ration is being prepared

Blocks every toolgun action on the dispenser.

Parameters

  • player
  • trace
  • tool

Returns

  • Boolean Always false

Spawns a ration packet prop in front of the dispenser.

Parameters

  • customModel String optional, defaults to nil Model for the prop; defaults to the minimal tier packet

Returns

  • Entity The spawned prop_physics

Draws the dispenser's status light.

While a ration is being prepared the light flashes blue with a beep, faster as it nears completion. Otherwise it is green when unlocked, orange when locked and red during a refusal flash.

Plays one random Combine button sound from the dispenser.

Sets up the invisible collision box and the parented Combine dispenser model.

Returns whether the dispenser is locked.

Returns

  • Boolean Whether the dispenser is locked

Locks the dispenser and plays a random button sound.

Keeps the dispenser still while nobody holds it and it is not constrained.

Parameters

  • physicsObject

Flashes the status light red and plays the denied sound.

Parameters

  • duration Number How long the light flashes, in seconds

Declares the ration ready time, flash time and locked state data table variables.

Locks the dispenser when it is unlocked and unlocks it when it is locked.

Unlocks the dispenser and plays a random button sound.

Always transmits the dispenser to every client.

Dispenses a ration to a citizen or lets Combine lock and unlock the dispenser.

Citizens can collect one ration per hour (stored in the nextration character data); a locked dispenser or one used too early gives a red flash. Uses are ignored within 3 seconds of each other.

Parameters

  • activator
  • caller

Defined in