Client Command by Trigger proximity
From Valve Developer Community
Sometimes, either for testing or gameplay purposes, you may need the client (player(s) on your map) to execute a console command. This tutorial explains how to make a console command which executes on the start of every round in CS:S and makes a single CT activate his flashlight. If you want things to be used multiple times, read at the end of this tutorial what you need to do.
| Table of contents |
|
|
Entity requirements
- Player spawn. e.g. info_player_start, info_player_counterterrorist, info_player_terrorist, etc.
- Trigger_proximity
- Point_clientcommand
- Logic_auto
- Information about client commands: Command, Console Command List, and Impulse
|
[edit] Tutorial
[edit] Setting up the point_clientcommand
Note: It doesn't matter where you put it, but a sensible place might be near the player spawn so you don't lose it.[edit] Setting up the trigger_proximity
[edit] Setting up the logic_auto
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Multiple ...
Triggers
For more triggers, like described in this tutorial, copy the point_clientcommand and the trigger_proximity. Rename them both to make sure they are only related to each other. Now place them at more player spawns.
| Player # | Name point_clientcommand | Name Trigger_proximity | Output Trigger_proximity |
|---|---|---|---|
| Player 1 | clientcommand | triggerprox_1 | clientcommand|Command|impulse 100|0.20|signed |
| Player 2 | clientcommand | triggerprox_2 | clientcommand|Command|impulse 100|0.20|signed |
etc.
Leave the logic_auto as it is, since it will automatically search for more triggerprox_ prefixes because of the wildcard (*).The clientcommand is still the same, because it will just execute the Client Command and does nothing else.
Commands
For multiple commands at a time, add more outputs to the trigger_proximity-entity:
| My output | Target entity | Target input | Parameter | Delay | Only once | Comments | ||
| OnUser1 | clientcommand | Command | impulse 100 | 0.20 | signed | Active the flashlight on Client's side | ||
| OnUser1 | clientcommand | Command | jpeg | 0.00 | signed | Create a screenshot on Client's side | ||
Tips for commands
For this tutorial, a flashlight (impulse 100) was used as a command. There are many others that come in handy. Feel free to add your own suggestions (including the Console Command, circumstances):
| Command | What does it do | Circumstances / Examples |
|---|---|---|
impulse 100 | Toggles flashlight | Dark maps |
bind "F12" "<command>" | Binds a key for a command | Binding a key to a certain command (only useful in Single Player). |
Note: Any command that has spaces(e.g. ent_fire <ent_name> <message>) requires double quotes. This will crash Hammer next time you load the level, as Hammer uses double quotes to separate parts of messages. Currently the only way around this(to my knowledge) is to use double quotes when compiling, which will work fine, but when exiting Hammer change the double quotes to single quotes(then save). Next time you load the map, remember to change them back to double quotes.Sample map
sdk_client_command_start_round__by_CrabbyData.vmf (13,3 kB)
Download mirrors:
- Mirror 1 (http://www.dutchlivealliance.nl/sdk_client_command_start_round__by_CrabbyData.vmf) From CrabbyData's site
- Mirror 2 (http://rapidshare.com/files/124542519/sdk_client_command_start_round__by_CrabbyData.vmf.html) RapidShare.com
- Mirror 3 (http://www.badongo.com/en/file/10026033) Badongo.com (complete the CAPTCHA on the right side of the page and click 'Download Your File Here')
