Skip to content

cs_script API

Every declaration in cs_script/point_script, the module a point_script entity's JavaScript imports. It is generated from Valve's own point_script.d.ts (content/csgo_addons/cs_script_demo/maps/scripts/point_script.d.ts in the Workshop Tools), so the docs below are Valve's. Scripts run as es2022. New to cs_script? Start with Getting started. A typings file with every Hammer classname, input and output is on the codegen schemas page, and API changes between builds show up in the changelog.

CS2 build 27045800 · Steam date 2026-11-30 · platform windows-x86_64 · schema format 2.2 · d.ts sha256 20a4fcd50eac

Valve's module notes

`"cs_script/point_script"` is the module provided to scripts loaded for point_script entities. # Setup: - Create a JavaScript file (.js) that imports this module. - See `hello.js` for an example. - Create a point_script entity in your map and set its cs_script field to reference your JavaScript file as a vjs asset. - See example addon cs_script_demo. There is a point_script entity in the cs_script_demo.vmap named "hello_cs_script" that runs `hello.js`. There are a handful of other examples as well. # Execution: - The compiled version of your script (.vjs_c) will be loaded during map load. - When the point_script entity is spawned it will execute all code at the top level scope of your script. - Register callbacks on `Instance` to setup code that executes at various times throughout the lifetime of the map. - A function passed to `Instance.OnActivate` will be invoked when the point_script entity is activated. - A function passed to `Instance.OnPlayerJump` will be invoked when any player in the map jumps. # Tips: - Entity variables are stable. Two variables referring to the same entity will be reference equals (===). - Extra values attached to an entity variable will still be there if the variable is fetched again. - A map can have multiple point_script entities. Each script will run with its own Instance, set of globals, and set of entity variables. # Tools Mode: - In tools mode, saving changes to your script will recompile your file, clear all registered callbacks, and re-run the top level scope of your script. - Global variables and instances of entity variables will persist across reloads. - Beware. This is an avenue for holding references to code from previous iterations of your script. This is only a concern in tools mode. - See `Instance.OnScriptReload` for a tool to handle edge cases around reloading.

Exports

ExportType
InstanceIPointScript
ConsoleIConsole
GameRulesIGameRules
EntitiesIEntities

Hooks

Callbacks registered on Instance. cs_script has no generic game-event listener, so these 41 hooks are the whole set of game moments a script can react to. The Game event column names the event from the game-event registry that reports the same moment, for readers coming from server plugins or demo parsing. It is a pairing by name and documentation (docs/overlays/cs_script.yml), marked unverified until someone confirms it in game.

