Pick up the crowbar of research scientist Gordon Freeman, who finds himself on an alien-infested Earth being picked to the bone, its resources depleted, its populace dwindling. Freeman is thrust into the unenviable role of rescuing the world from the wrong he unleashed back at Black Mesa. And a lot of people, people he cares about, are counting on him.

Post tutorial Report RSS Trigger a console command when the player enters a trigger brush

Console command triggered when the player enters a trigger brush. The example used makes the Crosshair appear or disappear. Basic knowledge of hammer is assumed. This tutorial is ideal for cut-scenes where crosshairs get in the way.

Posted by on - Basic Mapping/Technical

[page=Trigger any console command when the player walks through a brush]
Console command triggered when the player enters a trigger brush. The example used makes the Crosshair appear or disappear. Basic knowledge of hammer is assumed and required. This tutorial is ideal for cut-scenes where pesky crosshairs get in the way.

For the sample map used in this tutorial click here.

In your map, create a point_clientcommand. Name it whatever you want, I'm using 'Client'.
Now create a trigger brush. This is where if you walk into your command will fire.

Name the trigger brush: Trigger (Or whatever you want, just make sure you use the same name later on if needed)
Now tie the trigger brush (Ctrl+T) to a trigger_once entity. Leave all of the options the same.

Make an output on the trigger:

My output named: OnStartTouch
Target entities named: Client
Via this input: Command
With a parameter override of: 'Console Command here'

Replace 'Console command here' with the command you wish to be triggered and bang! Done!

[page=Examples and conclusion]

This is great for cut-scenes in the middle of a game. Just follow the tutorial I showed you on the first page but instead of 'Console command here' have:

crosshair 0 (To remove the crosshair)
crosshair 1 (To make the crosshair appear)

Next, I'm going to show you how to turn the crosshair off when the map loads. This is off topic a little but never the less it still follows the same sort of guidelines.

Place a point_clientcommand very close to your info_player_start. Now name it whatever you want, I'm using 'Client2' so it doesn't clash with my previous tutorial. Now create a logic_auto close to it. You should use these on the outputs for the logic_auto:

My output named: OnMapSpawn
Target entities named: Client2
Via this input: Command
With a parameter override of: crosshair 0

To make it run smoother, tick the 'Fire once only' box. This doesn't particularly matter, but it may make the game less laggy.

From this tutorial you have hopefully learned how to create console commands on a trigger when the player walks through a brush. You should also be able to recognize the similar coding throughout my tutorial.

There you have it, a quick and easy way to run console commands without the player knowing it!

Post comment Comments
*Don*
*Don* - - 137 comments

whats up with all the #111's on the page?

Reply Good karma Bad karma+2 votes
Half_Kill
Half_Kill - - 59 comments

I think its suppose to be like this

1.
My Output name; OnStartTouch
2.
Target entities named; Client
3.
Via this input; Command
4.
With a parameter override ; "Command Here"

Reply Good karma Bad karma+2 votes
RancidRandy
RancidRandy - - 663 comments

Thanks for clarifying it.

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: