Ration Dispenser entity
Entity defined in entities/entities/cw_rationdispenser
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
Methods
ENT:ActivateRation(activator, duration, force)
server gamemodes/cwhl2rp/schema/entities/entities/cw_rationdispenser/init.lua:102Prepares 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
nilUnused; the delay is always set from the tier - force Boolean optional, defaults to
nilWhether to dispense even while another ration is being prepared
ENT:CanTool(player, trace, tool)
server gamemodes/cwhl2rp/schema/entities/entities/cw_rationdispenser/init.lua:243Blocks every toolgun action on the dispenser.
Parameters
- player
- trace
- tool
Returns
- Boolean Always
false
ENT:CreateDummyRation(customModel)
server gamemodes/cwhl2rp/schema/entities/entities/cw_rationdispenser/init.lua:77Spawns a ration packet prop in front of the dispenser.
Parameters
- customModel String optional, defaults to
nilModel 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.
ENT:EmitRandomSound()
server gamemodes/cwhl2rp/schema/entities/entities/cw_rationdispenser/init.lua:192Plays 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.
ENT:PhysicsUpdate(physicsObject)
server gamemodes/cwhl2rp/schema/entities/entities/cw_rationdispenser/init.lua:205Keeps the dispenser still while nobody holds it and it is not constrained.
Parameters
- physicsObject
ENT:SetFlashDuration(duration)
server gamemodes/cwhl2rp/schema/entities/entities/cw_rationdispenser/init.lua:69Flashes the status light red and plays the denied sound.
Parameters
- duration Number How long the light flashes, in seconds
ENT:SetupDataTables()
shared gamemodes/cwhl2rp/schema/entities/entities/cw_rationdispenser/shared.lua:15Declares 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.
ENT:UpdateTransmitState()
server gamemodes/cwhl2rp/schema/entities/entities/cw_rationdispenser/init.lua:42Always transmits the dispenser to every client.
ENT:Use(activator, caller)
server gamemodes/cwhl2rp/schema/entities/entities/cw_rationdispenser/init.lua:216Dispenses 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