HookCallbackGame eventDescription
OnScriptReloadOnScriptReload<T>(config: { before?: () => T, after?: (memory: T) => void }): voidCalled in Tools mode when the script is reloaded due to changes.
The before callback will be invoked before pre-load teardown.
The after callback will be invoked after the new script is evaluated and will be passed the return value of the before callback.
OnActivate() => voidCalled when the point_script entity is activated
OnScriptInput(inputData: { caller?: Entity, activator?: Entity }) => voidCalled when input RunScriptInput is triggered on the point_script entity with a parameter value that matches name.
OnPlayerConnect(event: { player: CSPlayerController }) => voidunverifiedCalled when a client finishes the initial connection handshake with the server.
OnPlayerActivate(event: { player: CSPlayerController }) => voidunverifiedCalled when a client finishes loading and is ready to spawn.
OnPlayerDisconnect(event: { playerSlot: number }) => voidunverifiedCalled when a client disconnects from the server.
OnPlayerReset(event: { player: CSPlayerPawn }) => voidunverifiedCalled when a player respawns, changes team, or is placed back at spawn due to a round restart
Also fires on a team change and on a round-restart respawn.
OnBotControl(event: { controller: CSPlayerController }) => voidCalled when a player takes or releases control of a bot.
OnPlayerTeamChanged(event: { player: CSPlayerPawn, oldTeam: number }) => voidunverifiedCalled when a player changes team
OnRoundStart() => voidunverifiedCalled when a new round begins
OnRoundEnd(event: { winningTeam: number, reason: CSRoundEndReason }) => voidunverifiedCalled when a team wins a round
OnBeginRoundRestart() => voidunverifiedCalled at the start of cleanup for a round restart
OnBombPlantStart(event: { planter: CSPlayerPawn }) => voidunverifiedCalled when a player starts planting their c4
OnBombPlantAbort(event: { planter: CSPlayerPawn }) => voidunverifiedCalled when a player aborts planting their c4
OnBombPlant(event: BombPlantEvent) => voidunverifiedCalled when a player plants their c4
OnBombDefuseStart(event: { plantedC4: CSPlantedC4 }) => voidunverifiedCalled when a player starts defusing a c4
OnBombDefuseAbort(event: { plantedC4: CSPlantedC4 }) => voidunverifiedCalled when a player aborts defusing a c4
OnBombDefuse(event: BombDefuseEvent) => voidunverifiedCalled when a player defuses a c4
OnBombExplode(event: { plantedC4: CSPlantedC4 }) => voidunverifiedCalled when a c4 explodes
OnHostagePickUpStart(event: { hostage: CSHostage }) => voidnoneCalled when a player starts picking up a hostage
OnHostagePickUpAbort(event: { hostage: CSHostage, player: CSPlayerPawn }) => voidnoneCalled when a player aborts picking up a hostage
OnHostagePickUp(event: { hostage: CSHostage }) => voidunverifiedCalled when a player finishes picking up a hostage
OnHostageDrop(event: { hostage: CSHostage, dropper: CSPlayerPawn }) => voidunverifiedCalled when a carried hostage is dropped without being rescued
OnHostageRescue(event: { hostage: CSHostage }) => voidunverifiedCalled when a hostage reaches a rescue zone
OnHostageKill(event: { hostage: CSHostage, attacker?: CSPlayerPawn }) => voidunverifiedCalled when a hostage is killed
OnModifyPlayerDamage(event: ModifyPlayerDamageEvent) => ModfiyPlayerDamageResult | voidnoneCalled immediately before a CSPlayerPawn takes damage to armor and health.
Called after hitgroup modifications are applied such as headshot multiplier.
This won't be called if the player would take no damage. Such as if they're frozen or invulnerable or if friendly fire would disable the damage.
Runs before damage is applied, so no event exists yet; player_hurt follows it.
OnPlayerDamage(event: PlayerDamageEvent) => voidunverifiedCalled when a player has taken damage.
OnPlayerKill(event: { player: CSPlayerPawn, inflictor?: Entity, attacker?: Entity, weapon?: CSWeaponBase }) => voidunverifiedCalled when a player dies. inflictor, attacker and weapon will match the damage event that caused the kill.
OnPlayerJump(event: { player: CSPlayerPawn }) => voidunverifiedCalled when a player jumps off the ground.
OnPlayerLand(event: { player: CSPlayerPawn }) => voidnoneCalled when a player hits the ground while falling.
OnPlayerChat(event: { player?: CSPlayerController, text: string, team: number }) => voidunverifiedCalled when a player sends a chat message. team will match they player's team if the message was sent to team chat.
OnPlayerPing(event: { player: CSPlayerController, position: Vector }) => voidunverifiedCalled when a player pings a location.
OnGunReload(event: { weapon: CSWeaponBase }) => voidunverifiedCalled when a gun is reloaded.
OnGunFire(event: { weapon: CSWeaponBase }) => voidunverifiedCalled when a gun emits bullets. A shotgun will only trigger this once when emitting multiple bullets at once.
OnBulletImpact(event: { weapon: CSWeaponBase, position: Vector, hitEntity?: Entity }) => voidunverifiedCalled when a bullet hits a surface.
Penetrations can cause a single bullet to trigger multiple impacts.
This will be called for all impacts of a bullet before any player damage events are called.
OnWeaponDrop(event: { weapon: CSWeaponBase, dropper: CSPlayerPawn }) => voidunverifiedCalled when a weapon is dropped.
There is no weapon_drop event; item_remove is the nearest and also fires when an item is removed for other reasons.
OnWeaponPickup(event: { weapon: CSWeaponBase }) => voidunverifiedCalled when a weapon is picked up.
OnGrenadeThrow(event: { weapon: CSWeaponBase, projectile: CSGrenadeProjectileBase }) => voidunverifiedCalled when a grenade is thrown. projectile is the newly created grenade projectile.
OnGrenadeBounce(event: GrenadeBounceEvent) => voidunverifiedCalled when a grenade bounces.
OnKnifeAttack(event: { weapon: CSWeaponBase, attackType: CSWeaponAttackType }) => voidnoneCalled when a knife attacks, even if it misses.
OnCustomHudClicked(event: { player: CSPlayerController, layout: CustomHudLayout, buttonId: string }) => voidnoneCalled when a button in a CustomHudLayout is clicked.

