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; SetTransmit AND-merges with Transmit.setVisibleTo; lifecycle virtuals (Spawn, Think, Use, …).
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"DispatchTraceAttack). Mutate DamageInfo.damage in place.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.SDKHook(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: "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", 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.
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: "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", 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.