Step1: Vending Machine-
Create a propstatic then adjust it's location in your map. Then open it's properties and set world model to "models/props/csoffice/Vending_machine.mdl" without the "" or if you've managed a custom mdl use that.
refer to screenshot1
Step2: Bottle & Dispenser-
Now we want to make the bottle and dispenser so that it shoots out of the machine but also making it look realistically and not getting in anyones way. (well thats really up to you.)
Well this is quite simple. Take your entity tool and create a env_shooter. Lets name it "shooter1" without the "".
Now set these settings:
Gib Direction: Direction in which you want your bottle to fire Number of Gibs: Set it to 1 so that no more than one fires out of the machine ;p Gib Angles: Orientation of the spawned bottle (standing up, on its side, etc) Gib Velocity: Speed in which the bottle is fired Course Varieance: slight variance in direction Gib Life: Set it to how many seconds you want your bottle to exist in your map (I set to 10) Model: Set this to models/props/csoffice/Waterbottle.mdl or your own custom mdl Material Sound: Set to NONE as the bottle will create it's own sound. Simulate: Set to Physics
Now under the flags tab check "Repeatable" so that it will fire more than just once.
refer to screenshot2
Now for our button. Create a brush using the tools/toolsinvisible material/texture covering your vending machines buttons. Tie it to the entity func_button.
Set up as so:
Sounds: Up to you I didnt add any. Delay Before Reset: Again up to you but I set it to 2 (seconds)
Under the flags tab check off "Don't move" and "Use Activates (which should already be checked by default)"
Under the Output tab create this line
OnPressed | shooter1 | shoot | 0.00 | No
Now when you press your button it will activate the envshooter firing off a bottle (if you placed the envshooter correctly with your tweaked settings it should pop out of the vending machines mouth realistically)
refer to screenshots 3 and 4
Good luck and enjoy.
Tats...
P.S. Thank you Samejima motivating me to find alternative and cleaning this up.
Edit: This is a new version of VendingMachine after playing with it a bit more I found this to be much simpler and add the effect I wanted. Hope it helps...
NOTE: I did NOT write this tutorial, it brought here for your own convenience. It was origanlly from HL2world.com.
Although, if you have an questions or comments, i can help you, my xfire is hedbanger999.
I hope this helped!