Deprecated, kept for old scripts: OnBeforePlayerDamage, OnBeforeReload, OnReload.

Entity classes

What FindEntityByName, FindEntitiesByClass and the hooks hand back. A script object only exposes the methods listed on its page. Classnames lists what to pass to FindEntitiesByClass to get this type back: the Hammer classnames (through the curated docs/overlays/entity_classnames.yml) and the ones the game creates itself, such as player for every player pawn.

Interfaces

The exported singletons' types (IPointScript, IConsole, IGameRules) and the shapes of event payloads, trace configs and results.

Type aliases

AliasDefinition
Color{ r: number, g: number, b: number, a: number }
ColorArg{ r: number, g: number, b: number, a?: number }
EntityKeyValueboolean | number | string | Vector | QAngle
InputValueboolean | number | string | Vector | Color | undefined
QAngle{ pitch: number, yaw: number, roll: number }
RotationVector{ x: number, y: number, z: number }
SpawnGrenadeProjectileConfigSpawnGrenadeProjectileConfigWithOwner | SpawnGrenadeProjectileConfigWithoutOwner
Vector{ x: number, y: number, z: number }

Enums

17 enums. Where an enum mirrors an engine enum the Engine column pairs each member with the engine member of the same name. 7 of them are renumbered (CSDamageFlags, CSDamageTypes, CSGearSlot, CSInputs, CSLoadoutSlot, CSMoveType, CSWeaponAttackType). The script value is what script methods take and return (SetMoveType, GetMoveType). An integer that goes through the map instead, as a KeyValue (movetype 2) or an input parameter, is read by the engine, so it is most likely the engine number: CSMoveType.WALK is 1 but MOVETYPE_WALK is 2. That last point is unverified in game, so test before relying on it. Values from a schema dump, a demo or a server plugin are engine numbers too.

CSDamageFlags renumbered

Engine enum: TakeDamageFlags_t

MemberValueEngineNotes
NONE0DFLAG_NONE = 0
SUPPRESS_HEALTH_CHANGES1 (1 << 0)DFLAG_SUPPRESS_HEALTH_CHANGES = 1
SUPPRESS_PHYSICS_FORCE2 (1 << 1)DFLAG_SUPPRESS_PHYSICS_FORCE = 2
SUPPRESS_EFFECTS4 (1 << 2)DFLAG_SUPPRESS_EFFECTS = 4
PREVENT_DEATH8 (1 << 3)DFLAG_PREVENT_DEATH = 8
FORCE_DEATH16 (1 << 4)DFLAG_FORCE_DEATH = 16
SUPPRESS_DAMAGE_MODIFICATION32 (1 << 5)DFLAG_SUPPRESS_DAMAGE_MODIFICATION = 256 differs
IGNORE_ARMOR64 (1 << 6)DFLAG_IGNORE_ARMOR = 262144 differs

CSDamageType deprecated

No members declared.

CSDamageTypes renumbered

Engine enum: DamageTypes_t

MemberValueEngineNotes
GENERIC0DMG_GENERIC = 0
CRUSH1 (1 << 0)DMG_CRUSH = 1
BULLET2 (1 << 1)DMG_BULLET = 2
SLASH4 (1 << 2)DMG_SLASH = 4
BURN8 (1 << 3)DMG_BURN = 8
VEHICLE16 (1 << 4)DMG_VEHICLE = 16
FALL32 (1 << 5)DMG_FALL = 32
BLAST64 (1 << 6)DMG_BLAST = 64
CLUB128 (1 << 7)DMG_CLUB = 128
SHOCK256 (1 << 8)DMG_SHOCK = 256
SONIC512 (1 << 9)DMG_SONIC = 512
BUCKSHOT1024 (1 << 10)DMG_BUCKSHOT = 2048 differs
DROWN2048 (1 << 11)DMG_DROWN = 16384 differs
POISON4096 (1 << 12)DMG_POISON = 32768 differs
HEADSHOT8192 (1 << 13)DMG_HEADSHOT = 524288 differs

CSGearSlot renumbered

Engine enum: gear_slot_t

