Ration Dispenser entity
Entity defined in plugin/entities/entities/cw_factoryrationdispenser
Part of Ration Factory
Shared definition of the cw_factoryrationdispenser entity of the Ration Factory plugin, with the networked ration
timer, flash timer, lock state and ration count, and IsLocked and GetRationCount.
Originally written for the Iron Wall community.
Summary
Methods
Methods
ENT:ActivateRation(activator, duration, force)
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:107Starts dispensing a ration to a player after a delay.
The ration's quality and delay depend on the player's civ_reputation character data:
ration_high after 8 seconds above 50 reputation (or for CWU members), ration_medium
after 12 above 25, ration_standard after 18 above 10, and ration_normal after 26
otherwise. When the delay ends the dispenser animates a package and spawns the ration item
for the player. Does nothing while a previous ration is still being dispensed.
Parameters
- activator Player The player who receives the ration
- duration Number optional, defaults to
nilUnused; the delay always comes from the reputation - force Boolean optional, defaults to
nilDispense even while a previous ration is still pending
ENT:CanTool(player, trace, tool)
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:248Blocks every toolgun action on the dispenser.
Parameters
- player
- trace
- tool
ENT:CreateDummyRation(model)
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:81Spawns a prop in front of the dispenser to play the dispensing animation with.
Parameters
- model String Model of the prop
Returns
- Entity The
prop_physicsprop
ENT:Draw()
client gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/cl_init.lua:31Draws the status light: blinking blue while dispensing, red when flashing, orange when locked, else green.
ENT:EmitRandomSound()
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:186Plays one of the Combine button sounds at random.
ENT:GetRationCount()
shared gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/shared.lua:32Returns how many rations the dispenser has left.
Returns
- Number The ration count
ENT:HUDPaintTargetID(x, y, alpha)
client gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/cl_init.lua:20Draws the dispenser's name and ration count for Combine players looking at it.
Parameters
- x
- y
- alpha
ENT:Initialize()
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:16Attaches the Combine dispenser model, sets up the collision box and starts with five rations.
ENT:IsLocked()
shared gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/shared.lua:26Returns whether the dispenser is locked.
Returns
- Boolean Whether the dispenser is locked
ENT:Lock()
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:60Locks the dispenser so citizens cannot take rations, with a button sound.
ENT:PhysicsUpdate(physicsObject)
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:199Keeps the dispenser still unless a player holds it or it is constrained.
Parameters
- physicsObject
ENT:SetFlashDuration(duration)
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:73Flashes the dispenser's light red with a denial sound.
Parameters
- duration Number How long the light stays red, in seconds
ENT:SetRationCount(count)
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:254Sets how many rations the dispenser holds.
Parameters
- count Number The new ration count
ENT:SetupDataTables()
shared gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/shared.lua:17Sets up the networked ration timer, flash timer, lock state and ration count.
ENT:Toggle()
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:51Locks the dispenser when it is unlocked and unlocks it otherwise.
ENT:Unlock()
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:66Unlocks the dispenser so citizens can take rations again, with a button sound.
ENT:UpdateTransmitState()
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:46Makes the dispenser always transmit to clients.
ENT:Use(activator, caller)
server gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua:212Handles a player using the dispenser, at most once every three seconds.
Citizens get a ration when the dispenser is unlocked, has rations left and their nextration
character data time has passed, which is then set ten wage intervals ahead; otherwise the
light flashes red. Combine players load a ration_standard from their inventory
into it, or toggle the lock when they carry none.
Parameters
- activator
- caller
Defined in
- gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/cl_init.lua
- gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/init.lua
- gamemodes/cwhl2rp/plugins/rationfactory/plugin/entities/entities/cw_factoryrationdispenser/shared.lua