List of CS:GO Script Functions: Difference between revisions
Kidfearless (talk | contribs) m (Added More descriptions) |
No edit summary |
||
(52 intermediate revisions by 18 users not shown) | |||
Line 1: | Line 1: | ||
{{LanguageBar}} | |||
{{ | {{Delisted|csgo}} | ||
| | |||
}} | |||
{{toc-right}} | {{toc-right}} | ||
{{sq}} This list contains the engine-related Squirrel classes, functions and variables available for [[VScript]] in {{ | {{sq}} This list contains the engine-related Squirrel classes, functions and variables available for [[VScript]] in {{csgo|4}}. The official documentation can be printed in the console by setting <code>developer</code> to non-zero, loading a map, and executing <code>script_help</code>. | ||
== Variables == | == Variables == | ||
{| class="standard-table" | |||
{| class="standard-table" | |||
!Instance | !Instance | ||
!Type | !Type | ||
Line 34: | Line 15: | ||
|<code>Entities</code> | |<code>Entities</code> | ||
|<code>[[#CEntities|CEntities]]</code> | |<code>[[#CEntities|CEntities]]</code> | ||
|Provides access to | |Provides access to spawned entities in the server. | ||
|- | |- | ||
|} | |} | ||
== Constants == | == Constants == | ||
Line 42: | Line 24: | ||
!Instance | !Instance | ||
!Type | !Type | ||
! | !Value | ||
|- | |- | ||
|<code>_charsize_</code> | |<code>_charsize_</code> | ||
Line 58: | Line 40: | ||
|<code>_version_</code> | |<code>_version_</code> | ||
|string | |string | ||
| | | "Squirrel 2.2.3 stable" | ||
|- | |- | ||
|<code>RAND_MAX</code> | |<code>RAND_MAX</code> | ||
Line 68: | Line 50: | ||
| 3.14159 | | 3.14159 | ||
|} | |} | ||
{{note|These are simply global variables, namely table slots in the root table. They can be changed at will, for example <code>::PI {{=}} 3</code>.}} | |||
== Classes == | == Classes == | ||
Line 75: | Line 59: | ||
This is a script handle class for entities. All entities spawned have a script handle using this or one of its subclasses. | This is a script handle class for entities. All entities spawned have a script handle using this or one of its subclasses. | ||
All script handles in-game are accessible from [[#CEntities|Entities]]. Entity | All script handles in-game are accessible from [[#CEntities|Entities]]. Entity scripts can use <code>self</code> to access their own script handle. <code>activator</code> and <code>caller</code> variables can be accessed on function calls. | ||
==== Methods ==== | ==== Methods ==== | ||
{| class="standard-table" style="width: | {| class="standard-table" style="width: 75%;" | ||
! Function | ! Function | ||
! Signature | ! Signature | ||
Line 85: | Line 70: | ||
| <code>__KeyValueFromInt</code> | | <code>__KeyValueFromInt</code> | ||
| <code>bool __KeyValueFromInt(string ''key'', int ''value'')</code> | | <code>bool __KeyValueFromInt(string ''key'', int ''value'')</code> | ||
| Sets | | Sets entity [[keyvalue]] from an integer. | ||
|- | |- | ||
| <code>__KeyValueFromFloat</code> | | <code>__KeyValueFromFloat</code> | ||
| <code>bool __KeyValueFromFloat(string ''key'', float ''value'')</code> | | <code>bool __KeyValueFromFloat(string ''key'', float ''value'')</code> | ||
| Sets | | Sets entity keyvalue from a float. | ||
|- | |- | ||
| <code>__KeyValueFromString</code> | | <code>__KeyValueFromString</code> | ||
| <code>bool __KeyValueFromString(string ''key'', string ''value'')</code> | | <code>bool __KeyValueFromString(string ''key'', string ''value'')</code> | ||
| Sets | | Sets entity keyvalue from a string. | ||
|- | |- | ||
| <code>__KeyValueFromVector</code> | | <code>__KeyValueFromVector</code> | ||
| <code>bool __KeyValueFromVector(string ''key'', Vector ''value'')</code> | | <code>bool __KeyValueFromVector(string ''key'', Vector ''value'')</code> | ||
| Sets | | Sets entity keyvalue from a [[#Vector|Vector]]. | ||
|- | |- | ||
| <code>ConnectOutput</code> | | <code>ConnectOutput</code> | ||
| <code>void ConnectOutput(string ''output'', string ''function'')</code> | | <code>void ConnectOutput(string ''output'', string ''function'')</code> | ||
| Adds an I/O connection that will call the named function when the specified output fires. | | Adds an [[I/O]] connection that will call the named function when the specified output fires. | ||
|- | |- | ||
| <code>DisconnectOutput</code> | | <code>DisconnectOutput</code> | ||
Line 109: | Line 94: | ||
| <code>Destroy</code> | | <code>Destroy</code> | ||
| <code>void Destroy()</code> | | <code>void Destroy()</code> | ||
| | | Kills the entity. | ||
|- | |- | ||
| <code>EmitSound</code> | | <code>EmitSound</code> | ||
| <code>void EmitSound(string '' | | <code>void EmitSound(string ''soundname'')</code> | ||
| Plays a sound from this entity. | | Plays a sound from this entity. | ||
|- | |- | ||
Line 125: | Line 110: | ||
| <code>FirstMoveChild</code> | | <code>FirstMoveChild</code> | ||
| <code>handle FirstMoveChild()</code> | | <code>handle FirstMoveChild()</code> | ||
| | | If in hierarchy, get the first move child. | ||
|- | |- | ||
| <code>GetAngles</code> | | <code>GetAngles</code> | ||
| <code>Vector GetAngles()</code> | | <code>Vector GetAngles()</code> | ||
| Get the entity pitch, yaw, roll as a | | Get the entity local angles ([[angles|pitch, yaw, roll]]) as a Vector object. | ||
|- | |- | ||
| <code>GetAngularVelocity</code> | | <code>GetAngularVelocity</code> | ||
Line 137: | Line 122: | ||
| <code>GetBoundingMaxs</code> | | <code>GetBoundingMaxs</code> | ||
| <code>Vector GetBoundingMaxs()</code> | | <code>Vector GetBoundingMaxs()</code> | ||
| | | Get a vector containing max bounds in local space. | ||
|- | |||
| <code>GetBoundingMaxsOriented</code> | |||
| <code>Vector GetBoundingMaxsOriented()</code> | |||
| Get a vector containing max bounds, centered on object, taking the object's orientation into account. | |||
|- | |- | ||
| <code>GetBoundingMins</code> | | <code>GetBoundingMins</code> | ||
| <code>Vector GetBoundingMins()</code> | | <code>Vector GetBoundingMins()</code> | ||
| | | Get a vector containing min bounds in local space. | ||
|- | |||
| <code>GetBoundingMinsOriented</code> | |||
| <code>Vector GetBoundingMinsOriented()</code> | |||
| Get a vector containing min bounds, centered on object, taking the object's orientation into account. | |||
|- | |- | ||
| <code>GetCenter</code> | | <code>GetCenter</code> | ||
| <code>Vector GetCenter()</code> | | <code>Vector GetCenter()</code> | ||
| | | Get vector to center of object in world space. | ||
|- | |- | ||
| <code>GetClassname</code> | | <code>GetClassname</code> | ||
| <code>string GetClassname()</code> | | <code>string GetClassname()</code> | ||
| | | Get entity [[classname]]. | ||
|- | |- | ||
| <code>GetForwardVector</code> | | <code>GetForwardVector</code> | ||
| <code>Vector GetForwardVector()</code> | | <code>Vector GetForwardVector()</code> | ||
| Get the forward vector of the entity. | | Get the forward vector of the entity in world space. | ||
|- | |- | ||
| <code>GetHealth</code> | | <code>GetHealth</code> | ||
| <code>int GetHealth()</code> | | <code>int GetHealth()</code> | ||
| Returns the current health. | | Returns the current [[health]]. | ||
|- | |- | ||
| <code>GetLeftVector</code> | | <code>GetLeftVector</code> | ||
| <code>Vector GetLeftVector()</code> | | <code>Vector GetLeftVector()</code> | ||
| Get the | | Get the ''right'' vector of the entity in world space. | ||
|- | |- | ||
| <code>GetMaxHealth</code> | | <code>GetMaxHealth</code> | ||
| <code>int GetMaxHealth()</code> | | <code>int GetMaxHealth()</code> | ||
|Returns the maximum health. | | Returns the maximum health. | ||
|- | |- | ||
| <code>GetModelKeyValues</code> | | <code>GetModelKeyValues</code> | ||
| <code> | | <code>CScriptKeyValues GetModelKeyValues()</code> | ||
| Returns the [$keyvalues] block of the | | Returns the [[$keyvalues]] block of the entity's model as a [[#CScriptKeyValues]] object. Note that this is ''not'' the keyvalues of the entity itself. | ||
|- | |- | ||
| <code>GetModelName</code> | | <code>GetModelName</code> | ||
| <code>string GetModelName()</code> | | <code>string GetModelName()</code> | ||
| Returns the | | Returns the value of the entity's <code>model</code> keyvalue or <code>""</code>. | ||
|- | |- | ||
| <code>GetMoveParent</code> | | <code>GetMoveParent</code> | ||
| <code> | | <code>handle GetMoveParent()</code> | ||
| If in hierarchy, retrieves the | | If in hierarchy, retrieves the entity's parent. | ||
|- | |- | ||
| <code>GetName</code> | | <code>GetName</code> | ||
| <code>string GetName()</code> | | <code>string GetName()</code> | ||
| Returns the targetname of the entity. | | Returns the [[targetname]] of the entity. | ||
|- | |- | ||
| <code>GetOrigin</code> | | <code>GetOrigin</code> | ||
| <code>Vector GetOrigin()</code> | | <code>Vector GetOrigin()</code> | ||
| Returns | | Returns this entity's local origin. | ||
|- | |- | ||
| <code>GetOwner</code> | | <code>GetOwner</code> | ||
| <code>handle GetOwner()</code> | | <code>handle GetOwner()</code> | ||
| Gets this entity's owner. | | Gets this entity's owner. | ||
|- | |- | ||
| <code>GetPreTemplateName</code> | | <code>GetPreTemplateName</code> | ||
| <code>string GetPreTemplateName()</code> | | <code>string GetPreTemplateName()</code> | ||
| Get the entity name stripped of template unique decoration. | | Get the entity name stripped of template unique decoration. This is the <code>&048</code> suffix added by templates that do not preserve the entity name. | ||
|- | |- | ||
| <code>GetRootMoveParent</code> | | <code>GetRootMoveParent</code> | ||
Line 201: | Line 194: | ||
| <code>GetScriptId</code> | | <code>GetScriptId</code> | ||
| <code>string GetScriptId()</code> | | <code>string GetScriptId()</code> | ||
| | | Returns the thinkfunction keyvalue of the entity. | ||
|- | |- | ||
| <code>GetScriptScope</code> | | <code>GetScriptScope</code> | ||
Line 208: | Line 201: | ||
|- | |- | ||
| <code>GetSoundDuration</code> | | <code>GetSoundDuration</code> | ||
| <code>float GetSoundDuration(string '' | | <code>float GetSoundDuration(string ''soundname'', string ''actormodel'')</code> | ||
| Returns float duration of the sound. | | Returns float duration of the sound. {{todo|Does this work correctly only with .wav files?}} | ||
|- | |- | ||
| <code>GetTeam</code> | | <code>GetTeam</code> | ||
| <code>int GetTeam()</code> | | <code>int GetTeam()</code> | ||
| | | Get the team this entity is on. | ||
|- | |- | ||
| <code>GetUpVector</code> | | <code>GetUpVector</code> | ||
| <code>Vector GetUpVector()</code> | | <code>Vector GetUpVector()</code> | ||
| Get the up vector of the entity. | | Get the up vector of the entity in world space. | ||
|- | |- | ||
| <code>GetVelocity</code> | | <code>GetVelocity</code> | ||
| <code>Vector GetVelocity()</code> | | <code>Vector GetVelocity()</code> | ||
| | | Get the velocity of the entity. | ||
|- | |- | ||
| <code>IsValid</code> | | <code>IsValid</code> | ||
Line 229: | Line 222: | ||
| <code>NextMovePeer</code> | | <code>NextMovePeer</code> | ||
| <code>handle NextMovePeer()</code> | | <code>handle NextMovePeer()</code> | ||
| | | Return the next entity in the same movement hierarchy. | ||
|- | |- | ||
| <code>PrecacheModel</code> | | <code>PrecacheModel</code> | ||
| <code>void PrecacheModel(string '' | | <code>void PrecacheModel(string ''modelname'')</code> | ||
| Precache a model | | Precache a model. Expensive. | ||
|- | |- | ||
| <code>PrecacheScriptSound</code> | | <code>PrecacheScriptSound</code> | ||
| <code>void PrecacheScriptSound(string '' | | <code>void PrecacheScriptSound(string ''soundname'')</code> | ||
| | | Precache a sound. Expensive. | ||
|- | |- | ||
| <code>PrecacheSoundScript</code> | | <code>PrecacheSoundScript</code> | ||
| <code>void PrecacheSoundScript(string '' | | <code>void PrecacheSoundScript(string ''soundscript'')</code> | ||
| Precache a sound for later playing. | | Precache a sound for later playing. Expensive. | ||
|- | |- | ||
| <code>SetAbsOrigin</code> | | <code>SetAbsOrigin</code> | ||
| <code>void SetAbsOrigin(Vector ''position'')</code> | | <code>void SetAbsOrigin(Vector ''position'')</code> | ||
| | | Set absolute origin. | ||
|- | |- | ||
| <code>SetAngles</code> | | <code>SetAngles</code> | ||
| <code>void SetAngles(float ''pitch'', float ''yaw'', float ''roll'')</code> | | <code>void SetAngles(float ''pitch'', float ''yaw'', float ''roll'')</code> | ||
| Set entity pitch, yaw, roll | | Set entity local angles ([[angles|pitch, yaw, roll]]). | ||
|- | |- | ||
| <code>SetAngularVelocity</code> | | <code>SetAngularVelocity</code> | ||
Line 256: | Line 249: | ||
|- | |- | ||
| <code>SetForwardVector</code> | | <code>SetForwardVector</code> | ||
| <code>void SetForwardVector(Vector '' | | <code>void SetForwardVector(Vector ''forwardvec'')</code> | ||
| | | Sets entity forward vector in local space. | ||
|- | |- | ||
| <code>SetHealth</code> | | <code>SetHealth</code> | ||
| <code>void SetHealth(int '' | | <code>void SetHealth(int ''health'')</code> | ||
| Sets the current health. | | Sets the current [[health]]. | ||
|- | |- | ||
| <code>SetMaxHealth</code> | | <code>SetMaxHealth</code> | ||
| <code>void SetMaxHealth(int '' | | <code>void SetMaxHealth(int ''health'')</code> | ||
| Sets | | Sets the maximum health. | ||
|- | |- | ||
| <code>SetModel</code> | | <code>SetModel</code> | ||
| <code>void SetModel(string '' | | <code>void SetModel(string ''modelname'')</code> | ||
| Changes the model of the entity. Does not | | Changes the model of the entity. Does not precache the model. | ||
|- | |- | ||
| <code>SetOrigin</code> | | <code>SetOrigin</code> | ||
| <code>void SetOrigin(Vector ''position'')</code> | | <code>void SetOrigin(Vector ''position'')</code> | ||
| | | Set local origin. "Teleports" the entity. | ||
|- | |- | ||
| <code>SetOwner</code> | | <code>SetOwner</code> | ||
Line 280: | Line 273: | ||
|- | |- | ||
| <code>SetSize</code> | | <code>SetSize</code> | ||
| <code>void SetSize(Vector, Vector)</code> | | <code>void SetSize(Vector ''mins'', Vector ''maxs'')</code> | ||
| | | Sets the bounding box size. | ||
|- | |- | ||
| <code>SetTeam</code> | | <code>SetTeam</code> | ||
| <code>void SetTeam(int '' | | <code>void SetTeam(int ''team'')</code> | ||
| | | Set the team this entity is on. | ||
|- | |- | ||
| <code>SetVelocity</code> | | <code>SetVelocity</code> | ||
| <code>void SetVelocity(Vector ''velocity'')</code> | | <code>void SetVelocity(Vector ''velocity'')</code> | ||
| | | Set local velocity. | ||
|- | |- | ||
| <code>StopSound</code> | | <code>StopSound</code> | ||
| <code>void StopSound(string '' | | <code>void StopSound(string ''soundname'')</code> | ||
| Stops a sound on this entity. | | Stops a sound on this entity. | ||
|- | |- | ||
Line 311: | Line 304: | ||
| <code>Input''InputName''</code> | | <code>Input''InputName''</code> | ||
| <code>bool Input''InputName''()</code> | | <code>bool Input''InputName''()</code> | ||
| Called when the entity receives an input from the I/O system. The name of the function needs to be <code>Input</code> followed by the name of the input in CamelCase, for example <code>InputFireUser1</code> for the FireUser1 input | | Called when the entity receives an input from the I/O system. The name of the function needs to be <code>Input</code> followed by the name of the input in CamelCase, for example <code>InputFireUser1</code> for the FireUser1 input. The function needs to return a boolean value. Setting it to <code>true</code> allows the entity to process the input, while <code>false</code> cancels it. | ||
|- | |- | ||
| <code>OnPostSpawn</code> | | <code>OnPostSpawn</code> | ||
| <code>void OnPostSpawn()</code> | | <code>void OnPostSpawn()</code> | ||
| | | This is called after the entity has spawned. | ||
|- | |- | ||
| <code>Precache</code> | | <code>Precache</code> | ||
| <code>void Precache()</code> | | <code>void Precache()</code> | ||
| | | This is called during entity spawning and after restore to allow scripts to precache any resources they need. | ||
|} | |} | ||
=== CBaseAnimating === | === CBaseAnimating === | ||
Line 326: | Line 320: | ||
Script handle class for animating entities such as props. | Script handle class for animating entities such as props. | ||
==== Methods ==== | ==== Methods ==== | ||
Line 338: | Line 333: | ||
|- | |- | ||
| <code>GetAttachmentOrigin</code> | | <code>GetAttachmentOrigin</code> | ||
| <code>Vector GetAttachmentOrigin(int 'id')</code> | | <code>Vector GetAttachmentOrigin(int ''id'')</code> | ||
| Get the attachment ID's origin vector. | | Get the attachment ID's origin vector. | ||
|- | |- | ||
Line 351: | Line 346: | ||
| <code>SetBodygroup</code> | | <code>SetBodygroup</code> | ||
| <code>void SetBodygroup(int ''groupIndex'', int ''value'')</code> | | <code>void SetBodygroup(int ''groupIndex'', int ''value'')</code> | ||
| Sets the models bodygroup value by index. | | Sets the models bodygroup value by index. | ||
|} | |} | ||
Line 357: | Line 352: | ||
=== CBaseFlex === | === CBaseFlex === | ||
Extends [[#CBaseAnimating|CBaseAnimating]] | Extends [[#CBaseAnimating|CBaseAnimating]] | ||
==== Methods ==== | ==== Methods ==== | ||
Line 376: | Line 372: | ||
=== CBasePlayer === | === CBasePlayer === | ||
Extends [[#CBaseAnimating|CBaseAnimating]] | Extends [[#CBaseAnimating|CBaseAnimating]] | ||
==== Methods ==== | ==== Methods ==== | ||
Line 387: | Line 384: | ||
| Returns true if the player is in noclip mode. | | Returns true if the player is in noclip mode. | ||
|} | |} | ||
=== CBaseMultiplayerPlayer === | === CBaseMultiplayerPlayer === | ||
Line 398: | Line 396: | ||
Script handle class for [[env_entity_maker]]. | Script handle class for [[env_entity_maker]]. | ||
==== Methods ==== | ==== Methods ==== | ||
Line 410: | Line 409: | ||
|- | |- | ||
| <code>SpawnEntityAtEntityOrigin</code> | | <code>SpawnEntityAtEntityOrigin</code> | ||
| <code>void SpawnEntityAtEntityOrigin( | | <code>void SpawnEntityAtEntityOrigin(handle ''entity'')</code> | ||
| Create an entity at the location of a specified entity instance. | | Create an entity at the location of a specified entity instance. | ||
|- | |- | ||
Line 418: | Line 417: | ||
|- | |- | ||
| <code>SpawnEntityAtNamedEntityOrigin</code> | | <code>SpawnEntityAtNamedEntityOrigin</code> | ||
| <code>void SpawnEntityAtNamedEntityOrigin(string '' | | <code>void SpawnEntityAtNamedEntityOrigin(string ''targetname'')</code> | ||
| Create an entity at the location of a named entity. | | Create an entity at the location of a named entity. If multiple entities have the same name, only the one with the lowest entity index will be targeted. | ||
|} | |} | ||
=== CPointTemplate === | === CPointTemplate === | ||
Line 427: | Line 425: | ||
Script handle class for [[point_template]]. | Script handle class for [[point_template]]. | ||
==== Hooks ==== | ==== Hooks ==== | ||
;<code>table PreSpawnInstance(string ''entityClass'', string ''entityName'')</code> | ;<code>table PreSpawnInstance(string ''entityClass'', string ''entityName'')</code> | ||
:If this is defined, it will be called right before the entity is created, and any | :If this is defined, it will be called right before the entity is created, and any keyvalues returned will be assigned to the entity. | ||
<source lang="cpp">function PreSpawnInstance( entityClass, entityName ) | <source lang="cpp">function PreSpawnInstance( entityClass, entityName ) | ||
Line 437: | Line 435: | ||
local keyvalues = | local keyvalues = | ||
{ | { | ||
rendercolor = "0 255 0" | rendercolor = "0 255 0", | ||
targetname = "mySpawnedEntity" | targetname = "mySpawnedEntity" | ||
} | } | ||
return keyvalues | return keyvalues | ||
} | } | ||
</source> | </source> | ||
;<code>void PostSpawn(table ''entities'')</code> | ;<code>void PostSpawn(table ''entities'')</code> | ||
:Called after the entities are spawned. A table with the handles of the spawned entities indexed by name is passed to the function. Could use this to connect outputs or do whatever needs to be done after the entity was created. | :Called after the entities are spawned. A table with the handles of the spawned entities indexed by name is passed to the function. Could use this to connect outputs or do whatever needs to be done after the entity was created. | ||
{{note|PostSpawn() will not be called unless the PreSpawnInstance() function is also defined in the script.}} | {{note|PostSpawn() will not be called unless the PreSpawnInstance() function is also defined in the script.}} | ||
Line 452: | Line 450: | ||
<source lang="cpp">function PostSpawn( entities ) | <source lang="cpp">function PostSpawn( entities ) | ||
{ | { | ||
foreach( | foreach( targetname, handle in entities ) | ||
{ | |||
printl( targetname + ": " + handle ) | |||
} | |||
} | |||
</source> | |||
===== Example ===== | |||
Spawned entities can be accessed synchronously in script by using an entity maker. The following generalised example creates a global <code>SpawnMyEntity()</code> function which spawns and returns the templated entity. It can be modified to support multiple templated entities. | |||
<source lang="cpp"> | |||
m_hSpawnedEntity <- null; | |||
m_KeyValues <- null; | |||
m_hSpawner <- Entities.CreateByClassname( "env_entity_maker" ); | |||
m_hSpawner.__KeyValueFromString( "EntityTemplate", self.GetName() ); | |||
function PreSpawnInstance( classname, targetname ) | |||
{ | |||
return m_KeyValues; | |||
} | |||
function PostSpawn( entities ) | |||
{ | |||
foreach ( targetname, entity in entities ) | |||
{ | { | ||
m_hSpawnedEntity = entity; | |||
break; | |||
} | } | ||
} | } | ||
::SpawnMyEntity <- function( keyvalues = null ) | |||
{ | |||
m_KeyValues = keyvalues; | |||
m_hSpawner.SpawnEntity(); | |||
return m_hSpawnedEntity; | |||
}.bindenv(this) | |||
</source> | </source> | ||
Spawn templated entities from any script. | |||
<source lang="cpp"> | |||
local ent = SpawnMyEntity( { | |||
rendercolor = Vector( RandomInt(0, 255), RandomInt(0, 255), RandomInt(0, 255) ) | |||
} ) | |||
printl( ent ) | |||
</source> | |||
=== CSceneEntity === | === CSceneEntity === | ||
Line 464: | Line 505: | ||
==== Methods ==== | ==== Methods ==== | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 518: | Line 558: | ||
| Set cameras current FOV in integer degrees and FOV change rate as float. | | Set cameras current FOV in integer degrees and FOV change rate as float. | ||
|} | |} | ||
==== Hooks ==== | ==== Hooks ==== | ||
{| class="standard-table" style="width: 100%;" | |||
! Function | |||
! Signature | |||
! Description | |||
|- | |||
| <code>ScriptStartCameraShot</code> | |||
| <code>void ScriptStartCameraShot(string ''shotType'', handle ''sceneEntity'', handle ''actor1'', handle ''actor2'', float ''duration'')</code> | |||
| ''Called from SceneEntity in response to a CChoreoEvent::CAMERA sent from a VCD.'' {{todo}} | |||
|} | |||
=== CFuncTrackTrain === | === CFuncTrackTrain === | ||
Extends [[#CBaseEntity|CBaseEntity]] | Extends [[#CBaseEntity|CBaseEntity]] | ||
==== Methods ==== | ==== Methods ==== | ||
Line 535: | Line 583: | ||
|- | |- | ||
| <code>GetFuturePosition</code> | | <code>GetFuturePosition</code> | ||
| <code>Vector GetFuturePosition(float, float) | | <code>Vector GetFuturePosition(float ''x'', float ''speed'')</code> | ||
| Get a position on the track x seconds in the future. | | Get a position on the track x seconds in the future. | ||
|} | |} | ||
Line 542: | Line 590: | ||
=== CHostage === | === CHostage === | ||
Extends [[#CBaseEntity|CBaseEntity]] | Extends [[#CBaseEntity|CBaseEntity]] | ||
==== Methods ==== | ==== Methods ==== | ||
Line 557: | Line 606: | ||
=== CGameCoopMissionManager === | === CGameCoopMissionManager === | ||
Extends [[#CBaseEntity|CBaseEntity]] | Extends [[#CBaseEntity|CBaseEntity]] | ||
==== Methods ==== | ==== Methods ==== | ||
Line 570: | Line 620: | ||
=== | === CEntities === | ||
Script instance: <code>Entities</code> | |||
An interface to find and iterate over the script handles for the entities in play. | |||
To iterate over a set of entities, pass <code>null</code> to the ''previous'' argument in the appropriate method to start an iteration, or reference to a previously found entity to continue a search. | |||
The following are two equivalent examples and iterate over all weapons on the map: | |||
=== | {| width=100% | ||
|- style="vertical-align:top;" | |||
| | |||
<source lang=cpp> | |||
local ent = null; | |||
while ( ent = Entities.FindByClassname(ent, "weapon_*") ) | |||
{ | |||
// ... | |||
} | |||
</source> | |||
| | |||
<source lang=cpp> | |||
for (local ent; ent = Entities.FindByName(ent, "weapon_*"); ) | |||
{ | |||
// ... | |||
} | |||
</source> | |||
|} | |||
{{Note | | |||
* The variable name <code>ent</code> is arbitrary. | |||
* Indeed, we mean "{{=}}" and not "{{=}}{{=}}" in the loop conditions! The loops end if <code>ent</code> becomes <code>null</code>, which happens when no matching entities have an [[entity index]] higher to the one in ''previous'' parameter. | |||
* Semicolons are optional, except in the header of the <code>for</code> statement. | |||
* The string parameters of the <code>FindBy...</code> functions support the wildcard star <code>*</code>. In the above example, <code>FindByClassname</code> only returns either a handle of an entity whose classname begins with "<code>weapon_</code>" or it returns <code>null</code>. | |||
}} | |||
==== Methods ==== | ==== Methods ==== | ||
Line 626: | Line 662: | ||
|- | |- | ||
| <code>CreateByClassname</code> | | <code>CreateByClassname</code> | ||
| <code>handle CreateByClassname(string '' | | <code>handle CreateByClassname(string ''classname'')</code> | ||
| Creates an entity by class | | Creates an entity by [[classname]] with the initial origin <code>(0,0,0)</code>. {{note|The classname keyvalue of an entity can be manipulated and does not necessarily reflect its code class. Also, there are entities that have a different classname than the one they are created with.}} | ||
|- | |- | ||
| <code>FindByClassname</code> | | <code>FindByClassname</code> | ||
| <code>handle FindByClassname(handle ''previous'', string '' | | <code>handle FindByClassname(handle ''previous'', string ''classname'')</code> | ||
| Find entities by | | Find entities by the value of their <code>classname</code> keyvalue. | ||
|- | |- | ||
| <code>FindByClassnameNearest</code> | | <code>FindByClassnameNearest</code> | ||
| <code>handle FindByClassnameNearest(string ''class'', Vector ''origin'', float ''radius'')</code> | | <code>handle FindByClassnameNearest(string ''class'', Vector ''origin'', float ''radius'')</code> | ||
| Find the entity | | Find the entity by the value of its <code>classname</code> keyvalue nearest to the specified <code>origin</code>. | ||
|- | |- | ||
| <code>FindByClassnameWithin</code> | | <code>FindByClassnameWithin</code> | ||
| <code>handle FindByClassnameWithin(handle ''previous'', string '' | | <code>handle FindByClassnameWithin(handle ''previous'', string ''classname'', Vector ''origin'', float ''radius'')</code> | ||
| Find entities by | | Find entities by the value of their <code>classname</code> keyvalue within a <code>radius</code> around an <code>origin</code>. | ||
|- | |- | ||
| <code>FindByModel</code> | | <code>FindByModel</code> | ||
| <code>handle FindByModel(handle ''previous'', string '' | | <code>handle FindByModel(handle ''previous'', string ''modelname'')</code> | ||
| Find entities by model | | Find entities by the value of their <code>model</code> keyvalue. {{tip|Useful to distinguish between entities with an identical classname keyvalue, for example {{ent|weapon_mp7}} and {{ent|weapon_mp5sd}}, see [[:Category:Counter-Strike: Global Offensive Weapons#Manipulating Weapons|Category: CS:GO Weapons]].}} | ||
|- | |- | ||
| <code>FindByName</code> | | <code>FindByName</code> | ||
| <code>handle FindByName(handle ''previous'', string '' | | <code>handle FindByName(handle ''previous'', string ''targetname'')</code> | ||
| Find entities by | | Find entities by the value of their <code>[[targetname]]</code> keyvalue. | ||
|- | |- | ||
| <code>FindByNameNearest</code> | | <code>FindByNameNearest</code> | ||
| <code>handle FindByNameNearest(string '' | | <code>handle FindByNameNearest(string ''targetname'', Vector ''origin'', float ''radius'')</code> | ||
| Find entities by | | Find entities by the value of their <code>targetname</code> keyvalue nearest to a point. | ||
|- | |- | ||
| <code>FindByNameWithin</code> | | <code>FindByNameWithin</code> | ||
| <code>handle FindByNameWithin(handle ''previous'', string '' | | <code>handle FindByNameWithin(handle ''previous'', string ''targetname'', Vector ''origin'', float ''radius'')</code> | ||
| Find entities by | | Find entities by the value of their <code>targetname</code> keyvalue within a radius. | ||
|- | |- | ||
| <code>FindByTarget</code> | | <code>FindByTarget</code> | ||
| <code>handle FindByTarget(handle ''previous'', string '' | | <code>handle FindByTarget(handle ''previous'', string ''target'')</code> | ||
| Find entities by | | Find entities by the value of their <code>target</code> keyvalue. | ||
|- | |- | ||
| <code>FindInSphere</code> | | <code>FindInSphere</code> | ||
| <code>handle FindInSphere(handle ''previous'', Vector ''origin'', float ''radius'')</code> | | <code>handle FindInSphere(handle ''previous'', Vector ''origin'', float ''radius'')</code> | ||
| Find entities within a radius. | | Find entities within a <code>radius</code> around an <code>origin</code>. | ||
|- | |- | ||
| <code>First</code> | | <code>First</code> | ||
| <code>handle First()</code> | | <code>handle First()</code> | ||
| | | Returns the first entity, typically ''[[worldspawn]]''. Equivalent to <code>Entities.Next(null)</code> | ||
|- | |- | ||
| <code>Next</code> | | <code>Next</code> | ||
| <code>handle Next(handle ''previous'')</code> | | <code>handle Next(handle ''previous'')</code> | ||
| | | At the given reference of a previously-found entity, returns the next one after it in the list. | ||
|- | |- | ||
| <code>IsValid</code> | | <code>IsValid</code> | ||
Line 678: | Line 714: | ||
|} | |} | ||
=== CPlayerVoiceListener === | |||
{{warning|Broken! This class is implemented in CS:GO, but the required <code>PlayerVoiceListener</code> instance is not.}} | |||
==== Methods ==== | ==== Methods ==== | ||
Line 689: | Line 725: | ||
|- | |- | ||
| <code>GetPlayerSpeechDuration</code> | | <code>GetPlayerSpeechDuration</code> | ||
| <code>float GetPlayerSpeechDuration(int)</code> | | <code>float GetPlayerSpeechDuration(int ''playerIndex'')</code> | ||
| Returns the number of seconds the player has been continuously speaking. | | Returns the number of seconds the player has been continuously speaking. | ||
|- | |- | ||
| <code>IsPlayerSpeaking</code> | | <code>IsPlayerSpeaking</code> | ||
| <code>bool IsPlayerSpeaking(int)</code> | | <code>bool IsPlayerSpeaking(int ''playerIndex'')</code> | ||
| Returns whether the player specified is speaking. | | Returns whether the player specified is speaking. | ||
|- | |- | ||
Line 705: | Line 741: | ||
Script handle representation of a models [[$keyvalues]] block. | Script handle representation of a models [[$keyvalues]] block. | ||
Sub keys are instances of the same class. | Sub keys are instances of the same class. | ||
==== Methods ==== | ==== Methods ==== | ||
Line 715: | Line 752: | ||
|- | |- | ||
| <code>FindKey</code> | | <code>FindKey</code> | ||
| <code>CScriptKeyValues FindKey(string '' | | <code>CScriptKeyValues FindKey(string ''key'')</code> | ||
| Find a sub key by the key name. | | Find a sub key by the key name. | ||
|- | |- | ||
Line 723: | Line 760: | ||
|- | |- | ||
| <code>GetKeyBool</code> | | <code>GetKeyBool</code> | ||
| <code>bool GetKeyBool(string '' | | <code>bool GetKeyBool(string ''key'')</code> | ||
| Return the key value as a bool. | | Return the key value as a bool. | ||
|- | |- | ||
| <code>GetKeyFloat</code> | | <code>GetKeyFloat</code> | ||
| <code>float GetKeyFloat(string '' | | <code>float GetKeyFloat(string ''key'')</code> | ||
| Return the key value as a float. | | Return the key value as a float. | ||
|- | |- | ||
| <code>GetKeyInt</code> | | <code>GetKeyInt</code> | ||
| <code>int GetKeyInt(string '' | | <code>int GetKeyInt(string ''key'')</code> | ||
| Return the key value as an integer. | | Return the key value as an integer. | ||
|- | |- | ||
| <code>GetKeyString</code> | | <code>GetKeyString</code> | ||
| <code>string GetKeyString(string '' | | <code>string GetKeyString(string ''key'')</code> | ||
| Return the key value as a string. | | Return the key value as a string. | ||
|- | |- | ||
| <code>GetNextKey</code> | | <code>GetNextKey</code> | ||
| <code> | | <code>CScriptKeyValues GetNextKey()</code> | ||
| Return the next neighbor key object to the one the method is called on. | | Return the next neighbor key object to the one the method is called on. | ||
|- | |- | ||
| <code>IsKeyEmpty</code> | | <code>IsKeyEmpty</code> | ||
| <code>bool IsKeyEmpty(string '' | | <code>bool IsKeyEmpty(string ''key'')</code> | ||
| Returns true if the named key has no value. | | Returns true if the named key has no value. | ||
|- | |- | ||
| <code>IsValid</code> | | <code>IsValid</code> | ||
| <code>bool IsValid()</code> | | <code>bool IsValid()</code> | ||
| Whether the handle belongs to a valid | | Whether the handle belongs to a valid key. | ||
|- | |- | ||
| <code>ReleaseKeyValues</code> | | <code>ReleaseKeyValues</code> | ||
Line 755: | Line 792: | ||
|} | |} | ||
=== CCallChainer === | |||
'''CCallChainer''' objects collect all functions with a matching prefix in a given scope, then inserts it all into the <code>chains</code> table with the prefix removed. All collected unprefixed functions can then be called in a chain using the class's <code>Call()</code> method, given the method's ''event'' argument matches the functions' name. | |||
Whenever a '''CCallChainer''' object is created, a function named <code>Dispatch</code> followed by its given prefix will also be created, which the class binds the environment of its <code>Call()</code> method to. | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | |||
! Function | |||
! Signature | |||
! Description | |||
|- | |||
| <code>constructor</code> | |||
| <code>CCallChainer(string ''functionPrefix'', table ''scope'' = null)</code> | |||
| Creates a CCallChainer object that'll collect functions that have a matching prefix in the given scope. | |||
|- | |||
| <code>PostScriptExecute</code> | |||
| <code>void PostScriptExecute()</code> | |||
| Search for all non-native functions with matching prefixes, then push them into the <code>chains</code> table. | |||
|- | |||
| <code>Call</code> | |||
| <code>bool Call(string ''event'', any ...)</code> | |||
| Find an unprefixed function name in the <code>chains</code> table and call it with the given arguments. | |||
|} | |||
==== Members ==== | |||
{| class="standard-table" style="width: 100%;" | |||
! Instance | |||
! Type | |||
! Description | |||
|- | |||
| <code>chains</code> | |||
| <code>table</code> | |||
| Contains names of unprefixed functions, each with an array of functions to call. | |||
|- | |||
| <code>prefix</code> | |||
| <code>string</code> | |||
| Prefix that functions should have to be added into the <code>chains</code> table. Set by the constructor. | |||
|- | |||
| <code>scope</code> | |||
| <code>table</code> | |||
| If set, seek functions in this scope instead. Set by the constructor. | |||
|} | |||
=== CSimpleCallChainer === | === CSimpleCallChainer === | ||
Intended to be simpler to use than [[#CCallChainer|CCallChainer]], the class '''CSimpleCallChainer''' holds only a single chain of functions inside an array instead of multiple inside a table. As such, its <code>Call()</code> method does not need a function's name. | |||
{ | |||
This class is also used internally by these [[#CBaseEntity|CBaseEntity]] hooks: <code>Precache()</code> and <code>OnPostSpawn()</code>. | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | |||
! Function | |||
! Signature | |||
! Description | |||
|- | |||
| <code>constructor</code> | |||
| <code>CSimpleCallChainer(string ''functionPrefix'', table ''scope'' = null, exactMatch = false)</code> | |||
| Creates a CSimpleCallChainer object that'll collect functions that have a matching prefix in the given scope, unless it seek for an exact name match. | |||
|- | |||
| <code>PostScriptExecute</code> | |||
| <code>void PostScriptExecute()</code> | |||
| Begin searching for all non-native functions with matching prefixes, then push them into the <code>chain</code> array. | |||
|- | |||
| <code>Call</code> | |||
| <code>bool Call(any ...)</code> | |||
| Call all functions inside the <code>chain</code> array with the given arguments. | |||
|} | |||
==== Members ==== | |||
{| class="standard-table" style="width: 100%;" | |||
! Instance | |||
! Type | |||
! Description | |||
|- | |||
| <code>chain</code> | |||
| <code>array</code> | |||
| All functions to be called by the <code>Call()</code> method. | |||
|- | |||
| <code>exactMatch</code> | |||
| <code>bool</code> | |||
| If set, names of non-native functions and <code>prefix</code> must be an exact match. Set by the constructor. | |||
|- | |||
| <code>prefix</code> | |||
| <code>string</code> | |||
| Prefix that functions should have to be added into the <code>chain</code> array. Set by the constructor. | |||
|- | |||
| <code>scope</code> | |||
| <code>table</code> | |||
| If set, seek functions in this scope instead. Set by the constructor. | |||
|} | |||
=== LateBinder === | === LateBinder === | ||
Line 788: | Line 909: | ||
When End() is called, all of the unresolved symbols in the tables and arrays will be resolved, any left unresolved will become a string prepended with '~', which later code can deal with. | When End() is called, all of the unresolved symbols in the tables and arrays will be resolved, any left unresolved will become a string prepended with '~', which later code can deal with. | ||
==== Methods ==== | ==== Methods ==== | ||
Line 821: | Line 943: | ||
| <code>UnhookRootMetamethod</code> | | <code>UnhookRootMetamethod</code> | ||
|} | |} | ||
=== regexp === | === regexp === | ||
The built-in [http://squirrel-lang.org/doc/ | The built-in [http://squirrel-lang.org/doc/sqstdlib2.html#d0e2580 Squirrel class] for regular expressions. | ||
==== Methods ==== | ==== Methods ==== | ||
Line 840: | Line 964: | ||
|- | |- | ||
| <code>match</code> | | <code>match</code> | ||
| <code> bool match(''str'')</code> | | <code>bool match(''str'')</code> | ||
| Returns a true if the regular expression matches the string str, otherwise returns false. | | Returns a true if the regular expression matches the string str, otherwise returns false. | ||
|- | |- | ||
Line 858: | Line 982: | ||
Three-dimensional vector. | Three-dimensional vector. | ||
Has overloaded | Has overloaded operations for the following: | ||
<code>Vector * number</code> | |||
<code>Vector + Vector</code> | |||
<code>Vector - Vector</code> | |||
==== Methods ==== | ==== Methods ==== | ||
Line 869: | Line 995: | ||
|- | |- | ||
| <code>constructor</code> | | <code>constructor</code> | ||
| <code>Vector(float ''x'', float ''y'', float ''z'')</code> | | <code>Vector(float ''x'' = 0, float ''y'' = 0, float ''z'' = 0)</code> | ||
| Creates a new vector with the specified Cartesian coordiantes. | | Creates a new vector with the specified Cartesian coordiantes. | ||
|- | |- | ||
| <code>Cross</code> | | <code>Cross</code> | ||
| <code>float Cross(Vector ''factor'')</code> | | <code>float Cross(Vector ''factor'')</code> | ||
| The vector product of two vectors. Returns a vector orthogonal to the input vectors. | | The [[wiki:Cross product|vector product]] of two vectors. Returns a vector orthogonal to the input vectors. | ||
|- | |- | ||
| <code>Dot</code> | | <code>Dot</code> | ||
| <code>float Dot(Vector ''factor'')</code> | | <code>float Dot(Vector ''factor'')</code> | ||
| The scalar product of two vectors. | | The [[wiki:Dot product|scalar product]] of two vectors. | ||
|- | |- | ||
| <code>Length</code> | | <code>Length</code> | ||
| <code>float Length()</code> | | <code>float Length()</code> | ||
| | | Length of the vector. | ||
|- | |- | ||
| <code>LengthSqr</code> | | <code>LengthSqr</code> | ||
| <code>float LengthSqr()</code> | | <code>float LengthSqr()</code> | ||
| | | Length of the vector squared. Cheaper than the above method. | ||
|- | |- | ||
| <code>Length2D</code> | | <code>Length2D</code> | ||
| <code>float Length2D()</code> | | <code>float Length2D()</code> | ||
| Returns the | | Returns the length of the vector on the x-y plane. | ||
|- | |- | ||
| <code>Length2DSqr</code> | | <code>Length2DSqr</code> | ||
| <code>float Length2DSqr()</code> | | <code>float Length2DSqr()</code> | ||
| Returns the square of the | | Returns the square of the length of the vector on the x-y plane. Cheaper than the above method. | ||
|- | |- | ||
| <code>Norm</code> | | <code>Norm</code> | ||
| <code>float Norm()</code> | | <code>float Norm()</code> | ||
| | | Normalises the vector, returns the vector length. | ||
|- | |- | ||
| <code>ToKVString</code> | | <code>ToKVString</code> | ||
Line 904: | Line 1,030: | ||
| Returns a string without separations commas. | | Returns a string without separations commas. | ||
|} | |} | ||
==== Members ==== | ==== Members ==== | ||
Line 927: | Line 1,054: | ||
== Global functions == | == Global functions == | ||
=== Printing and | |||
=== Printing and drawing === | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
Line 935: | Line 1,063: | ||
|- | |- | ||
| <code>DebugDrawBox</code> | | <code>DebugDrawBox</code> | ||
| <code>void DebugDrawBox(vector ''origin'', vector '' | | <code>void DebugDrawBox(vector ''origin'', vector ''mins'', vector ''maxs'', int ''r'', int ''g'', int ''b'', int ''alpha'', float ''duration'')</code> | ||
| Draw a debug overlay box. | | Draw a debug overlay box in the specified color for the specified duration with two corners being <code>origin + mins</code> and <code>origin + maxs</code>. The <code>alpha</code> is the fill rate (0-255). Set ''duration'' to 0 if drawn every tick. | ||
|- | |||
| <code>DebugDrawBoxAngles</code> | |||
| <code>void DebugDrawBoxAngles(Vector ''origin'', Vector ''mins'', Vector ''maxs'', Vector ''angles'', int ''r'', int ''g'', int ''b'', int ''alpha'', float ''duration'')</code> | |||
| Draw a debug overlay box with angles in the specified color for the specified duration with two corners being <code>origin + mins</code> and <code>origin + maxs</code> + <code>angles</code>. The <code>alpha</code> is the fill rate (0-255). Set ''duration'' to 0 if drawn every tick. | |||
|- | |- | ||
| <code>DebugDrawLine</code> | | <code>DebugDrawLine</code> | ||
| <code>void DebugDrawLine(Vector ''start'', Vector ''end'', int '' | | <code>void DebugDrawLine(Vector ''start'', Vector ''end'', int ''r'', int ''g'', int ''b'', bool ''noDepthTest'', float ''duration'')</code> | ||
| Draw a debug line between | | Draw a debug line between the points <code>start</code> and <code>end</code> in the specified color for the specified duration. Set ''duration'' to 0 if drawn every tick. | ||
|- | |- | ||
| <code>Msg</code> | | <code>Msg</code> | ||
Line 952: | Line 1,084: | ||
| <code>printl</code> | | <code>printl</code> | ||
| <code>void printl(string ''message'')</code> | | <code>void printl(string ''message'')</code> | ||
| Prints the given message to the developer console | | Prints the given message to the developer console with newline. Equivalent to <code>print(message + "\n")</code> | ||
|- | |- | ||
| <code>ScriptPrintMessageCenterAll</code> | | <code>ScriptPrintMessageCenterAll</code> | ||
Line 960: | Line 1,092: | ||
| <code>ScriptPrintMessageCenterAllWithParams</code> | | <code>ScriptPrintMessageCenterAllWithParams</code> | ||
| <code>void ScriptPrintMessageCenterAllWithParams(string ''message'', string ''param1'', string ''param2'', string ''param3'')</code> | | <code>void ScriptPrintMessageCenterAllWithParams(string ''message'', string ''param1'', string ''param2'', string ''param3'')</code> | ||
| Prints an alert message in the center print method to all players. Needs to pass token/message | | Prints an alert message in the center print method to all players. Needs to pass token/message. | ||
|- | |- | ||
| <code>ScriptPrintMessageCenterTeam</code> | | <code>ScriptPrintMessageCenterTeam</code> | ||
| <code>void ScriptPrintMessageCenterTeam(int, string)</code> | | <code>void ScriptPrintMessageCenterTeam(int, string)</code> | ||
| Prints an alert message in the center of the screen to the specified team. | | Prints an alert message in the center of the screen to the specified team. | ||
* 0 : None | |||
* 1 : Spectators | |||
* 2 : Terrorists | |||
* 3 : Counter-Terrorists | |||
{{Warning|Game crashes for other team numbers!}} | |||
|- | |- | ||
| <code>ScriptPrintMessageChatAll</code> | | <code>ScriptPrintMessageChatAll</code> | ||
Line 971: | Line 1,108: | ||
|- | |- | ||
| <code>ScriptPrintMessageChatTeam</code> | | <code>ScriptPrintMessageChatTeam</code> | ||
| <code>void ScriptPrintMessageChatTeam(int '' | | <code>void ScriptPrintMessageChatTeam(int ''team'', string ''message'')</code> | ||
| Prints a message in chat to the specified team. | | Prints a message in chat to the specified team. | ||
{{Warning|Game crashes for other team numbers than the above!}} | |||
|- | |- | ||
| <code>ShowMessage</code> | | <code>ShowMessage</code> | ||
| <code>void ShowMessage(string)</code> | | <code>void ShowMessage(string)</code> | ||
| Print a hud message on all clients. {{ | | Print a hud message on all clients. {{Note|Uses localized strings as found in <code>/scripts/titles.txt</code>}} | ||
|- | |- | ||
| <code>__DumpScope</code> | | <code>__DumpScope</code> | ||
| <code>void __DumpScope(int ''indentation'', | | <code>void __DumpScope(int ''indentation'', table ''scope'')</code> | ||
| Dumps contents of | | Dumps the contents of ''scope''. | ||
|- | |- | ||
|} | |} | ||
=== Training Course | === Training Course === | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 1,008: | Line 1,147: | ||
|- | |- | ||
| <code>ScriptSetBestTrainingCourseTime</code> | | <code>ScriptSetBestTrainingCourseTime</code> | ||
| <code>void ScriptSetBestTrainingCourseTime(int '' | | <code>void ScriptSetBestTrainingCourseTime(int ''time'')</code> | ||
| Sets the player's best time for completing the timed course. | | Sets the player's best time for completing the timed course. | ||
|- | |- | ||
| <code>ScriptSetMiniScoreHidden</code> | | <code>ScriptSetMiniScoreHidden</code> | ||
| <code>void ScriptSetMiniScoreHidden(bool '' | | <code>void ScriptSetMiniScoreHidden(bool ''hide'')</code> | ||
| Toggles the visibility of the miniscoreboard hud element. | | Toggles the visibility of the miniscoreboard hud element. | ||
|- | |- | ||
| <code>ScriptSetPlayerCompletedTraining</code> | | <code>ScriptSetPlayerCompletedTraining</code> | ||
| <code>void ScriptSetPlayerCompletedTraining(bool '' | | <code>void ScriptSetPlayerCompletedTraining(bool ''completed'')</code> | ||
| Sets whether the player has completed the initial portion of the training map. | | Sets whether the player has completed the initial portion of the training map. | ||
|- | |||
| <code>ScriptSetRadarHidden</code> | |||
| <code>void ScriptSetRadarHidden(bool ''hide'')</code> | |||
| Toggles the visibility of the radar hud element. | |||
|- | |- | ||
| <code>ScriptShowExitDoorMsg</code> | | <code>ScriptShowExitDoorMsg</code> | ||
Line 1,034: | Line 1,177: | ||
=== Co-op Strike | === [[Creating a Co-op Strike Map|Co-op Strike]] === | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 1,042: | Line 1,186: | ||
| <code>ScriptCoopCollectBonusCoin</code> | | <code>ScriptCoopCollectBonusCoin</code> | ||
| <code>void ScriptCoopCollectBonusCoin()</code> | | <code>void ScriptCoopCollectBonusCoin()</code> | ||
| Marks one of the bonus coins as collected. | | Marks one of the [[Item coop coin|bonus coins]] as collected. | ||
|- | |- | ||
| <code>ScriptCoopGiveC4sToCTs</code> | | <code>ScriptCoopGiveC4sToCTs</code> | ||
| <code>void ScriptCoopGiveC4sToCTs(int)</code> | | <code>void ScriptCoopGiveC4sToCTs(int)</code> | ||
| Will give the number of specified | | Will give the number of specified [[weapon_c4|C4]]s to all alive CT players. | ||
|- | |- | ||
| <code>ScriptCoopMissionGetMissionNumber</code> | | <code>ScriptCoopMissionGetMissionNumber</code> | ||
Line 1,055: | Line 1,199: | ||
| <code>void ScriptCoopMissionRespawnDeadPlayers()</code> | | <code>void ScriptCoopMissionRespawnDeadPlayers()</code> | ||
| Respawns players only. | | Respawns players only. | ||
|- | |||
| <code>ScriptCoopMissionSetDeadPlayerRespawnEnabled</code> | |||
| <code>void ScriptCoopMissionSetDeadPlayerRespawnEnabled(bool)</code> | |||
| Controls whether player respawns can happen. | |||
|- | |- | ||
| <code>ScriptCoopMissionSetNextRespawnIn</code> | | <code>ScriptCoopMissionSetNextRespawnIn</code> | ||
Line 1,074: | Line 1,222: | ||
| <code>ScriptCoopSetBotQuotaAndRefreshSpawns</code> | | <code>ScriptCoopSetBotQuotaAndRefreshSpawns</code> | ||
| <code>void ScriptCoopSetBotQuotaAndRefreshSpawns(int)</code> | | <code>void ScriptCoopSetBotQuotaAndRefreshSpawns(int)</code> | ||
| Sets the bot quota considering the # of players connected and refreshes the spawns. | | Sets the [[bot quota]] considering the # of players connected and refreshes the spawns. | ||
|- | |||
| <code>ScriptCoopExtendRoundDurationTime</code> | |||
| <code>void ScriptCoopExtendRoundDurationTime(float)</code> | |||
| Extends the round time after checkpoint during the mission. | |||
|- | |||
| <code>ScriptCoopToggleEntityOutlineHighlights</code> | |||
| <code>void ScriptCoopToggleEntityOutlineHighlights(bool)</code> | |||
| Highlights all dropped weapons for players, or removes all highlights. | |||
|- | |||
| <code>ScriptMissionResetDangerZones</code> | |||
| <code>void ScriptMissionResetDangerZones()</code> | |||
| Resets all danger zone entities. | |||
|- | |||
| <code>ScriptMissionCreateAndDetonateDangerZone</code> | |||
| <code>void ScriptMissionCreateAndDetonateDangerZone(Vector, Vector)</code> | |||
| Creates and detonates a danger zone at the given location moving towards target location. | |||
|- | |- | ||
|} | |} | ||
=== Math | |||
The built-in [http://www.squirrel-lang.org/ | === Premier Mode === | ||
{| class="standard-table" style="width: 100%;" | |||
! Function | |||
! Signature | |||
! Description | |||
|- | |||
| <code>ScriptLobbyMapVetoFinished</code> | |||
| <code>void ScriptLobbyMapVetoFinished(string mapname, bool, bool, string)</code> | |||
| Switch to the selected map after lobby map veto finished. | |||
|- | |||
|} | |||
=== Math === | |||
The built-in [http://www.squirrel-lang.org/mainsite/doc/sqstdlib2.html#d0e1519 Squirrel math library]. | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
Line 1,088: | Line 1,268: | ||
| <code>abs</code> | | <code>abs</code> | ||
| <code> int abs(float ''x'')</code> | | <code> int abs(float ''x'')</code> | ||
| Returns the absolute value of x as an integer. | | Returns the absolute value of <code>x</code> as an integer. | ||
|- | |- | ||
| <code>acos</code> | | <code>acos</code> | ||
| <code> float acos(float ''x'')</code> | | <code> float acos(float ''x'')</code> | ||
| Returns the arccosine of x. | | Returns the arccosine of <code>x</code>. | ||
|- | |- | ||
| <code>asin</code> | | <code>asin</code> | ||
| <code> float asin(float ''x'')</code> | | <code> float asin(float ''x'')</code> | ||
| Returns the arcsine of x. | | Returns the arcsine of <code>x</code>. | ||
|- | |- | ||
| <code>atan</code> | | <code>atan</code> | ||
| <code> float atan(float ''x'')</code> | | <code> float atan(float ''x'')</code> | ||
| Returns the arctangent of x. | | Returns the arctangent of <code>x</code>. | ||
|- | |- | ||
| <code>atan2</code> | | <code>atan2</code> | ||
| <code> float atan2(float ''x'', float ''y'')</code> | | <code> float atan2(float ''x'', float ''y'')</code> | ||
| Returns the arctangent of x/y. | | Returns the arctangent of <code>x/y</code>. | ||
|- | |- | ||
| <code>ceil</code> | | <code>ceil</code> | ||
| <code> float ceil(float ''x'')</code> | | <code> float ceil(float ''x'')</code> | ||
| Returns a float value representing the smallest integer that is greater than or equal to x. | | Returns a float value representing the smallest integer that is greater than or equal to <code>x</code>. | ||
|- | |- | ||
| <code>cos</code> | | <code>cos</code> | ||
| <code> float cos(float ''x'')</code> | | <code> float cos(float ''x'')</code> | ||
| Returns the cosine of x. | | Returns the cosine of <code>x</code>. | ||
|- | |- | ||
| <code>exp</code> | | <code>exp</code> | ||
| <code> float exp(float ''x'')</code> | | <code> float exp(float ''x'')</code> | ||
| Returns the exponential value of the float parameter x. | | Returns the exponential value (<code>e^x</code>) of the float parameter <code>x</code>. | ||
|- | |- | ||
| <code>fabs</code> | | <code>fabs</code> | ||
| <code> float fabs(float ''x'')</code> | | <code> float fabs(float ''x'')</code> | ||
| Returns the absolute value of x as a float. | | Returns the absolute value of <code>x</code> as a float. | ||
|- | |- | ||
| <code>floor</code> | | <code>floor</code> | ||
| <code> float floor(float ''x'')</code> | | <code> float floor(float ''x'')</code> | ||
| Returns a float value representing the largest integer that is less than or equal to x. | | Returns a float value representing the largest integer that is less than or equal to <code>x</code>. | ||
|- | |- | ||
| <code>log</code> | | <code>log</code> | ||
| <code> float log(float ''x'')</code> | | <code> float log(float ''x'')</code> | ||
| Returns the natural logarithm of x. | | Returns the natural logarithm of <code>x</code>. | ||
|- | |- | ||
| <code>log10</code> | | <code>log10</code> | ||
| <code> float log10(float ''x'')</code> | | <code> float log10(float ''x'')</code> | ||
| Returns the logarithm base-10 of x. | | Returns the logarithm base-10 of <code>x</code>. | ||
|- | |- | ||
| <code>pow</code> | | <code>pow</code> | ||
| <code> float pow(float ''x'', float ''y'')</code> | | <code> float pow(float ''x'', float ''y'')</code> | ||
| Returns x raised to the power of y. | | Returns <code>x</code> raised to the power of <code>y</code>. | ||
|- | |- | ||
| <code>rand</code> | | <code>rand</code> | ||
| <code> int rand()</code> | | <code> int rand()</code> | ||
| Returns a pseudorandom integer in the range 0 to RAND_MAX. | | Returns a pseudorandom integer in the range 0 to <code>RAND_MAX</code>. | ||
|- | |- | ||
| <code>sin</code> | | <code>sin</code> | ||
| <code> float sin(float ''x'')</code> | | <code> float sin(float ''x'')</code> | ||
| Returns the sine of x. | | Returns the sine of <code>x</code>. | ||
|- | |- | ||
| <code>sqrt</code> | | <code>sqrt</code> | ||
| <code> float sqrt(float ''x'')</code> | | <code> float sqrt(float ''x'')</code> | ||
| Returns the square root of x. | | Returns the square root of <code>x</code>. | ||
|- | |- | ||
| <code>srand</code> | | <code>srand</code> | ||
Line 1,156: | Line 1,336: | ||
| <code>tan</code> | | <code>tan</code> | ||
| <code> float tan(float ''x'')</code> | | <code> float tan(float ''x'')</code> | ||
| Returns the tangent of x. | | Returns the tangent of <code>x</code>. | ||
|} | |} | ||
=== Other === | === Other === | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 1,167: | Line 1,348: | ||
|- | |- | ||
| <code>Assert</code> | | <code>Assert</code> | ||
| <code>void Assert( | | <code>void Assert(''exp'', string ''message'' = null)</code> | ||
| | | Throws an exception if ''exp'' equates to false, optionally with message. | ||
|- | |- | ||
| <code>CreateProp</code> | | <code>CreateProp</code> | ||
| <code>handle CreateProp(string '' | | <code>handle CreateProp(string ''classname'', Vector ''origin'', string ''model'', int ''animation'')</code> | ||
| Create a prop with the specified class and model. Both prop_physics, prop_dynamic as well as some other entity classes with models work. Does not precache the model. | | Create a prop with the specified class and model. Both [[prop_physics]], [[prop_dynamic]] as well as some other entity classes with models work. Does not precache the model. | ||
|- | |- | ||
| <code>CreateSceneEntity</code> | | <code>CreateSceneEntity</code> | ||
| <code>CSceneEntity CreateSceneEntity(string ''scene'')</code> | | <code>CSceneEntity CreateSceneEntity(string ''scene'')</code> | ||
| Create a scene entity to play the specified scene .vcd file. | | Create a scene entity to play the specified scene [[VCD|.vcd file]]. | ||
|- | |- | ||
| <code>DispatchParticleEffect</code> | | <code>DispatchParticleEffect</code> | ||
| <code>void DispatchParticleEffect(string | | <code>void DispatchParticleEffect(string ''particle'', Vector ''position'', Vector ''orientation'')</code> | ||
| Dispatches a one-off particle system. | | Dispatches a one-off particle system. See [[List of CS:GO Particles]]. Does not work if the particle is not precached.{{how}} {{note|Looped animations will stay until the round is reset.}} | ||
|- | |- | ||
| <code>DoIncludeScript</code> | | <code>DoIncludeScript</code> | ||
| <code>bool DoIncludeScript(string ''filename'', table ''scope'')</code> | | <code>bool DoIncludeScript(string ''filename'', table ''scope'')</code> | ||
| Execute | | Execute the script file <code>"csgo/scripts/vscripts/" + filename</code> in the scope of <code>scope</code>. The extension <code>.nut</code> can be omitted. Returns true if the script was found and executed, otherwise false. | ||
|- | |||
| <code>IncludeScript</code> | |||
| <code>bool IncludeScript(string ''filename'', table ''scope'' = null)</code> | |||
| Execute the script file <code>"csgo/scripts/vscripts/" + filename</code> in the scope of <code>scope</code>, <code>this</code> by default. The extension <code>.nut</code> can be omitted. Returns true if the script was found and executed, otherwise false. | |||
|- | |- | ||
| <code>DoEntFire</code> | | <code>DoEntFire</code> | ||
| <code>void DoEntFire(string ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code> | | <code>void DoEntFire(string ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code> | ||
| Generate an entity I/O event | | Generate an entity [[I/O]] event. | ||
|- | |- | ||
| <code>EntFire</code> | | <code>EntFire</code> | ||
| <code> | | <code>void EntFire(string ''target'', string ''action'', string ''value'' = "", float ''delay'' = 0.0, handle ''activator'' = null)</code> | ||
| Generate an entity I/O event. | | Generate an entity I/O event. | ||
|- | |- | ||
| <code>EntFireByHandle</code> | | <code>EntFireByHandle</code> | ||
| <code>void EntFireByHandle(handle ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code> | | <code>void EntFireByHandle(handle ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code> | ||
| Generate an entity I/O event | | Generate an entity I/O event. | ||
|- | |- | ||
| <code>FrameTime</code> | | <code>FrameTime</code> | ||
| <code>float FrameTime()</code> | | <code>float FrameTime()</code> | ||
| Get the time spent on the server in the last frame | | Get the time spent on the server in the last frame. | ||
|- | |- | ||
| <code>GetDeveloperLevel</code> | | <code>GetDeveloperLevel</code> | ||
| <code>int GetDeveloperLevel()</code> | | <code>int GetDeveloperLevel()</code> | ||
| Gets the level of the ''developer'' mode. | | Gets the level of the ''developer'' mode. Equivalent to <code>developer()</code>. | ||
|- | |- | ||
| <code>GetMapName</code> | | <code>GetMapName</code> | ||
| <code>string GetMapName()</code> | | <code>string GetMapName()</code> | ||
| Get the name of the map. | | Get the name of the map, e.g. <code>"de_dust2"</code>. | ||
|- | |- | ||
| <code>LoopSinglePlayerMaps</code> | | <code>LoopSinglePlayerMaps</code> | ||
| <code>bool LoopSinglePlayerMaps()</code> | | <code>bool LoopSinglePlayerMaps()</code> | ||
| | | Returns the boolean value of the ConVar <code>loopsingleplayermaps</code>, i.e. whether the single player maps are run in a continuous loop. | ||
|- | |- | ||
| <code>PrintHelp</code> | | <code>PrintHelp</code> | ||
| <code>void PrintHelp(string ''string'' = "*", bool ''exact'' = false)</code> | | <code>void PrintHelp(string ''string'' = "*", bool ''exact'' = false)</code> | ||
| Output help for script functions, optionally with a search string | | Output help for script functions, optionally with a search string. | ||
|- | |- | ||
| <code>RandomFloat</code> | | <code>RandomFloat</code> | ||
| <code>float RandomFloat(float ''min'', float ''max'')</code> | | <code>float RandomFloat(float ''min'', float ''max'')</code> | ||
| Generate a random floating point number within a range, inclusive | | Generate a random floating point number within a range, inclusive. | ||
|- | |- | ||
| <code>RandomInt</code> | | <code>RandomInt</code> | ||
| <code>int RandomInt(int ''min'', int ''max'')</code> | | <code>int RandomInt(int ''min'', int ''max'')</code> | ||
| Generate a random integer within a range, inclusive | | Generate a random integer within a range, inclusive. | ||
|- | |- | ||
| <code>RecordAchievementEvent</code> | | <code>RecordAchievementEvent</code> | ||
| <code>void RecordAchievementEvent(string, int)</code> | | <code>void RecordAchievementEvent(string, int)</code> | ||
| Records achievement event or progress | | Records achievement event or progress. | ||
|- | |- | ||
| <code>RetrieveNativeSignature</code> | | <code>RetrieveNativeSignature</code> | ||
| <code>void RetrieveNativeSignature(string '' | | <code>void RetrieveNativeSignature(string ''nativeFunction'')</code> | ||
| | | {{todo}} | ||
|- | |- | ||
| <code>ScriptGetGameMode</code> | | <code>ScriptGetGameMode</code> | ||
| <code>int ScriptGetGameMode()</code> | | <code>int ScriptGetGameMode()</code> | ||
| | | Gets the current [[game mode]]. | ||
|- | |- | ||
| <code>ScriptGetGameType</code> | | <code>ScriptGetGameType</code> | ||
| <code>int ScriptGetGameType()</code> | | <code>int ScriptGetGameType()</code> | ||
| | | Gets the current [[game type]]. | ||
|- | |- | ||
| <code>ScriptGetRoundsPlayed</code> | | <code>ScriptGetRoundsPlayed</code> | ||
| <code>int ScriptGetRoundsPlayed()</code> | | <code>int ScriptGetRoundsPlayed()</code> | ||
| Get the number of rounds | | Get the number of rounds that any team has won so far. {{Warning | Drawn rounds are not counted, except they were ended using a [[game_round_end]] entity.}} | ||
|- | |- | ||
| <code>ScriptIsLocalPlayerUsingController</code> | | <code>ScriptIsLocalPlayerUsingController</code> | ||
Line 1,261: | Line 1,438: | ||
| <code>bool ScriptIsWarmupPeriod()</code> | | <code>bool ScriptIsWarmupPeriod()</code> | ||
| Is it warmup or not. | | Is it warmup or not. | ||
|- | |- | ||
| <code>SendToConsole</code> | | <code>SendToConsole</code> | ||
| <code>void SendToConsole(string ''command'')</code> | | <code>void SendToConsole(string ''command'')</code> | ||
| Send a string to the console as a command. | | Send a string to the console as a client command. The command is executed through the local player or listen server host. If no player is found, this function will only print the developer message <code>Cannot execute "''<command>''", no player</code> in the console. | ||
|- | |- | ||
| <code>SendToConsoleServer</code> | | <code>SendToConsoleServer</code> | ||
| <code>void SendToConsoleServer(string)</code> | | <code>void SendToConsoleServer(string ''command'')</code> | ||
| Send a string that gets executed on the server as a ServerCommand | | Send a string that gets executed on the server as a ServerCommand using [[whitelistcmd]]. Commands or ConVars that are not whitelisted are not executed or changed. | ||
|- | |- | ||
| <code>Time</code> | | <code>Time</code> | ||
| <code>float Time()</code> | | <code>float Time()</code> | ||
| Get the current server time | | Get the current server time in seconds. | ||
|- | |- | ||
| <code>TraceLine</code> | | <code>TraceLine</code> | ||
| <code>float TraceLine(Vector, Vector, handle)</code> | | <code>float TraceLine(Vector ''start'', Vector ''end'', handle ''ignore'')</code> | ||
| | | Given 2 points and an entity to ignore, returns fraction along line that only hits world. | ||
|- | |||
| <code>TraceLinePlayersIncluded</code> | |||
| <code>float TraceLinePlayersIncluded(Vector ''start'', Vector ''end'', handle ''ignore'')</code> | |||
| Given 2 points and entity to ignore, returns fraction along line that hits world, models, players and NPCs. {{Note| Blocking entities are not limited to [[player]], almost everything will block it.}} | |||
|- | |- | ||
| <code>UniqueString</code> | | <code>UniqueString</code> | ||
| <code> | | <code>string UniqueString(string ''suffix'' = "")</code> | ||
| Generate a string guaranteed to be unique across the life of the script VM, with an optional root string. Useful for adding data to tables when not sure what keys are already in use in that table. Equivalent to <code>DoUniqueString(suffix)</code>. | |||
|- | |||
| <code>DoUniqueString</code> | |||
| <code>string DoUniqueString(string ''suffix'')</code> | |||
| Generate a string guaranteed to be unique across the life of the script VM, with an optional root string. Useful for adding data to tables when not sure what keys are already in use in that table. | | Generate a string guaranteed to be unique across the life of the script VM, with an optional root string. Useful for adding data to tables when not sure what keys are already in use in that table. | ||
|- | |- | ||
| <code>__ReplaceClosures</code> | | <code>__ReplaceClosures</code> | ||
| <code>void __ReplaceClosures(function ''script'', table ''scope'')</code> | |||
| Internal function called in <code>script_reload_</code> server commands. | |||
|} | |} | ||
== See | == See also == | ||
* [ | * [[VScript]] | ||
* [[VScript Fundamentals]] | |||
* [[ | * [[Listening to game events in CS:GO|Listening to game events]] | ||
* {{sq}} [[Squirrel]] | |||
* {{csgo}} [[CS:GO VScript Examples|VScript Examples]] | |||
* {{l4d2}} [[Left 4 Dead 2/Script Functions]] | |||
* {{portal2}} [[List of Portal 2 Script Functions]] | * {{portal2}} [[List of Portal 2 Script Functions]] | ||
* {{tf2}} [[Team Fortress 2/Scripting/Script Functions|List of Team Fortress 2 Script Functions]] | |||
[[Category: | {{csgo-navbox}} | ||
{{csgo topicon}} | |||
[[Category:VScript functions]] | |||
[[Category:Scripting]] | [[Category:Scripting]] |
Latest revision as of 08:30, 27 February 2025


It is covered here for historical and technical reference.
This list contains the engine-related Squirrel classes, functions and variables available for VScript in
Counter-Strike: Global Offensive. The official documentation can be printed in the console by setting
developer
to non-zero, loading a map, and executing script_help
.
Variables
Instance | Type | Description |
---|---|---|
Entities
|
CEntities
|
Provides access to spawned entities in the server. |
Constants
Instance | Type | Value |
---|---|---|
_charsize_
|
integer | 1 |
_floatsize_
|
integer | 4 |
_intsize_
|
integer | 4 |
_version_
|
string | "Squirrel 2.2.3 stable" |
RAND_MAX
|
integer | 32767 |
PI
|
float | 3.14159 |

::PI = 3
.Classes
CBaseEntity
This is a script handle class for entities. All entities spawned have a script handle using this or one of its subclasses.
All script handles in-game are accessible from Entities. Entity scripts can use self
to access their own script handle. activator
and caller
variables can be accessed on function calls.
Methods
Function | Signature | Description |
---|---|---|
__KeyValueFromInt
|
bool __KeyValueFromInt(string key, int value)
|
Sets entity keyvalue from an integer. |
__KeyValueFromFloat
|
bool __KeyValueFromFloat(string key, float value)
|
Sets entity keyvalue from a float. |
__KeyValueFromString
|
bool __KeyValueFromString(string key, string value)
|
Sets entity keyvalue from a string. |
__KeyValueFromVector
|
bool __KeyValueFromVector(string key, Vector value)
|
Sets entity keyvalue from a Vector. |
ConnectOutput
|
void ConnectOutput(string output, string function)
|
Adds an I/O connection that will call the named function when the specified output fires. |
DisconnectOutput
|
void DisconnectOutput(string output, string function)
|
Removes a connected script function from an I/O event. |
Destroy
|
void Destroy()
|
Kills the entity. |
EmitSound
|
void EmitSound(string soundname)
|
Plays a sound from this entity. |
entindex
|
int entindex()
|
Returns the entity index. |
EyePosition
|
Vector EyePosition()
|
Get vector to the eye position - absolute coordinates. |
FirstMoveChild
|
handle FirstMoveChild()
|
If in hierarchy, get the first move child. |
GetAngles
|
Vector GetAngles()
|
Get the entity local angles (pitch, yaw, roll) as a Vector object. |
GetAngularVelocity
|
Vector GetAngularVelocity()
|
Get the local angular velocity - returns a Vector of pitch, yaw, roll. |
GetBoundingMaxs
|
Vector GetBoundingMaxs()
|
Get a vector containing max bounds in local space. |
GetBoundingMaxsOriented
|
Vector GetBoundingMaxsOriented()
|
Get a vector containing max bounds, centered on object, taking the object's orientation into account. |
GetBoundingMins
|
Vector GetBoundingMins()
|
Get a vector containing min bounds in local space. |
GetBoundingMinsOriented
|
Vector GetBoundingMinsOriented()
|
Get a vector containing min bounds, centered on object, taking the object's orientation into account. |
GetCenter
|
Vector GetCenter()
|
Get vector to center of object in world space. |
GetClassname
|
string GetClassname()
|
Get entity classname. |
GetForwardVector
|
Vector GetForwardVector()
|
Get the forward vector of the entity in world space. |
GetHealth
|
int GetHealth()
|
Returns the current health. |
GetLeftVector
|
Vector GetLeftVector()
|
Get the right vector of the entity in world space. |
GetMaxHealth
|
int GetMaxHealth()
|
Returns the maximum health. |
GetModelKeyValues
|
CScriptKeyValues GetModelKeyValues()
|
Returns the $keyvalues block of the entity's model as a #CScriptKeyValues object. Note that this is not the keyvalues of the entity itself. |
GetModelName
|
string GetModelName()
|
Returns the value of the entity's model keyvalue or "" .
|
GetMoveParent
|
handle GetMoveParent()
|
If in hierarchy, retrieves the entity's parent. |
GetName
|
string GetName()
|
Returns the targetname of the entity. |
GetOrigin
|
Vector GetOrigin()
|
Returns this entity's local origin. |
GetOwner
|
handle GetOwner()
|
Gets this entity's owner. |
GetPreTemplateName
|
string GetPreTemplateName()
|
Get the entity name stripped of template unique decoration. This is the &048 suffix added by templates that do not preserve the entity name.
|
GetRootMoveParent
|
handle GetRootMoveParent()
|
If in hierarchy, walks up the hierarchy to find the root parent. |
GetScriptId
|
string GetScriptId()
|
Returns the thinkfunction keyvalue of the entity. |
GetScriptScope
|
handle GetScriptScope()
|
Retrieve the table storing the Entity Script data associated with this entity. |
GetSoundDuration
|
float GetSoundDuration(string soundname, string actormodel)
|
Returns float duration of the sound. Todo: Does this work correctly only with .wav files?
|
GetTeam
|
int GetTeam()
|
Get the team this entity is on. |
GetUpVector
|
Vector GetUpVector()
|
Get the up vector of the entity in world space. |
GetVelocity
|
Vector GetVelocity()
|
Get the velocity of the entity. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
NextMovePeer
|
handle NextMovePeer()
|
Return the next entity in the same movement hierarchy. |
PrecacheModel
|
void PrecacheModel(string modelname)
|
Precache a model. Expensive. |
PrecacheScriptSound
|
void PrecacheScriptSound(string soundname)
|
Precache a sound. Expensive. |
PrecacheSoundScript
|
void PrecacheSoundScript(string soundscript)
|
Precache a sound for later playing. Expensive. |
SetAbsOrigin
|
void SetAbsOrigin(Vector position)
|
Set absolute origin. |
SetAngles
|
void SetAngles(float pitch, float yaw, float roll)
|
Set entity local angles (pitch, yaw, roll). |
SetAngularVelocity
|
void SetAngularVelocity(float pitch, float yaw, float roll)
|
Set the local angular velocity - takes float pitch, yaw, roll velocities. |
SetForwardVector
|
void SetForwardVector(Vector forwardvec)
|
Sets entity forward vector in local space. |
SetHealth
|
void SetHealth(int health)
|
Sets the current health. |
SetMaxHealth
|
void SetMaxHealth(int health)
|
Sets the maximum health. |
SetModel
|
void SetModel(string modelname)
|
Changes the model of the entity. Does not precache the model. |
SetOrigin
|
void SetOrigin(Vector position)
|
Set local origin. "Teleports" the entity. |
SetOwner
|
void SetOwner(handle owner)
|
Sets this entity's owner. |
SetSize
|
void SetSize(Vector mins, Vector maxs)
|
Sets the bounding box size. |
SetTeam
|
void SetTeam(int team)
|
Set the team this entity is on. |
SetVelocity
|
void SetVelocity(Vector velocity)
|
Set local velocity. |
StopSound
|
void StopSound(string soundname)
|
Stops a sound on this entity. |
ValidateScriptScope
|
bool ValidateScriptScope()
|
Ensure that an entity's script scope has been created. |
Hooks
If one of these functions are declared in an Entity Script, the entity will run this function automatically in the appropriate situation.
Function | Signature | Description |
---|---|---|
InputInputName
|
bool InputInputName()
|
Called when the entity receives an input from the I/O system. The name of the function needs to be Input followed by the name of the input in CamelCase, for example InputFireUser1 for the FireUser1 input. The function needs to return a boolean value. Setting it to true allows the entity to process the input, while false cancels it.
|
OnPostSpawn
|
void OnPostSpawn()
|
This is called after the entity has spawned. |
Precache
|
void Precache()
|
This is called during entity spawning and after restore to allow scripts to precache any resources they need. |
CBaseAnimating
Extends CBaseEntity
Script handle class for animating entities such as props.
Methods
Function | Signature | Description |
---|---|---|
GetAttachmentAngles
|
Vector GetAttachmentAngles(int id)
|
Get the attachment ID's angles as a pitch, yaw, roll vector. |
GetAttachmentOrigin
|
Vector GetAttachmentOrigin(int id)
|
Get the attachment ID's origin vector. |
IsSequenceFinished
|
bool IsSequenceFinished()
|
Ask whether the main sequence is done playing. |
LookupAttachment
|
int LookupAttachment(string attachmentName)
|
Get the named attachment ID. |
SetBodygroup
|
void SetBodygroup(int groupIndex, int value)
|
Sets the models bodygroup value by index. |
CBaseFlex
Extends CBaseAnimating
Methods
Function | Signature | Description |
---|---|---|
GetCurrentScene
|
handle GetCurrentScene()
|
Returns the instance of the oldest active scene entity (if any). |
GetSceneByIndex
|
handle GetSceneByIndex(int index)
|
Returns the instance of the scene entity at the specified index. |
CBasePlayer
Extends CBaseAnimating
Methods
Function | Signature | Description |
---|---|---|
IsNoclipping
|
bool IsNoclipping()
|
Returns true if the player is in noclip mode. |
CBaseMultiplayerPlayer
Extends CBasePlayer
Script handle class for the CS:GO players. No additional methods.
CEnvEntityMaker
Extends CBaseEntity
Script handle class for env_entity_maker.
Methods
Function | Signature | Description |
---|---|---|
SpawnEntity
|
void SpawnEntity()
|
Create an entity at the location of the maker |
SpawnEntityAtEntityOrigin
|
void SpawnEntityAtEntityOrigin(handle entity)
|
Create an entity at the location of a specified entity instance. |
SpawnEntityAtLocation
|
void SpawnEntityAtLocation(Vector origin, Vector orientation)
|
Create an entity at a specified location and orientation, orientation is Euler angle in degrees (pitch, yaw, roll). |
SpawnEntityAtNamedEntityOrigin
|
void SpawnEntityAtNamedEntityOrigin(string targetname)
|
Create an entity at the location of a named entity. If multiple entities have the same name, only the one with the lowest entity index will be targeted. |
CPointTemplate
Extends CBaseEntity
Script handle class for point_template.
Hooks
table PreSpawnInstance(string entityClass, string entityName)
- If this is defined, it will be called right before the entity is created, and any keyvalues returned will be assigned to the entity.
function PreSpawnInstance( entityClass, entityName )
{
local keyvalues =
{
rendercolor = "0 255 0",
targetname = "mySpawnedEntity"
}
return keyvalues
}
void PostSpawn(table entities)
- Called after the entities are spawned. A table with the handles of the spawned entities indexed by name is passed to the function. Could use this to connect outputs or do whatever needs to be done after the entity was created.

function PostSpawn( entities )
{
foreach( targetname, handle in entities )
{
printl( targetname + ": " + handle )
}
}
Example
Spawned entities can be accessed synchronously in script by using an entity maker. The following generalised example creates a global SpawnMyEntity()
function which spawns and returns the templated entity. It can be modified to support multiple templated entities.
m_hSpawnedEntity <- null;
m_KeyValues <- null;
m_hSpawner <- Entities.CreateByClassname( "env_entity_maker" );
m_hSpawner.__KeyValueFromString( "EntityTemplate", self.GetName() );
function PreSpawnInstance( classname, targetname )
{
return m_KeyValues;
}
function PostSpawn( entities )
{
foreach ( targetname, entity in entities )
{
m_hSpawnedEntity = entity;
break;
}
}
::SpawnMyEntity <- function( keyvalues = null )
{
m_KeyValues = keyvalues;
m_hSpawner.SpawnEntity();
return m_hSpawnedEntity;
}.bindenv(this)
Spawn templated entities from any script.
local ent = SpawnMyEntity( {
rendercolor = Vector( RandomInt(0, 255), RandomInt(0, 255), RandomInt(0, 255) )
} )
printl( ent )
CSceneEntity
Extends CBaseEntity
Methods
Function | Signature | Description |
---|---|---|
AddBroadcastTeamTarget
|
void AddBroadcastTeamTarget(int index)
|
Adds a team (by index) to the broadcast list. |
EstimateLength
|
float EstimateLength()
|
Returns length of this scene in seconds. |
FindNamedEntity
|
handle FindNamedEntity(string reference)
|
given an entity reference, such as !target, get actual entity from scene object. |
IsPaused
|
bool IsPaused()
|
If this scene is currently paused. |
IsPlayingBack
|
bool IsPlayingBack()
|
If this scene is currently playing. |
LoadSceneFromString
|
bool LoadSceneFromString(string sceneName, string scene)
|
Given a dummy scene name and a vcd string, load the scene. |
RemoveBroadcastTeamTarget
|
void RemoveBroadcastTeamTarget(int index)
|
Removes a team (by index) from the broadcast list. |
CTriggerCamera
Extends CBaseEntity
Methods
Function | Signature | Description |
---|---|---|
GetFov
|
int GetFov()
|
Get cameras current Field Of View setting as integer. |
SetFov
|
void SetFov(int fov, float rate)
|
Set cameras current FOV in integer degrees and FOV change rate as float. |
Hooks
Function | Signature | Description |
---|---|---|
ScriptStartCameraShot
|
void ScriptStartCameraShot(string shotType, handle sceneEntity, handle actor1, handle actor2, float duration)
|
Called from SceneEntity in response to a CChoreoEvent::CAMERA sent from a VCD. [Todo] |
CFuncTrackTrain
Extends CBaseEntity
Methods
Function | Signature | Description |
---|---|---|
GetFuturePosition
|
Vector GetFuturePosition(float x, float speed)
|
Get a position on the track x seconds in the future. |
CHostage
Extends CBaseEntity
Methods
Function | Signature | Description |
---|---|---|
IsBeingCarried
|
bool IsBeingCarried()
|
Get whether the hostage is currently being carried or not. |
CGameCoopMissionManager
Extends CBaseEntity
Methods
Function | Signature | Description |
---|---|---|
GetWaveNumber
|
int GetWaveNumber()
|
Get the number of waves the players have completed. |
CEntities
Script instance: Entities
An interface to find and iterate over the script handles for the entities in play.
To iterate over a set of entities, pass null
to the previous argument in the appropriate method to start an iteration, or reference to a previously found entity to continue a search.
The following are two equivalent examples and iterate over all weapons on the map:
local ent = null;
while ( ent = Entities.FindByClassname(ent, "weapon_*") )
{
// ...
}
|
for (local ent; ent = Entities.FindByName(ent, "weapon_*"); )
{
// ...
}
|

- The variable name
ent
is arbitrary. - Indeed, we mean "=" and not "==" in the loop conditions! The loops end if
ent
becomesnull
, which happens when no matching entities have an entity index higher to the one in previous parameter. - Semicolons are optional, except in the header of the
for
statement. - The string parameters of the
FindBy...
functions support the wildcard star*
. In the above example,FindByClassname
only returns either a handle of an entity whose classname begins with "weapon_
" or it returnsnull
.
Methods
Function | Signature | Description |
---|---|---|
CreateByClassname
|
handle CreateByClassname(string classname)
|
Creates an entity by classname with the initial origin (0,0,0) . ![]() |
FindByClassname
|
handle FindByClassname(handle previous, string classname)
|
Find entities by the value of their classname keyvalue.
|
FindByClassnameNearest
|
handle FindByClassnameNearest(string class, Vector origin, float radius)
|
Find the entity by the value of its classname keyvalue nearest to the specified origin .
|
FindByClassnameWithin
|
handle FindByClassnameWithin(handle previous, string classname, Vector origin, float radius)
|
Find entities by the value of their classname keyvalue within a radius around an origin .
|
FindByModel
|
handle FindByModel(handle previous, string modelname)
|
Find entities by the value of their model keyvalue. ![]() |
FindByName
|
handle FindByName(handle previous, string targetname)
|
Find entities by the value of their targetname keyvalue.
|
FindByNameNearest
|
handle FindByNameNearest(string targetname, Vector origin, float radius)
|
Find entities by the value of their targetname keyvalue nearest to a point.
|
FindByNameWithin
|
handle FindByNameWithin(handle previous, string targetname, Vector origin, float radius)
|
Find entities by the value of their targetname keyvalue within a radius.
|
FindByTarget
|
handle FindByTarget(handle previous, string target)
|
Find entities by the value of their target keyvalue.
|
FindInSphere
|
handle FindInSphere(handle previous, Vector origin, float radius)
|
Find entities within a radius around an origin .
|
First
|
handle First()
|
Returns the first entity, typically worldspawn. Equivalent to Entities.Next(null)
|
Next
|
handle Next(handle previous)
|
At the given reference of a previously-found entity, returns the next one after it in the list. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
CPlayerVoiceListener

PlayerVoiceListener
instance is not.
Methods
Function | Signature | Description |
---|---|---|
GetPlayerSpeechDuration
|
float GetPlayerSpeechDuration(int playerIndex)
|
Returns the number of seconds the player has been continuously speaking. |
IsPlayerSpeaking
|
bool IsPlayerSpeaking(int playerIndex)
|
Returns whether the player specified is speaking. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
CScriptKeyValues
Script handle representation of a models $keyvalues block. Sub keys are instances of the same class.
Methods
Function | Signature | Description |
---|---|---|
constructor
| ||
FindKey
|
CScriptKeyValues FindKey(string key)
|
Find a sub key by the key name. |
GetFirstSubKey
|
CScriptKeyValues GetFirstSubKey()
|
Return the first sub key object. |
GetKeyBool
|
bool GetKeyBool(string key)
|
Return the key value as a bool. |
GetKeyFloat
|
float GetKeyFloat(string key)
|
Return the key value as a float. |
GetKeyInt
|
int GetKeyInt(string key)
|
Return the key value as an integer. |
GetKeyString
|
string GetKeyString(string key)
|
Return the key value as a string. |
GetNextKey
|
CScriptKeyValues GetNextKey()
|
Return the next neighbor key object to the one the method is called on. |
IsKeyEmpty
|
bool IsKeyEmpty(string key)
|
Returns true if the named key has no value. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid key. |
ReleaseKeyValues
|
void ReleaseKeyValues()
|
Releases the contents of the instance. |
CCallChainer
CCallChainer objects collect all functions with a matching prefix in a given scope, then inserts it all into the chains
table with the prefix removed. All collected unprefixed functions can then be called in a chain using the class's Call()
method, given the method's event argument matches the functions' name.
Whenever a CCallChainer object is created, a function named Dispatch
followed by its given prefix will also be created, which the class binds the environment of its Call()
method to.
Methods
Function | Signature | Description |
---|---|---|
constructor
|
CCallChainer(string functionPrefix, table scope = null)
|
Creates a CCallChainer object that'll collect functions that have a matching prefix in the given scope. |
PostScriptExecute
|
void PostScriptExecute()
|
Search for all non-native functions with matching prefixes, then push them into the chains table.
|
Call
|
bool Call(string event, any ...)
|
Find an unprefixed function name in the chains table and call it with the given arguments.
|
Members
Instance | Type | Description |
---|---|---|
chains
|
table
|
Contains names of unprefixed functions, each with an array of functions to call. |
prefix
|
string
|
Prefix that functions should have to be added into the chains table. Set by the constructor.
|
scope
|
table
|
If set, seek functions in this scope instead. Set by the constructor. |
CSimpleCallChainer
Intended to be simpler to use than CCallChainer, the class CSimpleCallChainer holds only a single chain of functions inside an array instead of multiple inside a table. As such, its Call()
method does not need a function's name.
This class is also used internally by these CBaseEntity hooks: Precache()
and OnPostSpawn()
.
Methods
Function | Signature | Description |
---|---|---|
constructor
|
CSimpleCallChainer(string functionPrefix, table scope = null, exactMatch = false)
|
Creates a CSimpleCallChainer object that'll collect functions that have a matching prefix in the given scope, unless it seek for an exact name match. |
PostScriptExecute
|
void PostScriptExecute()
|
Begin searching for all non-native functions with matching prefixes, then push them into the chain array.
|
Call
|
bool Call(any ...)
|
Call all functions inside the chain array with the given arguments.
|
Members
Instance | Type | Description |
---|---|---|
chain
|
array
|
All functions to be called by the Call() method.
|
exactMatch
|
bool
|
If set, names of non-native functions and prefix must be an exact match. Set by the constructor.
|
prefix
|
string
|
Prefix that functions should have to be added into the chain array. Set by the constructor.
|
scope
|
table
|
If set, seek functions in this scope instead. Set by the constructor. |
LateBinder
Late binding: allows a table to refer to parts of itself, it's children, it's owner, and then have the references fixed up after it's fully parsed.
// Usage:
lateBinder <- LateBinder();
lateBinder.Begin( this );
Test1 <-
{
Foo=1
}
Test2 <-
{
FooFoo = "I'm foo foo"
BarBar="@Test1.Foo"
SubTable = { boo=[bah, "@Test2.FooFoo", "@Test1.Foo"], booboo2={one=bah, two="@Test2.FooFoo", three="@Test1.Foo"} }
booboo=[bah, "@Test2.FooFoo", "@Test1.Foo"]
booboo2={one=bah, two="@Test2.FooFoo", three="@Test1.Foo"}
bah=wha
}
lateBinder.End();
delete lateBinder;
When End() is called, all of the unresolved symbols in the tables and arrays will be resolved, any left unresolved will become a string prepended with '~', which later code can deal with.
Methods
Function | Signature | Description |
---|---|---|
Begin
| ||
End
| ||
EstablishDelegation
| ||
HookRootMetamethod
| ||
Log
| ||
m_bindNamesStack
| ||
m_fixupSet
| ||
m_log
| ||
m_logIndent
| ||
m_targetTable
| ||
RemoveDelegation
| ||
Resolve
| ||
UnhookRootMetamethod
|
regexp
The built-in Squirrel class for regular expressions.
Methods
Function | Signature | Description |
---|---|---|
constructor
|
regexp()
|
|
capture
|
[table] capture(str, [start])
|
Returns an array of tables containing two indexes("begin" and "end")of the first match of the regular expression in the string str. An array entry is created for each captured sub expressions. If no match occurs returns null. The search starts from the index start of the string, if start is omitted the search starts from the beginning of the string. |
match
|
bool match(str)
|
Returns a true if the regular expression matches the string str, otherwise returns false. |
search
|
table search(str, [start])
|
Returns a table containing two indexes("begin" and "end") of the first match of the regular expression in the string str, otherwise if no match occurs returns null. The search starts from the index start of the string, if start is omitted the search starts from the beginning of the string. |
subexpcount
|
Vector
Squirrel equivalent of the C++ Vector class.
Three-dimensional vector.
Has overloaded operations for the following:
Vector * number
Vector + Vector
Vector - Vector
Methods
Function | Signature | Description |
---|---|---|
constructor
|
Vector(float x = 0, float y = 0, float z = 0)
|
Creates a new vector with the specified Cartesian coordiantes. |
Cross
|
float Cross(Vector factor)
|
The vector product of two vectors. Returns a vector orthogonal to the input vectors. |
Dot
|
float Dot(Vector factor)
|
The scalar product of two vectors. |
Length
|
float Length()
|
Length of the vector. |
LengthSqr
|
float LengthSqr()
|
Length of the vector squared. Cheaper than the above method. |
Length2D
|
float Length2D()
|
Returns the length of the vector on the x-y plane. |
Length2DSqr
|
float Length2DSqr()
|
Returns the square of the length of the vector on the x-y plane. Cheaper than the above method. |
Norm
|
float Norm()
|
Normalises the vector, returns the vector length. |
ToKVString
|
string ToKVString()
|
Returns a string without separations commas. |
Members
Instance | Type | Description |
---|---|---|
x
|
float
|
Cartesian X axis. |
y
|
float
|
Cartesian Y axis. |
z
|
float
|
Cartesian Z axis. |
Global functions
Printing and drawing
Function | Signature | Description |
---|---|---|
DebugDrawBox
|
void DebugDrawBox(vector origin, vector mins, vector maxs, int r, int g, int b, int alpha, float duration)
|
Draw a debug overlay box in the specified color for the specified duration with two corners being origin + mins and origin + maxs . The alpha is the fill rate (0-255). Set duration to 0 if drawn every tick.
|
DebugDrawBoxAngles
|
void DebugDrawBoxAngles(Vector origin, Vector mins, Vector maxs, Vector angles, int r, int g, int b, int alpha, float duration)
|
Draw a debug overlay box with angles in the specified color for the specified duration with two corners being origin + mins and origin + maxs + angles . The alpha is the fill rate (0-255). Set duration to 0 if drawn every tick.
|
DebugDrawLine
|
void DebugDrawLine(Vector start, Vector end, int r, int g, int b, bool noDepthTest, float duration)
|
Draw a debug line between the points start and end in the specified color for the specified duration. Set duration to 0 if drawn every tick.
|
Msg
|
void Msg(string message)
|
Equivalent to print
|
print
|
void print(string message)
|
Prints the given message to the developer console. |
printl
|
void printl(string message)
|
Prints the given message to the developer console with newline. Equivalent to print(message + "\n")
|
ScriptPrintMessageCenterAll
|
void ScriptPrintMessageCenterAll(string message)
|
Prints an alert message in the center of the screen to all players. |
ScriptPrintMessageCenterAllWithParams
|
void ScriptPrintMessageCenterAllWithParams(string message, string param1, string param2, string param3)
|
Prints an alert message in the center print method to all players. Needs to pass token/message. |
ScriptPrintMessageCenterTeam
|
void ScriptPrintMessageCenterTeam(int, string)
|
Prints an alert message in the center of the screen to the specified team.
![]() |
ScriptPrintMessageChatAll
|
void ScriptPrintMessageChatAll(string message)
|
Prints a message in chat to all players. |
ScriptPrintMessageChatTeam
|
void ScriptPrintMessageChatTeam(int team, string message)
|
Prints a message in chat to the specified team.
![]() |
ShowMessage
|
void ShowMessage(string)
|
Print a hud message on all clients. ![]() /scripts/titles.txt |
__DumpScope
|
void __DumpScope(int indentation, table scope)
|
Dumps the contents of scope. |
Training Course
Function | Signature | Description |
---|---|---|
ScriptGetBestTrainingCourseTime
|
int ScriptGetBestTrainingCourseTime()
|
Gets the player's best time for completing the timed course. |
ScriptGetPlayerCompletedTraining
|
bool ScriptGetPlayerCompletedTraining()
|
Returns true if the player has completed the initial portion of the training map. |
ScriptGetValveTrainingCourseTime
|
int ScriptGetValveTrainingCourseTime()
|
Gets Valve's best time for completing the timed course. |
ScriptHighlightAmmoCounter
|
void ScriptHighlightAmmoCounter()
|
Sends an event that is just used by the instructor system to show a hint highlighting the ammo counter. |
ScriptSetBestTrainingCourseTime
|
void ScriptSetBestTrainingCourseTime(int time)
|
Sets the player's best time for completing the timed course. |
ScriptSetMiniScoreHidden
|
void ScriptSetMiniScoreHidden(bool hide)
|
Toggles the visibility of the miniscoreboard hud element. |
ScriptSetPlayerCompletedTraining
|
void ScriptSetPlayerCompletedTraining(bool completed)
|
Sets whether the player has completed the initial portion of the training map. |
ScriptSetRadarHidden
|
void ScriptSetRadarHidden(bool hide)
|
Toggles the visibility of the radar hud element. |
ScriptShowExitDoorMsg
|
void ScriptShowExitDoorMsg()
|
Shows a message box in trainign when the player exits through the exit door |
ScriptShowFinishMsgBox
|
void ScriptShowFinishMsgBox()
|
Shows a message box to let players know what to do next after finishing the training course. |
ScriptTrainingGivePlayerAmmo
|
void ScriptTrainingGivePlayerAmmo()
|
Refills ammo to max for all weapons the player has (only works in training). |
Co-op Strike
Function | Signature | Description |
---|---|---|
ScriptCoopCollectBonusCoin
|
void ScriptCoopCollectBonusCoin()
|
Marks one of the bonus coins as collected. |
ScriptCoopGiveC4sToCTs
|
void ScriptCoopGiveC4sToCTs(int)
|
Will give the number of specified C4s to all alive CT players. |
ScriptCoopMissionGetMissionNumber
|
int ScriptCoopMissionGetMissionNumber()
|
Gets the mission number for the current map - maps can have multiple missions on them. |
ScriptCoopMissionRespawnDeadPlayers
|
void ScriptCoopMissionRespawnDeadPlayers()
|
Respawns players only. |
ScriptCoopMissionSetDeadPlayerRespawnEnabled
|
void ScriptCoopMissionSetDeadPlayerRespawnEnabled(bool)
|
Controls whether player respawns can happen. |
ScriptCoopMissionSetNextRespawnIn
|
void ScriptCoopMissionSetNextRespawnIn(float, bool)
|
Set the next respawn wave to happen in this many seconds. |
ScriptCoopMissionSpawnFirstEnemies
|
void ScriptCoopMissionSpawnFirstEnemies(int)
|
Spawns the first wave of enemies in coop. |
ScriptCoopMissionSpawnNextWave
|
void ScriptCoopMissionSpawnNextWave(int)
|
Tells the next wave of enemies to spawn in coop. Also respawns player. |
ScriptCoopResetRoundStartTime
|
void ScriptCoopResetRoundStartTime()
|
Resets the round time and starts the mission. |
ScriptCoopSetBotQuotaAndRefreshSpawns
|
void ScriptCoopSetBotQuotaAndRefreshSpawns(int)
|
Sets the bot quota considering the # of players connected and refreshes the spawns. |
ScriptCoopExtendRoundDurationTime
|
void ScriptCoopExtendRoundDurationTime(float)
|
Extends the round time after checkpoint during the mission. |
ScriptCoopToggleEntityOutlineHighlights
|
void ScriptCoopToggleEntityOutlineHighlights(bool)
|
Highlights all dropped weapons for players, or removes all highlights. |
ScriptMissionResetDangerZones
|
void ScriptMissionResetDangerZones()
|
Resets all danger zone entities. |
ScriptMissionCreateAndDetonateDangerZone
|
void ScriptMissionCreateAndDetonateDangerZone(Vector, Vector)
|
Creates and detonates a danger zone at the given location moving towards target location. |
Premier Mode
Function | Signature | Description |
---|---|---|
ScriptLobbyMapVetoFinished
|
void ScriptLobbyMapVetoFinished(string mapname, bool, bool, string)
|
Switch to the selected map after lobby map veto finished. |
Math
The built-in Squirrel math library.
Function | Signature | Description |
---|---|---|
abs
|
int abs(float x)
|
Returns the absolute value of x as an integer.
|
acos
|
float acos(float x)
|
Returns the arccosine of x .
|
asin
|
float asin(float x)
|
Returns the arcsine of x .
|
atan
|
float atan(float x)
|
Returns the arctangent of x .
|
atan2
|
float atan2(float x, float y)
|
Returns the arctangent of x/y .
|
ceil
|
float ceil(float x)
|
Returns a float value representing the smallest integer that is greater than or equal to x .
|
cos
|
float cos(float x)
|
Returns the cosine of x .
|
exp
|
float exp(float x)
|
Returns the exponential value (e^x ) of the float parameter x .
|
fabs
|
float fabs(float x)
|
Returns the absolute value of x as a float.
|
floor
|
float floor(float x)
|
Returns a float value representing the largest integer that is less than or equal to x .
|
log
|
float log(float x)
|
Returns the natural logarithm of x .
|
log10
|
float log10(float x)
|
Returns the logarithm base-10 of x .
|
pow
|
float pow(float x, float y)
|
Returns x raised to the power of y .
|
rand
|
int rand()
|
Returns a pseudorandom integer in the range 0 to RAND_MAX .
|
sin
|
float sin(float x)
|
Returns the sine of x .
|
sqrt
|
float sqrt(float x)
|
Returns the square root of x .
|
srand
|
void srand(float seed)
|
Sets the starting point for generating a series of pseudorandom integers. |
tan
|
float tan(float x)
|
Returns the tangent of x .
|
Other
Function | Signature | Description |
---|---|---|
Assert
|
void Assert(exp, string message = null)
|
Throws an exception if exp equates to false, optionally with message. |
CreateProp
|
handle CreateProp(string classname, Vector origin, string model, int animation)
|
Create a prop with the specified class and model. Both prop_physics, prop_dynamic as well as some other entity classes with models work. Does not precache the model. |
CreateSceneEntity
|
CSceneEntity CreateSceneEntity(string scene)
|
Create a scene entity to play the specified scene .vcd file. |
DispatchParticleEffect
|
void DispatchParticleEffect(string particle, Vector position, Vector orientation)
|
Dispatches a one-off particle system. See List of CS:GO Particles. Does not work if the particle is not precached.[How?] ![]() |
DoIncludeScript
|
bool DoIncludeScript(string filename, table scope)
|
Execute the script file "csgo/scripts/vscripts/" + filename in the scope of scope . The extension .nut can be omitted. Returns true if the script was found and executed, otherwise false.
|
IncludeScript
|
bool IncludeScript(string filename, table scope = null)
|
Execute the script file "csgo/scripts/vscripts/" + filename in the scope of scope , this by default. The extension .nut can be omitted. Returns true if the script was found and executed, otherwise false.
|
DoEntFire
|
void DoEntFire(string target, string action, string value, float delay, handle activator, handle caller)
|
Generate an entity I/O event. |
EntFire
|
void EntFire(string target, string action, string value = "", float delay = 0.0, handle activator = null)
|
Generate an entity I/O event. |
EntFireByHandle
|
void EntFireByHandle(handle target, string action, string value, float delay, handle activator, handle caller)
|
Generate an entity I/O event. |
FrameTime
|
float FrameTime()
|
Get the time spent on the server in the last frame. |
GetDeveloperLevel
|
int GetDeveloperLevel()
|
Gets the level of the developer mode. Equivalent to developer() .
|
GetMapName
|
string GetMapName()
|
Get the name of the map, e.g. "de_dust2" .
|
LoopSinglePlayerMaps
|
bool LoopSinglePlayerMaps()
|
Returns the boolean value of the ConVar loopsingleplayermaps , i.e. whether the single player maps are run in a continuous loop.
|
PrintHelp
|
void PrintHelp(string string = "*", bool exact = false)
|
Output help for script functions, optionally with a search string. |
RandomFloat
|
float RandomFloat(float min, float max)
|
Generate a random floating point number within a range, inclusive. |
RandomInt
|
int RandomInt(int min, int max)
|
Generate a random integer within a range, inclusive. |
RecordAchievementEvent
|
void RecordAchievementEvent(string, int)
|
Records achievement event or progress. |
RetrieveNativeSignature
|
void RetrieveNativeSignature(string nativeFunction)
|
[Todo] |
ScriptGetGameMode
|
int ScriptGetGameMode()
|
Gets the current game mode. |
ScriptGetGameType
|
int ScriptGetGameType()
|
Gets the current game type. |
ScriptGetRoundsPlayed
|
int ScriptGetRoundsPlayed()
|
Get the number of rounds that any team has won so far. ![]() |
ScriptIsLocalPlayerUsingController
|
bool ScriptIsLocalPlayerUsingController()
|
Returns whether the player is playing with a controller or not. |
ScriptIsWarmupPeriod
|
bool ScriptIsWarmupPeriod()
|
Is it warmup or not. |
SendToConsole
|
void SendToConsole(string command)
|
Send a string to the console as a client command. The command is executed through the local player or listen server host. If no player is found, this function will only print the developer message Cannot execute "<command>", no player in the console.
|
SendToConsoleServer
|
void SendToConsoleServer(string command)
|
Send a string that gets executed on the server as a ServerCommand using whitelistcmd. Commands or ConVars that are not whitelisted are not executed or changed. |
Time
|
float Time()
|
Get the current server time in seconds. |
TraceLine
|
float TraceLine(Vector start, Vector end, handle ignore)
|
Given 2 points and an entity to ignore, returns fraction along line that only hits world. |
TraceLinePlayersIncluded
|
float TraceLinePlayersIncluded(Vector start, Vector end, handle ignore)
|
Given 2 points and entity to ignore, returns fraction along line that hits world, models, players and NPCs. ![]() |
UniqueString
|
string UniqueString(string suffix = "")
|
Generate a string guaranteed to be unique across the life of the script VM, with an optional root string. Useful for adding data to tables when not sure what keys are already in use in that table. Equivalent to DoUniqueString(suffix) .
|
DoUniqueString
|
string DoUniqueString(string suffix)
|
Generate a string guaranteed to be unique across the life of the script VM, with an optional root string. Useful for adding data to tables when not sure what keys are already in use in that table. |
__ReplaceClosures
|
void __ReplaceClosures(function script, table scope)
|
Internal function called in script_reload_ server commands.
|
See also
- VScript
- VScript Fundamentals
- Listening to game events
Squirrel
VScript Examples
Left 4 Dead 2/Script Functions
List of Portal 2 Script Functions
List of Team Fortress 2 Script Functions
|