MemberValueEngineNotes
INVALID-1GEAR_SLOT_INVALID = -1
RIFLE0GEAR_SLOT_RIFLE = 0
PISTOL1GEAR_SLOT_PISTOL = 1
KNIFE2GEAR_SLOT_KNIFE = 2
GRENADES3GEAR_SLOT_GRENADES = 3
C44GEAR_SLOT_C4 = 4
BOOSTS5GEAR_SLOT_BOOSTS = 11 differs

CSGrenadeType

MemberValueNotes
HE0
FLASHBANG1
MOLOTOV2
INCENDIARY3
DECOY4
SMOKE5

CSHitGroup same values as engine

Engine enum: HitGroup_t

MemberValueEngineNotes
INVALID-1HITGROUP_INVALID = -1
GENERIC0HITGROUP_GENERIC = 0
HEAD1HITGROUP_HEAD = 1
CHEST2HITGROUP_CHEST = 2
STOMACH3HITGROUP_STOMACH = 3
LEFTARM4HITGROUP_LEFTARM = 4
RIGHTARM5HITGROUP_RIGHTARM = 5
LEFTLEG6HITGROUP_LEFTLEG = 6
RIGHTLEG7HITGROUP_RIGHTLEG = 7
NECK8HITGROUP_NECK = 8

CSInputs renumbered

Engine enum: InputBitMask_t

MemberValueEngineNotes
NONE0IN_NONE = 0
FORWARD1 (1 << 0)IN_FORWARD = 8 differs
BACK2 (1 << 1)IN_BACK = 16 differs
LEFT4 (1 << 2)no counterpart
RIGHT8 (1 << 3)no counterpart
WALK16 (1 << 4)no counterpart
DUCK32 (1 << 5)IN_DUCK = 4 differs
JUMP64 (1 << 6)IN_JUMP = 2 differs
USE128 (1 << 7)IN_USE = 32 differs
ATTACK256 (1 << 8)IN_ATTACK = 1 differs
ATTACK2512 (1 << 9)IN_ATTACK2 = 2048 differs
RELOAD1024 (1 << 10)IN_RELOAD = 8192 differs
SHOW_SCORES2048 (1 << 11)no counterpart
LOOK_AT_WEAPON4096 (1 << 12)IN_LOOK_AT_WEAPON = 34359738368 differs

CSLoadoutSlot renumbered

Engine enum: loadout_slot_t

MemberValueEngineNotes
INVALID0LOADOUT_SLOT_INVALID = -1 differs
MELEE1LOADOUT_SLOT_MELEE = 0 differs
SECONDARY02LOADOUT_SLOT_SECONDARY0 = 2
SECONDARY13LOADOUT_SLOT_SECONDARY1 = 3
SECONDARY24LOADOUT_SLOT_SECONDARY2 = 4
SECONDARY35LOADOUT_SLOT_SECONDARY3 = 5
SECONDARY46LOADOUT_SLOT_SECONDARY4 = 6
SMG07LOADOUT_SLOT_SMG0 = 8 differs
SMG18LOADOUT_SLOT_SMG1 = 9 differs
SMG29LOADOUT_SLOT_SMG2 = 10 differs
SMG310LOADOUT_SLOT_SMG3 = 11 differs
SMG411LOADOUT_SLOT_SMG4 = 12 differs
RIFLE012LOADOUT_SLOT_RIFLE0 = 14 differs
RIFLE113LOADOUT_SLOT_RIFLE1 = 15 differs
RIFLE214LOADOUT_SLOT_RIFLE2 = 16 differs
RIFLE315LOADOUT_SLOT_RIFLE3 = 17 differs
RIFLE416LOADOUT_SLOT_RIFLE4 = 18 differs
EQUIPMENT217LOADOUT_SLOT_EQUIPMENT2 = 34 differs

CSMoveType renumbered

Engine enum: MoveType_t

MemberValueEngineNotes
INVALID-1MOVETYPE_INVALID = 11 differs
NONE0MOVETYPE_NONE = 0
WALK1MOVETYPE_WALK = 2 differs
FLYGRAVITY2MOVETYPE_FLYGRAVITY = 4 differs
VPHYSICS3MOVETYPE_VPHYSICS = 5 differs
NOCLIP4MOVETYPE_NOCLIP = 7 differs
OBSERVER5MOVETYPE_OBSERVER = 8 differs
LADDER6MOVETYPE_LADDER = 9 differs
CUSTOM7MOVETYPE_CUSTOM = 10 differs

