func_buyzone

From Valve Developer Community
Jump to navigation Jump to search
English (en)Translate (Translate)
Buyzones usually touch all player spawns of an entire team.
Class hierarchy
CBuyZone
CBaseTrigger
CBaseToggle
CBaseEntity
func_buy_zone.cpp
Recycle-warning.png
This is a preserved entity.
If the game has round restart mechanics this entity may not behave as expected.

func_buyzone is a brush entity available in Counter-Strike seriesCounter-Strike series Counter-Strike series.

It is used to define areas where players of different teams can open the buy menu to purchase weapons and equipment.

If a player touches the volume of this entity and his team equals the team of this entity, then he is allowed to buy. Counter-Strike: Global Offensive If this entity has the team 0 or -1, then any or no player can buy inside this entity's volume, respectively.

Tip.pngTip:The SetTeam input can be used to change the buying team in-game.
Note.pngNote:Setting this entity's team to -1 and Disableing it have the same effect, just that these are independent operations.

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Team number (int) (TeamNum) <integer>
The team that can use the buyzone.
-1 Counter-Strike: Global Offensive No one
0 Counter-Strike: Global Offensive Everyone
2 Terrorists
3 Counter-Terrorists
other No one
Note.pngNote:Counter-Strike: Source doesn't support team-agnostic buyzones; this can be simulated with two identically shaped buyzones with different TeamNum values.
Legacy team number (team) <integer> !FGD Obsolete
Deprecated.
For backwards compatibility. Takes priority over TeamNum if set to 1 or 2.
1 Terrorists
2 Counter-Terrorists
BaseTrigger
Filter Name (filtername) <filter>
A filter entity to test potential activators against.
Start Disabled (StartDisabled) <boolean>
Stay dormant until activated (with theEnableinput).
Note.pngNote:This entity's trigger functionalities are !FGD but most can be used, such as the StartDisabled keyvalue and the Enable/Disable/Toggle inputs. Filter Name does not work. To use this entity's inherited trigger I/O (OnStartTouch, ...), set its spawnflags keyvalue appropriately (default is 4097). To add all of this in Hammer, see below.

Inputs

Warning.pngWarning:Counter-Strike: Global Offensive By default, this entity has the inputs SetEnabled/SetDisabled in Hammer, but it actually doesn't; Using these has no effect! Use Enable/Disable/Toggle instead. This can be fixed by editing csgo.fgd, searching for func_buyzone and replacing the incorrect input names. (The FGD code below fixes this differently.)
SetTeam <integerRedirectInput/integer>
Sets the team of this entity, which also sets the team that is allowed to buy.
SetTeam_TerroristOnly  (only in Counter-Strike: Global Offensive)
Restrict buyzone to Terrorists only. Equivalent to SetTeam 2.
SetTeam_CTOnly  (only in Counter-Strike: Global Offensive)
Restrict buyzone to Counter-Terrorists only. Equivalent to SetTeam 3.
SetTeam_AllTeams  (only in Counter-Strike: Global Offensive)
Allows all teams to use the buyzone. Equivalent to SetTeam 0.
SetTeam_None  (only in Counter-Strike: Global Offensive)
Allows no team to use the buyzone, effectively disabling it. Equivalent to SetTeam -1.
team <integerRedirectInput/integer> !FGD Obsolete
Deprecated.
Sets the team KV to the specified value. Since the KV is only analyzed during spawn, this input is useless.
BaseTrigger
Toggle
Toggles this trigger between enabled and disabled states.
Enable
Enable trigger
Disable
Disable trigger
TouchTest  (in all games since Source 2007)
Triggers either the OnTouching or OnNotTouching outputs for whether anything is touching this entity.
Icon-Bug.pngBug:Sleeping prop_physics will never fire "OnTouching". Also applies to entities using prop_physics as base.  (tested in: Half-Life 2)
StartTouch  (in all games since Source 2007) !FGD
Behave as if the !caller entity had just entered the trigger volume. Accepts non-physical entities.
EndTouch  (in all games since Source 2007) !FGD
Behave as if !caller had just exited the trigger volume.
DisableAndEndTouch  (only in Source 2013 MultiplayerTeam Fortress 2 branch)
Disables this trigger and calls EndTouch on all currently-touching entities.

Outputs

BaseTrigger
OnStartTouch
!activator = entity that caused this output
!caller = this entity
Fired when a valid entity starts touching this trigger.
OnStartTouchAll
!activator = entity that caused this output
!caller = this entity
Fired when a valid entity starts touching this trigger, and no other entities are touching it. If there are any other entities touching the trigger when a new one begins to touch, only OnStartTouch will fire.
OnEndTouch
!activator = entity that caused this output
!caller = this entity
Fired when a valid entity stops touching this trigger.
Note.pngNote:Will also fire for entities touching it when trigger is disabled via Disable input
Warning.pngWarning:This includes entities which are deleted while inside the trigger. In this case !activator will be invalid.
Warning.pngWarning:OnEndTouch can fire before OnStartTouch under certain circumstances[How?] where both are fired on the same tick and each have the same delay.
Note.pngFix:Add a slight delay to OnEndTouch.
OnEndTouchAll
!activator = entity that caused this output
!caller = this entity
Fired when all valid entities stop touching this trigger.
OnTouching  (in all games since Source 2007)
!activator = !caller = this entity
Fired if something is currently touching this trigger when TouchTest is fired.
OnNotTouching  (in all games since Source 2007)
!activator = !caller = this entity
Fired if nothing is currently touching this trigger when TouchTest is fired.

FGD Code

This code...

  • replaces its base class with Trigger which effectively adds trigger properties such as the keyvalue StartDisabled, the inputs and outputs Enable/Disable/Toggle/OnStartTouch/... and the trigger flags (1: Clients, ...).
  • adds the input TouchTest and the outputs OnTouching/OnNotTouching as seen in trigger_multiple of base.fgd.
  • removes the invalid inputs SetEnabled, SetDisabled.

Replace the corresponding lines of cstrike.fgd or csgo.fgd near func_buyzone with this.

Note.pngNote:Counter-Strike: Source The inputs SetTeam_[...] don't exist, so make sure not to add those four lines.
@SolidClass base(Trigger, TeamNum) = func_buyzone:  // "Targetname" -> "Trigger"
	"Buy Zone. Players can buy equipment while standing in this zone, if the zone matches their current team.\n\n" +
	"A single Buy Zone entity must be either terrorist or counter-terrorist, it cannot be both. Should have " +
	"the toolstrigger material applied to all sides"
	
[
//	input SetEnabled(void) : "Sets this buyzone as enabled."
//	input SetDisabled(void) : "Sets this buyzone as disabled."
	input TouchTest(void) : "Tests if the trigger is being touched and fires an output based on whether the value is true or false."

	input SetTeam_TerroristOnly(void) : "Make it so only terrorist can buy from this buyzone."
	input SetTeam_CTOnly(void) : "Make it so only CT's can buy from this buyzone."
	input SetTeam_AllTeams(void) : "Make it so all teams can buy from this buyzone."
	input SetTeam_None(void) : "Make it so no teams can buy from this buyzone (this essentially disables the buyzone)."

	output OnTouching(void) : "Fired when the TestTouch input is true (something is touching the trigger.)"
	output OnNotTouching(void) : "Fired when the TestTouch input is not true (nothing is touching the trigger.)"
]