UseTypeValueCBaseEntity::Use use-type (USE_OFF / USE_ON / USE_SET / USE_TOGGLE).
Docs / API / Modules / sdkhooks
@s2script/sdk/sdkhooks
Per-entity SDKHook / SDKUnhook (SourceMod-shaped). OnTakeDamage / OnTakeDamagePost; SetTransmit AND-merges with Transmit.setVisibleTo; lifecycle virtuals (Spawn, Think, Use, …); Weapon* / Reload.
import { UseTypeValue } from "@s2script/sdk/sdkhooks";Author-time types ship in the npm package; the engine injects the runtime at plugin load.
Add @s2script/sdk to your plugin's dependencies.
Generated from the shipped type definitions.
UseTypeValueCBaseEntity::Use use-type (USE_OFF / USE_ON / USE_SET / USE_TOGGLE).
UseTypeCBaseEntity::Use use-type constants (wiki USE_*).
readonly Off: 0USE_OFF — turn off.readonly On: 1USE_ON — turn on.readonly Set: 2USE_SET — set to value.readonly Toggle: 3USE_TOGGLE — toggle.SDKHookTypeShipped SDKHook types. Wiki names without the SDKHook_ prefix. A wiki name whose engine
backing failed or is absent returns false from SDKHook (does not throw). A string
that is not a member here throws.
readonly OnTakeDamage: "OnTakeDamage"CBaseEntity::TakeDamageOld).
Mutate DamageInfo.damage in place. SDKHook returns false when no game package
provides damage hooks.readonly SetTransmit: "SetTransmit"SDKHook_SetTransmit). Handled / Stop hide this entity from this
viewer. AND-merge with Transmit.setVisibleTo: either API can hide; SetTransmit cannot
un-hide a native mask clear. There is no SetTransmitPost.readonly StartTouch: "StartTouch"CBaseEntity::StartTouch pre. Handled / Stop skip the original virtual.readonly Touch: "Touch"CBaseEntity::Touch pre. Handled / Stop skip the original virtual.readonly EndTouch: "EndTouch"CBaseEntity::EndTouch pre. Handled / Stop skip the original virtual.readonly Blocked: "Blocked"CBaseEntity::Blocked pre. Handled / Stop skip the original virtual.readonly StartTouchPost: "StartTouchPost"StartTouch post. Return is ignored.readonly TouchPost: "TouchPost"Touch post. Return is ignored.readonly EndTouchPost: "EndTouchPost"EndTouch post. Return is ignored.readonly BlockedPost: "BlockedPost"Blocked post. Return is ignored.readonly Spawn: "Spawn"CBaseEntity::Spawn pre. Handled / Stop skip the original virtual.readonly SpawnPost: "SpawnPost"Spawn post. Return is ignored.readonly Think: "Think"CBaseEntity::Think pre. Handled / Stop skip the original virtual.readonly ThinkPost: "ThinkPost"Think post. Return is ignored.readonly PreThink: "PreThink"PreThink. Return is ignored.readonly PreThinkPost: "PreThinkPost"PreThink post. Return is ignored.readonly PostThink: "PostThink"PostThink. Return is ignored.readonly PostThinkPost: "PostThinkPost"PostThink post. Return is ignored.readonly Use: "Use"CBaseEntity::Use pre. Handled / Stop skip the original virtual.readonly UsePost: "UsePost"Use post. Return is ignored.readonly GetMaxHealth: "GetMaxHealth"GetMaxHealth. Mutate info.maxHealth. Handled / Stop SUPERCEDE the original.readonly ShouldCollide: "ShouldCollide"ShouldCollide. Return a boolean (not HookResultValue); last defined wins.readonly VPhysicsUpdate: "VPhysicsUpdate"VPhysicsUpdate. Return is ignored.readonly VPhysicsUpdatePost: "VPhysicsUpdatePost"VPhysicsUpdate post. Return is ignored.readonly GroundEntChangedPost: "GroundEntChangedPost"GroundEntChanged post. Return is ignored.readonly CanBeAutobalanced: "CanBeAutobalanced"CanBeAutobalanced. Return a boolean (not HookResultValue); last defined wins.readonly OnTakeDamagePost: "OnTakeDamagePost"damage assignment is ignored. Return is ignored.readonly OnTakeDamageAlive: "OnTakeDamageAlive"OnTakeDamageAlive pre. CS2 has no distinct function yet — SDKHook returns false.readonly OnTakeDamageAlivePost: "OnTakeDamageAlivePost"OnTakeDamageAlive post. CS2 has no distinct function yet — SDKHook returns false.readonly TraceAttack: "TraceAttack"TraceAttack pre (TraceAttackInfo). No distinct CS2 virtual yet — SDKHook
returns false (use OnTakeDamage).readonly TraceAttackPost: "TraceAttackPost"TraceAttack post. No distinct CS2 virtual yet — SDKHook returns false.readonly FireBulletsPost: "FireBulletsPost"FireBulletsPost. Wiki already documents this as often absent. SDKHook returns false
until a live path is found.readonly Reload: "Reload"Handled / Stop skip the original virtual. Missing VP → false.readonly ReloadPost: "ReloadPost"(weapon, successful). No bool-return thunk yet — SDKHook returns false.readonly WeaponCanUse: "WeaponCanUse"WeaponCanUse pre. Callback is (entity, weapon). Missing ItemServices VP → false.readonly WeaponCanUsePost: "WeaponCanUsePost"WeaponCanUse post. Return is ignored. Missing VP → false.readonly WeaponCanSwitchTo: "WeaponCanSwitchTo"WeaponCanSwitchTo pre. Callback is (entity, weapon). Missing VP → false.readonly WeaponCanSwitchToPost: "WeaponCanSwitchToPost"WeaponCanSwitchTo post. Return is ignored. Missing VP → false.readonly WeaponDrop: "WeaponDrop"WeaponDrop pre. Callback is (entity, weapon). Missing VP → false.readonly WeaponDropPost: "WeaponDropPost"WeaponDrop post. Return is ignored. Missing VP → false.readonly WeaponEquip: "WeaponEquip"WeaponEquip pre. Callback is (entity, weapon). Missing VP → false.readonly WeaponEquipPost: "WeaponEquipPost"WeaponEquip post. Return is ignored. Missing VP → false.readonly WeaponSwitch: "WeaponSwitch"WeaponSwitch pre. Callback is (entity, weapon). Missing VP → false.readonly WeaponSwitchPost: "WeaponSwitchPost"WeaponSwitch post. Return is ignored. Missing VP → false.TraceAttackInfoBlock-scoped view of a TraceAttack callback. Mutate TraceAttackInfo.damage on the
pre-hook. Valid only during the handler.
damage: numberreadonly damageType: numberreadonly ammoType: numberreadonly hitbox: numberreadonly hitgroup: numberreadonly attacker: EntityRef | nullreadonly inflictor: EntityRef | nullreadonly victim: EntityRef | nullSDKHook(entity: EntityRef | null, type: "OnTakeDamage", callback: (info: DamageInfo) => HookResultValue | void): booleanHook entity for type. Auto-unhooked on entity destroy and plugin unload.
Not load-window-only — call from OnEntityCreated, OnPluginStart (ents already live), or any
time you hold a live EntityRef.
OnTakeDamage: mutate info.damage in place. No return needed. Return HookResult.Handled to
zero the hit; HookResult.Stop to also skip later hooks.
Returns — true if the hook was recorded. false on null/stale entity (does not throw).
import { SDKHook, SDKHookType, Entity } from "@s2script/sdk";
import type { EntityRef, DamageInfo } from "@s2script/sdk";
export function OnPluginStart(): void {
for (const pawn of Entity.findByClass("player")) {
SDKHook(pawn, SDKHookType.OnTakeDamage, onTakeDamage);
}
}
export function OnEntityCreated(entity: EntityRef | null, className: string): void {
if (!entity || className !== "player") return;
SDKHook(entity, SDKHookType.OnTakeDamage, onTakeDamage);
}
function onTakeDamage(info: DamageInfo) {
info.damage /= 2;
}SDKHook(entity: EntityRef | null, type: "OnTakeDamagePost", callback: (info: DamageInfo) => void): booleanPost-apply damage. DamageInfo reads the info after the original ran; it is valid only during the synchronous callback. Return is ignored; Handled does not zero the hit (that is the pre-hook).
SDKHook(entity: EntityRef | null, type: "OnTakeDamageAlive", callback: (info: DamageInfo) => HookResultValue | void): booleanOnTakeDamageAlive pre. No CS2 backing yet — always returns false.
SDKHook(entity: EntityRef | null, type: "OnTakeDamageAlivePost", callback: (info: DamageInfo) => void): booleanOnTakeDamageAlive post. No CS2 backing yet — always returns false.
SDKHook(entity: EntityRef | null, type: "TraceAttack", callback: (info: TraceAttackInfo) => HookResultValue | void): booleanTraceAttack pre. No distinct CS2 virtual yet — always returns false.
SDKHook(entity: EntityRef | null, type: "TraceAttackPost", callback: (info: TraceAttackInfo) => void): booleanTraceAttack post. No distinct CS2 virtual yet — always returns false.
SDKHook(entity: EntityRef | null, type: "FireBulletsPost", callback: FireBulletsPostCallback): booleanFireBulletsPost. No CS2 backing yet — always returns false.
SDKHook(entity: EntityRef | null, type: "StartTouch" | "Touch" | "EndTouch" | "Blocked", callback: TouchCallback): booleanTouch-family pre-hook. Callback is (entity, other). Omit return = Continue.
Handled / Stop SUPERCEDE the original virtual (Stop also skips later callbacks).
SDKHook(entity: EntityRef | null, type: "StartTouchPost" | "TouchPost" | "EndTouchPost" | "BlockedPost", callback: TouchPostCallback): booleanTouch-family post-hook. Return is ignored; the original virtual already ran.
SDKHook(entity: EntityRef | null, type: "Spawn" | "Think" | "Reload", callback: ThisCallback): booleanSpawn / Think pre-hook. Callback is (entity). Omit return = Continue.
Handled / Stop SUPERCEDE the original virtual (Stop also skips later callbacks).
SDKHook(entity: EntityRef | null, type:
| "SpawnPost"
| "ThinkPost"
| "PreThink"
| "PreThinkPost"
| "PostThink"
| "PostThinkPost"
| "VPhysicsUpdate"
| "VPhysicsUpdatePost"
| "GroundEntChangedPost", callback: ThisVoidCallback): booleanVoid this-only hooks (Posts, PreThink/PostThink, VPhysicsUpdate, GroundEntChangedPost). Return is ignored.
SDKHook(entity: EntityRef | null, type: "Use", callback: UseCallback): booleanUse pre-hook. Handled / Stop SUPERCEDE the original virtual.
SDKHook(entity: EntityRef | null, type: "UsePost", callback: UsePostCallback): booleanUse post-hook. Return is ignored.
SDKHook(entity: EntityRef | null, type: "GetMaxHealth", callback: (info: { maxHealth: number }) => HookResultValue | void): booleanGetMaxHealth. Mutate info.maxHealth in place. Handled / Stop SUPERCEDE with the new value.
SDKHook(entity: EntityRef | null, type: "ShouldCollide", callback: (
entity: EntityRef,
collisionGroup: number,
contentsMask: number,
originalResult: boolean,
) => boolean): booleanShouldCollide. Return a boolean (not HookResult); last defined return wins, default original.
SDKHook(entity: EntityRef | null, type: "CanBeAutobalanced", callback: (client: Client, origRet: boolean) => boolean): booleanCanBeAutobalanced. Return a boolean (not HookResult); last defined return wins, default original.
Callback is skipped when the hooked entity has no Client — never a raw slot 0.
SDKHook(entity: EntityRef | null, type: "SetTransmit", callback: (entity: EntityRef, client: Client) => HookResultValue | void): booleanSetTransmit. Callback is (entity, client). Omit return = Continue.
Handled / Stop hide this entity from this viewer (AND-merge with Transmit.setVisibleTo;
cannot un-hide a native mask clear). Stop also skips later SetTransmit callbacks on that pair.
SDKHook(entity: EntityRef | null, type: "WeaponCanUse" | "WeaponCanSwitchTo" | "WeaponDrop" | "WeaponEquip" | "WeaponSwitch", callback: WeaponCallback): booleanWeapon-family pre-hook. Callback is (entity, weapon). Omit return = Continue.
Handled / Stop SUPERCEDE the original virtual. Missing ItemServices VP → false.
SDKHook(entity: EntityRef | null, type:
| "WeaponCanUsePost"
| "WeaponCanSwitchToPost"
| "WeaponDropPost"
| "WeaponEquipPost"
| "WeaponSwitchPost", callback: WeaponPostCallback): booleanWeapon-family post-hook. Return is ignored. Missing VP → false.
SDKHook(entity: EntityRef | null, type: "ReloadPost", callback: ReloadPostCallback): booleanReloadPost. Callback is (weapon, successful). No CS2 backing yet — always returns false.
SDKUnhook(entity: EntityRef | null, type: "OnTakeDamage", callback: (info: DamageInfo) => HookResultValue | void): booleanRemove one matching (entity, type, callback) hook. Callback identity is the function reference.
Returns — true if an entry was removed.
SDKUnhook(entity: EntityRef | null, type: "OnTakeDamagePost", callback: (info: DamageInfo) => void): booleanRemove an OnTakeDamagePost hook.
SDKUnhook(entity: EntityRef | null, type: "OnTakeDamageAlive", callback: (info: DamageInfo) => HookResultValue | void): booleanRemove an OnTakeDamageAlive hook.
SDKUnhook(entity: EntityRef | null, type: "OnTakeDamageAlivePost", callback: (info: DamageInfo) => void): booleanRemove an OnTakeDamageAlivePost hook.
SDKUnhook(entity: EntityRef | null, type: "TraceAttack", callback: (info: TraceAttackInfo) => HookResultValue | void): booleanRemove a TraceAttack hook.
SDKUnhook(entity: EntityRef | null, type: "TraceAttackPost", callback: (info: TraceAttackInfo) => void): booleanRemove a TraceAttackPost hook.
SDKUnhook(entity: EntityRef | null, type: "FireBulletsPost", callback: FireBulletsPostCallback): booleanRemove a FireBulletsPost hook.
SDKUnhook(entity: EntityRef | null, type: "StartTouch" | "Touch" | "EndTouch" | "Blocked", callback: TouchCallback): booleanRemove a Touch-family pre-hook.
SDKUnhook(entity: EntityRef | null, type: "StartTouchPost" | "TouchPost" | "EndTouchPost" | "BlockedPost", callback: TouchPostCallback): booleanRemove a Touch-family post-hook.
SDKUnhook(entity: EntityRef | null, type: "Spawn" | "Think" | "Reload", callback: ThisCallback): booleanRemove a Spawn / Think pre-hook.
SDKUnhook(entity: EntityRef | null, type:
| "SpawnPost"
| "ThinkPost"
| "PreThink"
| "PreThinkPost"
| "PostThink"
| "PostThinkPost"
| "VPhysicsUpdate"
| "VPhysicsUpdatePost"
| "GroundEntChangedPost", callback: ThisVoidCallback): booleanRemove a void this-only hook.
SDKUnhook(entity: EntityRef | null, type: "Use", callback: UseCallback): booleanRemove a Use pre-hook.
SDKUnhook(entity: EntityRef | null, type: "UsePost", callback: UsePostCallback): booleanRemove a Use post-hook.
SDKUnhook(entity: EntityRef | null, type: "GetMaxHealth", callback: (info: { maxHealth: number }) => HookResultValue | void): booleanRemove a GetMaxHealth hook.
SDKUnhook(entity: EntityRef | null, type: "ShouldCollide", callback: (
entity: EntityRef,
collisionGroup: number,
contentsMask: number,
originalResult: boolean,
) => boolean): booleanRemove a ShouldCollide hook.
SDKUnhook(entity: EntityRef | null, type: "CanBeAutobalanced", callback: (client: Client, origRet: boolean) => boolean): booleanRemove a CanBeAutobalanced hook.
SDKUnhook(entity: EntityRef | null, type: "SetTransmit", callback: (entity: EntityRef, client: Client) => HookResultValue | void): booleanRemove a SetTransmit hook.
SDKUnhook(entity: EntityRef | null, type: "WeaponCanUse" | "WeaponCanSwitchTo" | "WeaponDrop" | "WeaponEquip" | "WeaponSwitch", callback: WeaponCallback): booleanRemove a Weapon-family pre-hook.
SDKUnhook(entity: EntityRef | null, type:
| "WeaponCanUsePost"
| "WeaponCanSwitchToPost"
| "WeaponDropPost"
| "WeaponEquipPost"
| "WeaponSwitchPost", callback: WeaponPostCallback): booleanRemove a Weapon-family post-hook.
SDKUnhook(entity: EntityRef | null, type: "ReloadPost", callback: ReloadPostCallback): booleanRemove a ReloadPost hook.