CSObserverMode same values as engine

Engine enum: ObserverMode_t

MemberValueEngineNotes
NONE0OBS_MODE_NONE = 0
FIXED1OBS_MODE_FIXED = 1
IN_EYE2OBS_MODE_IN_EYE = 2
CHASE3OBS_MODE_CHASE = 3
ROAMING4OBS_MODE_ROAMING = 4

CSRadarColor

MemberValueNotes
PLAYERHUD0
GRAY1
WHITE2
CT3
T4
RED5
GREEN6

CSRadarIcon

MemberValueNotes
TOWER0
C41
HOSTAGE2

CSRoundEndReason

MemberValueNotes
UNKNOWN-1
IN_PROGRESS0
GAME_COMMENCING1
DRAW2
TARGET_BOMBED3
TARGET_SAVED4
BOMB_DEFUSED5
HOSTAGES_RESCUED6
HOSTAGES_NOT_RESCUED7
CTS_WIN8
TERRORISTS_WIN9
CTS_SURRENDER10
TERRORISTS_SURRENDER11

CSTeamMoneyReason

MemberValueNotes
NONE0 $0
TERRORIST_WIN_BOMB1 cash_team_terrorist_win_bomb
ELIMINATION_HOSTAGE_MAP_T2 cash_team_elimination_hostage_map_t
ELIMINATION_HOSTAGE_MAP_CT3 cash_team_elimination_hostage_map_ct
ELIMINATION_BOMB_MAP4 cash_team_elimination_bomb_map
WIN_BY_TIME_RUNNING_OUT_HOSTAGE5 cash_team_win_by_time_running_out_hostage
WIN_BY_TIME_RUNNING_OUT_BOMB6 cash_team_win_by_time_running_out_bomb
WIN_BY_DEFUSING_BOMB7 cash_team_win_by_defusing_bomb
WIN_BY_HOSTAGE_RESCUE8 cash_team_win_by_hostage_rescue
LOSER_BONUS9 cash_team_loser_bonus
RESCUED_HOSTAGE10 cash_team_rescued_hostage
HOSTAGE_ALIVE11 cash_team_hostage_alive
PLANTED_BOMB_BUT_DEFUSED12 cash_team_planted_bomb_but_defused
HOSTAGE_INTERACTION13 cash_team_hostage_interaction
BONUS_SHORTHANDED14 cash_team_bonus_shorthanded

CSWeaponAttackType renumbered

Engine enum: WeaponAttackType_t

MemberValueEngineNotes
INVALID0eInvalid = -1 differs
PRIMARY1ePrimary = 0 differs
SECONDARY2eSecondary = 1 differs

CSWeaponType same values as engine

Engine enum: CSWeaponType

MemberValueEngineNotes
KNIFE0WEAPONTYPE_KNIFE = 0
PISTOL1WEAPONTYPE_PISTOL = 1
SUBMACHINEGUN2WEAPONTYPE_SUBMACHINEGUN = 2
RIFLE3WEAPONTYPE_RIFLE = 3
SHOTGUN4WEAPONTYPE_SHOTGUN = 4
SNIPER_RIFLE5WEAPONTYPE_SNIPER_RIFLE = 5
MACHINEGUN6WEAPONTYPE_MACHINEGUN = 6
C47WEAPONTYPE_C4 = 7
TASER8WEAPONTYPE_TASER = 8
GRENADE9WEAPONTYPE_GRENADE = 9
EQUIPMENT10WEAPONTYPE_EQUIPMENT = 10
STACKABLEITEM11WEAPONTYPE_STACKABLEITEM = 11
UNKNOWN12WEAPONTYPE_UNKNOWN = 12

CustomCameraMode same values as engine

Engine enum: CustomCameraMode_t

MemberValueEngineNotes
DISABLED0CUSTOM_CAMERA_MODE_DISABLED = 0 Position and angles come from the eye position and angles of the player.
CONTROLLED1CUSTOM_CAMERA_MODE_CONTROLLED = 1 Position and angles come from the origin and angles of the camera entity.
CONTROLLED_POSITION2CUSTOM_CAMERA_MODE_CONTROLLED_POSITION = 2 Position comes from the origin of camera entity. Angles are player controlled.
FOLLOW_POSITION3CUSTOM_CAMERA_MODE_FOLLOW_POSITION = 3 Position comes from an offset around a followed position. Angles are player controlled.