Shared definition of the cw_vendingmachine entity (print name Vending Machine), with its stock, flash action and flash time data table variables and ENT:GetStock.

Summary

Methods

Blocks every toolgun action on the machine.
Takes one can from the stock and dispenses a random Breen's water in front of the machine.
Draw()client
Draws the machine with its status light.
Returns the stock the machine is refilled to on restock.
Returns how many cans the machine has left.
Adds to the machine's stock, clamped between 0 and the default stock.
Sets up the soda machine model and physics with an empty stock.
Keeps the machine still while nobody holds it and it is not constrained.
Restock()server
Refills the machine to its default stock with a flash and sound.
Flashes the machine's status light.
Sets the machine's stock and optionally its default stock.
Declares the stock, flash action and flash time data table variables.
Always transmits the machine to every client.
Sells a Breen's water to a citizen for 8 tokens, or lets Combine restock an empty machine.

Methods

Blocks every toolgun action on the machine.

Parameters

  • player
  • trace
  • tool

Returns

  • Boolean Always false

Takes one can from the stock and dispenses a random Breen's water in front of the machine.

Dispenses a special Breen's water 1 time in 20, a smooth one 10 times in 20 and a regular one otherwise.

Parameters

  • activator Player The buyer, recorded as the item entity's owner

Draws the machine with its status light.

The light is green when stocked, orange when empty, and while flashing blue after a sale or restock or red after a refused purchase.

Returns the stock the machine is refilled to on restock.

Returns

  • Number The default stock, 0 when none was set

Returns how many cans the machine has left.

Returns

  • Number The current stock

Adds to the machine's stock, clamped between 0 and the default stock.

Parameters

  • amount Number Cans to add; negative to take some away

Sets up the soda machine model and physics with an empty stock.

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

Parameters

  • physicsObject

Refills the machine to its default stock with a flash and sound.

Flashes the machine's status light.

Parameters

  • duration Number How long the light flashes, in seconds
  • action Boolean optional, defaults to nil true for a blue success flash; otherwise a red refusal flash with a sound

Sets the machine's stock and optionally its default stock.

Parameters

  • amount Number The new stock
  • default Any optional, defaults to nil A number to use as the default stock, or true to make amount the default

Declares the stock, flash action and flash time data table variables.

Always transmits the machine to every client.

Sells a Breen's water to a citizen for 8 tokens, or lets Combine restock an empty machine.

Citizens can buy once every 10 minutes; an empty machine, a player who cannot pay or one on cooldown gets a red flash. Uses are ignored within 3 seconds of each other and while the light flashes.

Parameters

  • activator
  • caller

Defined in