Skip to content

math_counter

Entity I/O / math_counter

Holds a numeric value and performs arithmetic operations upon it. If either the minimum or maximum legal value is nonzero, OutValue will be clamped to the legal range, and the OnHitMin/OnHitMax outputs will be fired at the appropriate times. If both min and max are set to zero, no clamping is performed and only the OutValue output will be fired.

  • FGD @PointClass in game/core/base.fgd, bases Targetname, EnableDisable.
  • cs_script type: Entity, what FindEntitiesByClass("math_counter") returns.
  • Native class: CMathCounter (curated pairing).

CS2 build 27045800 · Steam date 2026-11-30 · platform windows-x86_64 · schema format 2.2

Inputs (26)

NameParameterFromDescription
RunScriptFilestringVScriptLoad and execute a script file
RunScriptCodestringVScriptExecute a fragment of script code
CallScriptFunctionstringVScriptCall a script function
CallPrivateScriptFunctionstringVScriptCalls a script function from this entity's private script scope.
CallGlobalScriptFunctionstringVScriptCalls a script function in the global script scope.
KillGameEntityRemoves this entity from the world.
KillHierarchyGameEntityRemoves this entity and all its children from the world.
KillConstrainedGameEntityRemoves this entity, all its children, and anything constrained to it, from the world.
AddOutputstringGameEntityAdds an entity I/O connection to this entity. Parameter format: outputname>targetname>inputname>parameter>delay>max times to fire (-1 == infinite). Very dangerous, use with care.
FireUser1GameEntityCauses this entity's OnUser1 output to be fired.
FireUser2GameEntityCauses this entity's OnUser2 output to be fired.
FireUser3GameEntityCauses this entity's OnUser3 output to be fired.
FireUser4GameEntityCauses this entity's OnUser4 output to be fired.
EnableAutoSleepingGameEntityEnable automatic sleeping on this entity's physics bodies. When enabled, physics bodies go to sleep when at rest.
DisableAutoSleepingGameEntityDisable automatic sleeping on this entity's physics bodies. Bodies remain awake until explicitly put to sleep.
EnableEnableDisableEnable this entity.
DisableEnableDisableDisable this entity.
AddintegerAdd an amount to the counter and fire the OutValue output with the result.
DivideintegerDivide the counter by an amount and fire the OutValue output with the result.
MultiplyintegerMultiply the counter by an amount and fire the OutValue output with the result.
SetValueintegerSet the counter to a new value and fire the OutValue output with the result.
SetValueNoFireintegerSet the counter to a new value without firing any outputs.
SubtractintegerSubtract an amount from the counter and fire the OutValue output with the result.
SetHitMaxintegerSet the upper bound of the counter and fire the OutValue output with the current value.
SetHitMinintegerSet the lower bound of the counter and fire the OutValue output with the current value.
GetValueCauses the counter fire its OnGetValue output with the current value of the counter. Used for polling the counter when you don't want constant updates from the OutValue output.

Outputs (11)

NameParameterFromDescription
OnUser1GameEntityFired in response to FireUser1 input.
OnUser2GameEntityFired in response to FireUser2 input.
OnUser3GameEntityFired in response to FireUser3 input.
OnUser4GameEntityFired in response to FireUser4 input.
OnKilledGameEntityFired when the entity is killed and removed from the game. Parameter is the inflictor.
OutValueintegerFired when the counter value changes.
OnHitMinFired when the counter value meets or goes below the min value. The counter must go back above the min value before the output will fire again.
OnHitMaxFired when the counter value meets or exceeds the max value. The counter must go below the max value before the output will fire again.
OnChangedFromMinFired when the counter value changes from the minimum value.
OnChangedFromMaxFired when the counter value changes from the max value.
OnGetValueintegerFired in response to the GetValue input. Used for polling the counter when you don't want constant updates from the OutValue output.

Keyvalues (6)

The names Hammer saves and the KeyValue input and AddOutput take at run time. An entity reads some keys only when it spawns, so changing one later may do nothing. Integer keys such as movetype take engine numbers, not the renumbered cs_script enum values.

KeyTypeDefaultFromDescription
vscripts
Entity Scripts
scriptlistVScriptName(s) of script files that are executed after all entities have spawned.
targetname
Name
target_sourceTargetnameThe name that other entities refer to this entity by.
StartDisabled
Start Disabled
boolean0EnableDisable
startvalue
Initial Value
integer0Starting value for the counter.
min
Minimum Legal Value
integer0Minimum legal value for the counter. If min=0 and max=0, no clamping is performed.
max
Maximum Legal Value
integer0Maximum legal value for the counter. If min=0 and max=0, no clamping is performed.