List of CS:GO Script Functions: Difference between revisions
(Begun copying appropriate content from the L4D2 list.) |
(Reformatted functions and added a lot more info.) |
||
Line 1: | Line 1: | ||
{{toc-right}} | {{toc-right}} | ||
{{sq}} This list contains the engine-related Squirrel classes, functions and variables available for [[VScript]] in {{game link|Counter-Strike: Global Offensive}}. Some of it can be printed in the console by setting <code>developer</code> to at least 1, loading a map and executing <code>script_help</code>. Note that <code>developer</code> only needs to be non-zero during map-loading, so to dump <code>script_help</code> to a file do something like this: | |||
{{sq}} This list contains | |||
<code> | |||
developer 3 | developer 3 | ||
map de_nuke | map de_nuke | ||
Line 11: | Line 10: | ||
script_help | script_help | ||
con_logfile "" | con_logfile "" | ||
</code> | |||
Line 67: | Line 71: | ||
All script handles in-game are accessible from [[#CEntities|Entities]]. Entity Scripts can use <code>self</code> to access their own script handle. | All script handles in-game are accessible from [[#CEntities|Entities]]. Entity Scripts can use <code>self</code> to access their own script handle. | ||
==== Methods ==== | ==== Methods ==== | ||
Line 97: | Line 100: | ||
| <code>Destroy</code> | | <code>Destroy</code> | ||
| <code>void Destroy()</code> | | <code>void Destroy()</code> | ||
| | | Deletes the entity. | ||
|- | |- | ||
| <code>EmitSound</code> | | <code>EmitSound</code> | ||
Line 157: | Line 160: | ||
| <code>GetModelKeyValues</code> | | <code>GetModelKeyValues</code> | ||
| <code>Keyvalues GetModelKeyValues()</code> | | <code>Keyvalues GetModelKeyValues()</code> | ||
| Returns the [$keyvalues] block of the entitys model as a [[#Keyvalues]] object. | | Returns the [$keyvalues] block of the entitys model as a [[#Keyvalues]] object. Note that this is ''not'' the keyvalues of the entity itself. | ||
|- | |- | ||
| <code>GetModelName</code> | | <code>GetModelName</code> | ||
Line 200: | Line 203: | ||
|- | |- | ||
| <code>GetTeam</code> | | <code>GetTeam</code> | ||
| <code>int | | <code>int GetTeam()</code> | ||
| Returns the team number of a player. | | Returns the team number of a player. Terrorists = 2, CTs = 3. | ||
|- | |- | ||
| <code>GetUpVector</code> | | <code>GetUpVector</code> | ||
| <code>Vector | | <code>Vector GetUpVector()</code> | ||
| Get the up vector of the entity. | | Get the up vector of the entity. | ||
|- | |- | ||
| <code>GetVelocity</code> | | <code>GetVelocity</code> | ||
| <code>Vector | | <code>Vector GetVelocity()</code> | ||
| Returns a local velocity Vector. | | Returns a local velocity Vector. | ||
|- | |- | ||
Line 224: | Line 227: | ||
|- | |- | ||
| <code>SetAbsOrigin</code> | | <code>SetAbsOrigin</code> | ||
| <code>void SetAbsOrigin(Vector '' | | <code>void SetAbsOrigin(Vector ''position'')</code> | ||
| | | Same as SetOrigin(). | ||
|- | |- | ||
| <code>SetAngles</code> | | <code>SetAngles</code> | ||
Line 241: | Line 244: | ||
| <code>SetHealth</code> | | <code>SetHealth</code> | ||
| <code>void SetHealth(int ''newHealth'')</code> | | <code>void SetHealth(int ''newHealth'')</code> | ||
|Sets the current health. | | Sets the current health. | ||
|- | |- | ||
| <code>SetMaxHealth</code> | | <code>SetMaxHealth</code> | ||
Line 265: | Line 268: | ||
| <code>SetTeam</code> | | <code>SetTeam</code> | ||
| <code>void SetTeam(int ''teamNumber'')</code> | | <code>void SetTeam(int ''teamNumber'')</code> | ||
| | | Instantly switches a players team. Terrorists = 2, CTs = 3. | ||
|- | |- | ||
| <code>SetVelocity</code> | | <code>SetVelocity</code> | ||
Line 299: | Line 302: | ||
=== CBaseAnimating | === CBaseAnimating === | ||
Extends [[#CBaseEntity|CBaseEntity]] | |||
Script handle class for animating entities such as props. | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 306: | Line 314: | ||
|- | |- | ||
| <code>GetAttachmentAngles</code> | | <code>GetAttachmentAngles</code> | ||
| <code>Vector | | <code>Vector GetAttachmentAngles(int ''id'')</code> | ||
| Get the attachment | | Get the attachment ID's angles as a pitch, yaw, roll vector. | ||
|- | |- | ||
| <code>GetAttachmentOrigin</code> | | <code>GetAttachmentOrigin</code> | ||
| <code>Vector | | <code>Vector GetAttachmentOrigin(int 'id')</code> | ||
| Get the attachment | | Get the attachment ID's origin vector. | ||
|- | |- | ||
| <code>IsSequenceFinished</code> | | <code>IsSequenceFinished</code> | ||
| <code>bool | | <code>bool IsSequenceFinished()</code> | ||
| Ask whether the main sequence is done playing | | Ask whether the main sequence is done playing. | ||
|- | |- | ||
| <code>LookupAttachment</code> | | <code>LookupAttachment</code> | ||
| <code>int | | <code>int LookupAttachment(string ''attachmentName'')</code> | ||
| Get the named attachment | | Get the named attachment ID. | ||
|- | |- | ||
| <code>SetBodygroup</code> | | <code>SetBodygroup</code> | ||
| <code>void | | <code>void SetBodygroup(int ''groupIndex'', int ''value'')</code> | ||
| Sets | | Sets the models bodygroup value by index. {{todo|How do you find the index?}} | ||
|} | |} | ||
=== CBaseFlex | |||
=== CBaseFlex === | |||
Extends [[#CBaseAnimating|CBaseAnimating]] | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 333: | Line 345: | ||
|- | |- | ||
| <code>GetCurrentScene</code> | | <code>GetCurrentScene</code> | ||
| <code>handle | | <code>handle GetCurrentScene()</code> | ||
| Returns the instance of the oldest active scene entity (if any). | | Returns the instance of the oldest active scene entity (if any). | ||
|- | |- | ||
| <code>GetSceneByIndex</code> | | <code>GetSceneByIndex</code> | ||
| <code>handle | | <code>handle GetSceneByIndex(int ''index'')</code> | ||
| Returns the instance of the scene entity at the specified index. | | Returns the instance of the scene entity at the specified index. | ||
|} | |} | ||
=== CBasePlayer extends CBaseAnimating === | |||
=== CBasePlayer extends === | |||
Extends [[#CBaseAnimating|CBaseAnimating]] | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 348: | Line 364: | ||
|- | |- | ||
| <code>IsNoclipping</code> | | <code>IsNoclipping</code> | ||
| <code>bool | | <code>bool IsNoclipping()</code> | ||
| Returns true if the player is in noclip mode. | | Returns true if the player is in noclip mode. | ||
|} | |} | ||
=== CEnvEntityMaker | === CBaseMultiplayerPlayer === | ||
Extends [[#CBasePlayer|CBasePlayer]] | |||
Script handle class for the CS:GO players. No additional methods. | |||
=== CEnvEntityMaker === | |||
Extends [[#CBaseEntity|CBaseEntity]] | |||
Script handle class for [[env_entity_maker]]. | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 366: | Line 387: | ||
|- | |- | ||
| <code>SpawnEntity</code> | | <code>SpawnEntity</code> | ||
| <code>void | | <code>void SpawnEntity()</code> | ||
| Create an entity at the location of the maker | | Create an entity at the location of the maker | ||
|- | |- | ||
| <code>SpawnEntityAtEntityOrigin</code> | | <code>SpawnEntityAtEntityOrigin</code> | ||
| <code>void | | <code>void SpawnEntityAtEntityOrigin(CBaseEntity ''entity'')</code> | ||
| Create an entity at the location of a specified entity instance | | Create an entity at the location of a specified entity instance. | ||
|- | |- | ||
| <code>SpawnEntityAtLocation</code> | | <code>SpawnEntityAtLocation</code> | ||
| <code>void | | <code>void SpawnEntityAtLocation(Vector ''origin'', Vector ''orientation'')</code> | ||
| Create an entity at a specified location and | | Create an entity at a specified location and orientation, orientation is Euler angle in degrees (pitch, yaw, roll). | ||
|- | |- | ||
| <code>SpawnEntityAtNamedEntityOrigin</code> | | <code>SpawnEntityAtNamedEntityOrigin</code> | ||
| <code>void | | <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. | ||
|} | |} | ||
=== CSceneEntity | === CPointTemplate === | ||
Extends [[#CBaseEntity|CBaseEntity]] | |||
Script handle class for [[point_template]]. | |||
==== Hooks ==== | |||
;<code>table PreSpawnInstance(string ''entityClass'', string ''entityName'')</code> | |||
:If this is defined, it will be called right before the entity is created, and any KeyValues returned will be assigned to the entity. | |||
:This could be used to dynamically assign target names, colors, even models. Unfortunately, models don't work like one would think. Yes, it is possible to change that gas tank into a football model, will even keep the weapon_gascan class, but it won't behave like one. | |||
<source lang="cpp">function PreSpawnInstance( entityClass, entityName ) | |||
{ | |||
return | |||
{ | |||
rendercolor = "0 255 0" | |||
targetname = "mySpawnedEntity" | |||
}; | |||
} | |||
</source> | |||
;<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. | |||
<source lang="cpp">function PostSpawn( entities ) | |||
{ | |||
foreach( name, handle in entities ) | |||
{ | |||
printl( name + ": " + handle ); | |||
} | |||
} | |||
</source> | |||
=== CSceneEntity === | |||
Extends [[#CBaseEntity|CBaseEntity]] | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 390: | Line 451: | ||
|- | |- | ||
| <code>AddBroadcastTeamTarget</code> | | <code>AddBroadcastTeamTarget</code> | ||
| <code>void | | <code>void AddBroadcastTeamTarget(int ''index'')</code> | ||
| Adds a team (by index) to the broadcast list | | Adds a team (by index) to the broadcast list. | ||
|- | |- | ||
| <code>EstimateLength</code> | | <code>EstimateLength</code> | ||
| <code>float | | <code>float EstimateLength()</code> | ||
| Returns length of this scene in seconds. | | Returns length of this scene in seconds. | ||
|- | |- | ||
| <code>FindNamedEntity</code> | | <code>FindNamedEntity</code> | ||
| <code>handle | | <code>handle FindNamedEntity(string ''reference'')</code> | ||
| given an entity reference, such as !target, get actual entity from scene object | | given an entity reference, such as !target, get actual entity from scene object. | ||
|- | |- | ||
| <code>IsPaused</code> | | <code>IsPaused</code> | ||
| <code>bool | | <code>bool IsPaused()</code> | ||
| If this scene is currently paused. | | If this scene is currently paused. | ||
|- | |- | ||
| <code>IsPlayingBack</code> | | <code>IsPlayingBack</code> | ||
| <code>bool | | <code>bool IsPlayingBack()</code> | ||
| If this scene is currently playing. | | If this scene is currently playing. | ||
|- | |- | ||
| <code>LoadSceneFromString</code> | | <code>LoadSceneFromString</code> | ||
| <code>bool | | <code>bool LoadSceneFromString(string ''sceneName'', string ''scene'')</code> | ||
| | | Given a dummy scene name and a vcd string, load the scene. | ||
|- | |- | ||
| <code>RemoveBroadcastTeamTarget</code> | | <code>RemoveBroadcastTeamTarget</code> | ||
| <code>void | | <code>void RemoveBroadcastTeamTarget(int ''index'')</code> | ||
| Removes a team (by index) from the broadcast list | | Removes a team (by index) from the broadcast list. | ||
|} | |} | ||
=== CTriggerCamera | === CTriggerCamera === | ||
Extends [[#CBaseEntity|CBaseEntity]] | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 426: | Line 491: | ||
|- | |- | ||
| <code>GetFov</code> | | <code>GetFov</code> | ||
| <code>int | | <code>int GetFov()</code> | ||
| | | Get cameras current Field Of View setting as integer. | ||
|- | |- | ||
| <code>SetFov</code> | | <code>SetFov</code> | ||
| <code>void | | <code>void SetFov(int ''fov'', float ''rate'')</code> | ||
| | | Set cameras current FOV in integer degrees and FOV change rate as float. | ||
|} | |} | ||
=== CCallChainer === | |||
{{todo}} | |||
=== | ==== Methods ==== | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
! Signature | ! Signature | ||
! Description | ! Description | ||
|- | |||
| <code>constructor</code> | |||
| <code>{{todo}} constructor()</code> | |||
| | |||
|- | |||
| <code>PostScriptExecute</code> | |||
| <code>{{todo}} PostScriptExecute()</code> | |||
| | |||
|- | |- | ||
| <code>Call</code> | | <code>Call</code> | ||
| <code>{{todo}} Call()</code> | |||
| | |||
|} | |||
==== Members ==== | |||
{| class="standard-table" style="width: 100%;" | |||
! Instance | |||
! Type | |||
! Description | |||
|- | |- | ||
| <code>chains</code> | | <code>chains</code> | ||
| <code>null</code> | |||
| <code> | | | ||
| | |||
|- | |- | ||
| <code>prefix</code> | | <code>prefix</code> | ||
| <code>null</code> | |||
| | |||
|- | |- | ||
| <code>scope</code> | | <code>scope</code> | ||
| <code>null</code> | |||
| | |||
|} | |} | ||
=== CEntities === | |||
Game 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. | ||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 465: | Line 556: | ||
|- | |- | ||
| <code>CreateByClassname</code> | | <code>CreateByClassname</code> | ||
| <code>handle | | <code>handle CreateByClassname(string ''class'')</code> | ||
| Creates an entity by | | Creates an entity by class name. | ||
|- | |- | ||
| <code>FindByClassname</code> | | <code>FindByClassname</code> | ||
| <code>handle | | <code>handle FindByClassname(handle ''previous'', string ''class'')</code> | ||
| Find entities by class name. | | Find entities by class name. | ||
|- | |- | ||
| <code>FindByClassnameNearest</code> | | <code>FindByClassnameNearest</code> | ||
| <code>handle | | <code>handle FindByClassnameNearest(string ''class'', Vector ''origin'', float ''radius'')</code> | ||
| Find | | Find the entity with the given class name nearest to the specified point. | ||
|- | |- | ||
| <code>FindByClassnameWithin</code> | | <code>FindByClassnameWithin</code> | ||
| <code>handle | | <code>handle FindByClassnameWithin(handle ''previous'', string ''class'', Vector ''origin'', float ''radius'')</code> | ||
| Find entities by class name within a radius. | | Find entities by class name within a radius. | ||
|- | |- | ||
| <code>FindByModel</code> | | <code>FindByModel</code> | ||
| <code>handle | | <code>handle FindByModel(handle ''previous'', string ''filename'')</code> | ||
| Find entities by model name. | | Find entities by model name. | ||
|- | |- | ||
| <code>FindByName</code> | | <code>FindByName</code> | ||
| <code>handle | | <code>handle FindByName(handle ''previous'', string ''name'')</code> | ||
| Find entities by name. | | Find entities by name. | ||
|- | |- | ||
| <code>FindByNameNearest</code> | | <code>FindByNameNearest</code> | ||
| <code>handle | | <code>handle FindByNameNearest(string ''name'', Vector ''origin'', float ''radius'')</code> | ||
| Find entities by name nearest to a point. | | Find entities by name nearest to a point. | ||
|- | |- | ||
| <code>FindByNameWithin</code> | | <code>FindByNameWithin</code> | ||
| <code>handle | | <code>handle FindByNameWithin(handle ''previous'', string ''name'', Vector ''origin'', float ''radius'')</code> | ||
| Find entities by name within a radius. | | Find entities by name within a radius. | ||
|- | |- | ||
| <code>FindByTarget</code> | | <code>FindByTarget</code> | ||
| <code>handle | | <code>handle FindByTarget(handle ''previous'', string ''targetname'')</code> | ||
| Find entities by | | Find entities by its target. | ||
|- | |- | ||
| <code>FindInSphere</code> | | <code>FindInSphere</code> | ||
| <code>handle | | <code>handle FindInSphere(handle ''previous'', Vector ''origin'', float ''radius'')</code> | ||
| Find entities within a radius. | | Find entities within a radius. | ||
|- | |- | ||
| <code>First</code> | | <code>First</code> | ||
| <code>handle | | <code>handle First()</code> | ||
| Begin an iteration over the list of entities | | Begin an iteration over the list of entities. | ||
|- | |||
| <code>Next</code> | |||
| <code>handle Next(handle ''previous'')</code> | |||
| Continue an iteration over the list of entities, providing reference to a previously found entity. | |||
|- | |- | ||
| <code>IsValid</code> | | <code>IsValid</code> | ||
| <code>bool IsValid()</code> | |||
| Whether the handle belongs to a valid entity. | |||
| <code> | |||
| | |||
|} | |} | ||
=== CPlayerVoiceListener === | |||
{{todo|What is the int parameter to the methods.}} | |||
==== Methods ==== | |||
=== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 525: | Line 619: | ||
|- | |- | ||
| <code>GetPlayerSpeechDuration</code> | | <code>GetPlayerSpeechDuration</code> | ||
| <code>float | | <code>float GetPlayerSpeechDuration(int)</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 | | <code>bool IsPlayerSpeaking(int)</code> | ||
| Returns whether the player specified is speaking. | | Returns whether the player specified is speaking. | ||
|- | |- | ||
| <code>IsValid</code> | | <code>IsValid</code> | ||
| <code>bool IsValid()</code> | |||
| 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 ==== | |||
=== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 547: | Line 645: | ||
|- | |- | ||
| <code>FindKey</code> | | <code>FindKey</code> | ||
| <code> | | <code>CScriptKeyValues FindKey(string ''keyName'')</code> | ||
| | | Find a sub key by the key name. | ||
|- | |- | ||
| <code>GetFirstSubKey</code> | | <code>GetFirstSubKey</code> | ||
| <code> | | <code>CScriptKeyValues GetFirstSubKey()</code> | ||
| | | Return the first sub key object. | ||
|- | |- | ||
| <code>GetKeyBool</code> | | <code>GetKeyBool</code> | ||
| <code>bool | | <code>bool GetKeyBool(string ''keyName'')</code> | ||
| | | Return the key value as a bool. | ||
|- | |- | ||
| <code>GetKeyFloat</code> | | <code>GetKeyFloat</code> | ||
| <code>float | | <code>float GetKeyFloat(string ''keyName'')</code> | ||
| | | Return the key value as a float. | ||
|- | |- | ||
| <code>GetKeyInt</code> | | <code>GetKeyInt</code> | ||
| <code>int | | <code>int GetKeyInt(string ''keyName'')</code> | ||
| | | Return the key value as an integer. | ||
|- | |- | ||
| <code>GetKeyString</code> | | <code>GetKeyString</code> | ||
| <code>string | | <code>string GetKeyString(string ''keyName'')</code> | ||
| | | Return the key value as a string. | ||
|- | |- | ||
| <code>GetNextKey</code> | | <code>GetNextKey</code> | ||
| <code>handle | | <code>handle GetNextKey()</code> | ||
| | | Return the next neighbor key object to the one the method is called on. | ||
|- | |- | ||
| <code>IsKeyEmpty</code> | | <code>IsKeyEmpty</code> | ||
| <code>bool | | <code>bool IsKeyEmpty(string ''keyName'')</code> | ||
| | | Returns true if the named key has no value. | ||
|- | |- | ||
| <code>IsValid</code> | | <code>IsValid</code> | ||
| <code>bool IsValid()</code> | |||
| Whether the handle belongs to a valid entity. | |||
|- | |- | ||
| <code>ReleaseKeyValues</code> | | <code>ReleaseKeyValues</code> | ||
| <code>void | | <code>void ReleaseKeyValues()</code> | ||
| | | Releases the contents of the instance. | ||
|} | |} | ||
=== CSimpleCallChainer === | === CSimpleCallChainer === | ||
Seems to have the same members as [[#CCallChainer|CCallChainer]]. | |||
{{todo}} | |||
=== LateBinder === | |||
==== Methods ==== | |||
=== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 646: | Line 727: | ||
=== regexp === | |||
The built-in [http://squirrel-lang.org/doc/sqstdlib3.html#d0e2591 Squirrel class] for regular expressions. | |||
==== Methods ==== | |||
=== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
! Signature | ! Signature | ||
! Description | ! Description | ||
|- | |||
| <code>constructor</code> | |||
| <code>regexp()</code> | |||
| | |||
|- | |- | ||
| <code>capture</code> | | <code>capture</code> | ||
| <code> [table] capture(''str'', [''start''])</code> | |||
| <code> | | 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. | ||
|- | |- | ||
| <code>match</code> | | <code>match</code> | ||
| <code> bool match(''str'')</code> | |||
| Returns a true if the regular expression matches the string str, otherwise returns false. | |||
|- | |- | ||
| <code>search</code> | | <code>search</code> | ||
| <code>table search(''str'', [''start''])</code> | |||
| 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. | |||
|- | |- | ||
| <code>subexpcount</code> | | <code>subexpcount</code> | ||
| | |||
| | |||
|} | |} | ||
=== Vector === | |||
Squirrel equivalent of the C++ [[Vector]] class. | |||
Three-dimensional vector. | |||
=== | Has overloaded arithmetic operations with both Vectors and scalar values. | ||
{{note|[http://www.leeland.net/hochsuch.html Example] declaration and manipulation of Vector}} | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
Line 675: | Line 774: | ||
|- | |- | ||
| <code>constructor</code> | | <code>constructor</code> | ||
| <code>Vector(float ''x'', float ''y'', float ''z'')</code> | |||
| Creates a new vector with the specified Cartesian coordiantes. | |||
|- | |- | ||
| <code>Cross</code> | | <code>Cross</code> | ||
| <code>float Cross(Vector ''factor'')</code> | |||
| The 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> | |||
| The scalar product of two vectors. | |||
|- | |- | ||
| <code>Length</code> | | <code>Length</code> | ||
| <code>float Length()</code> | |||
| Magnitude of the vector. | |||
|- | |||
| <code>LengthSqr</code> | |||
| <code>float LengthSqr()</code> | |||
| The magnitude of the vector squared. Faster than the above method. | |||
|- | |- | ||
| <code>Length2D</code> | | <code>Length2D</code> | ||
| <code>float Length2D()</code> | |||
| Returns the magnitude of the vector on the x-y plane. | |||
|- | |- | ||
| <code>Length2DSqr</code> | | <code>Length2DSqr</code> | ||
| <code>float Length2DSqr()</code> | |||
| <code> | | Returns the square of the magnitude of the vector on the x-y plane. Faster than the above method. | ||
|- | |- | ||
| <code>Norm</code> | | <code>Norm</code> | ||
| <code>float Norm()</code> | |||
| Seems to also return the vector length. | |||
|- | |- | ||
| <code>ToKVString</code> | | <code>ToKVString</code> | ||
| <code>string ToKVString()</code> | |||
| Returns a string without separations commas. | |||
|} | |||
==== Members ==== | |||
{| class="standard-table" style="width: 100%;" | |||
! Instance | |||
! Type | |||
! Description | |||
|- | |||
| <code>x</code> | |||
| <code>float</code> | |||
| Cartesian X axis. | |||
|- | |||
| <code>y</code> | |||
| <code>float</code> | |||
| Cartesian Y axis. | |||
|- | |||
| <code>z</code> | |||
| <code>float</code> | |||
| Cartesian Z axis. | |||
|} | |} | ||
== Global functions == | |||
=== Printing and Drawing === | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
! Signature | ! Signature | ||
! Description | ! Description | ||
|- | |- | ||
| <code>DebugDrawBox</code> | | <code>DebugDrawBox</code> | ||
Line 717: | Line 846: | ||
| <code>void DebugDrawLine(Vector ''start'', Vector ''end'', int ''red'', int ''green'', int ''blue', bool ''zTest'', float ''time'')</code> | | <code>void DebugDrawLine(Vector ''start'', Vector ''end'', int ''red'', int ''green'', int ''blue', bool ''zTest'', float ''time'')</code> | ||
| Draw a debug line between two points. | | Draw a debug line between two points. | ||
|- | |||
| <code>Msg</code> | |||
| <code>void Msg(string ''message'')</code> | |||
| Equivalent to <code>print</code> | |||
|- | |||
| <code>print</code> | |||
| <code>void print(string ''message'')</code> | |||
| Prints the given message to the developer console. | |||
|- | |||
| <code>printl</code> | |||
| <code>void printl(string ''message'')</code> | |||
| Prints the given message to the developer console just like print but also appends a newline. | |||
|- | |||
| <code>ScriptPrintMessageCenterAll</code> | |||
| <code>void ScriptPrintMessageCenterAll(string ''message'')</code> | |||
| Prints an alert message in the center of the screen to all players. | |||
|- | |||
| <code>ScriptPrintMessageCenterTeam</code> | |||
| <code>void ScriptPrintMessageCenterTeam(int, string)</code> | |||
| Prints an alert message in the center of the screen to the specified team. | |||
|- | |||
| <code>ScriptPrintMessageChatAll</code> | |||
| <code>void ScriptPrintMessageChatAll(string ''message'')</code> | |||
| Prints a message in chat to all players. | |||
|- | |||
| <code>ScriptPrintMessageChatTeam</code> | |||
| <code>void ScriptPrintMessageChatTeam(int ''teamNumber'', string ''message'')</code> | |||
| Prints a message in chat to the specified team. | |||
|- | |||
| <code>ShowMessage</code> | |||
| <code>void ShowMessage(string)</code> | |||
| Print a hud message on all clients. {{Bug|Non-functional}} | |||
|- | |||
| <code>__DumpScope</code> | |||
| <code>void __DumpScope(int ''indentation'', handle ''scope'')</code> | |||
| Dumps contents of everything in the scope. | |||
|- | |||
|} | |||
=== Training Course related === | |||
{| class="standard-table" style="width: 100%;" | |||
! Function | |||
! Signature | |||
! Description | |||
|- | |||
| <code>ScriptGetBestTrainingCourseTime</code> | |||
| <code>int ScriptGetBestTrainingCourseTime()</code> | |||
| Gets the player's best time for completing the timed course. | |||
|- | |||
| <code>ScriptGetPlayerCompletedTraining</code> | |||
| <code>bool ScriptGetPlayerCompletedTraining()</code> | |||
| Returns true if the player has completed the initial portion of the training map. | |||
|- | |||
| <code>ScriptGetValveTrainingCourseTime</code> | |||
| <code>int ScriptGetValveTrainingCourseTime()</code> | |||
| Gets Valve's best time for completing the timed course. | |||
|- | |||
| <code>ScriptHighlightAmmoCounter</code> | |||
| <code>void ScriptHighlightAmmoCounter()</code> | |||
| Sends an event that is just used by the instructor system to show a hint highlighting the ammo counter. | |||
|- | |||
| <code>ScriptSetBestTrainingCourseTime</code> | |||
| <code>void ScriptSetBestTrainingCourseTime(int ''bestTime'')</code> | |||
| Sets the player's best time for completing the timed course. | |||
|- | |||
| <code>ScriptSetMiniScoreHidden</code> | |||
| <code>void ScriptSetMiniScoreHidden(bool ''scoreHidden'')</code> | |||
| Toggles the visibility of the miniscoreboard hud element. | |||
|- | |||
| <code>ScriptSetPlayerCompletedTraining</code> | |||
| <code>void ScriptSetPlayerCompletedTraining(bool ''trainingCompleted'')</code> | |||
| Sets whether the player has completed the initial portion of the training map. | |||
|- | |||
| <code>ScriptShowExitDoorMsg</code> | |||
| <code>void ScriptShowExitDoorMsg()</code> | |||
| Shows a message box in trainign when the player exits through the exit door | |||
|- | |||
| <code>ScriptShowFinishMsgBox</code> | |||
| <code>void ScriptShowFinishMsgBox()</code> | |||
| Shows a message box to let players know what to do next after finishing the training course. | |||
|- | |||
| <code>ScriptTrainingGivePlayerAmmo</code> | |||
| <code>void ScriptTrainingGivePlayerAmmo()</code> | |||
| Refills ammo to max for all weapons the player has (only works in training). | |||
|- | |||
|} | |||
=== Other === | |||
{| class="standard-table" style="width: 100%;" | |||
! Function | |||
! Signature | |||
! Description | |||
|- | |||
| <code>Assert</code> | |||
| <code>void Assert(bool ''value'', string ''optional message'')</code> | |||
| Test value and if not true, throws exception, optionally with message. | |||
|- | |||
| <code>CreateProp</code> | |||
| <code>handle CreateProp(string ''class'', 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. {{bug|Does not initialize the physics of the prop.}} | |||
|- | |||
| <code>CreateSceneEntity</code> | |||
| <code>CSceneEntity CreateSceneEntity(string ''scene'')</code> | |||
| Create a scene entity to play the specified scene .vcd file. | |||
|- | |- | ||
| <code>DoIncludeScript</code> | | <code>DoIncludeScript</code> | ||
| <code>bool DoIncludeScript(string ''filename'', table ''scope'')</code> | | <code>bool DoIncludeScript(string ''filename'', table ''scope'')</code> | ||
| Execute a script with the script scope set to the specified table. | | Execute a script with the script scope set to the specified table. | ||
|- | |||
| <code>DoEntFire</code> | |||
| <code>void DoEntFire(string ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code> | |||
| Generate an entity I/O event. The ''caller'' argument takes a script handle, so it can be used with ''target'' set to ''!self'' to fire inputs to entities without usable targetnames. | |||
|- | |- | ||
| <code>EntFire</code> | | <code>EntFire</code> | ||
Line 736: | Line 975: | ||
| <code>GetDeveloperLevel</code> | | <code>GetDeveloperLevel</code> | ||
| <code>int GetDeveloperLevel()</code> | | <code>int GetDeveloperLevel()</code> | ||
| Gets the level of 'developer' | | Gets the level of the ''developer'' mode. | ||
|- | |- | ||
| <code>GetMapName</code> | | <code>GetMapName</code> | ||
Line 745: | Line 984: | ||
| <code>bool LoopSinglePlayerMaps()</code> | | <code>bool LoopSinglePlayerMaps()</code> | ||
| Run the single player maps in a continuous loop. | | Run the single player maps in a continuous loop. | ||
|- | |- | ||
| <code>PrintHelp</code> | | <code>PrintHelp</code> | ||
| | |||
| {{todo}} | |||
|- | |- | ||
| <code> | | <code>RandomFloat</code> | ||
| <code> | | <code>float RandomFloat()</code> | ||
| | | Generate a random floating point number. | ||
|- | |- | ||
| <code>RandomFloat</code> | | <code>RandomFloat</code> | ||
| <code>float RandomFloat(float, float)</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, int)</code> | | <code>int RandomInt()</code> | ||
| Generate a random integer. | |||
|- | |||
| <code>RandomInt</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 | ||
|- | |- | ||
Line 772: | Line 1,013: | ||
| Name suggests it would print the calling format for a native function, but I can't get it to output anything other than <code><unnamed></code> | | Name suggests it would print the calling format for a native function, but I can't get it to output anything other than <code><unnamed></code> | ||
|- | |- | ||
| <code>ScriptGetGameMode</code> | | <code>ScriptGetGameMode</code> | ||
| <code>int ScriptGetGameMode()</code> | | <code>int ScriptGetGameMode()</code> | ||
Line 788: | Line 1,020: | ||
| <code>int ScriptGetGameType()</code> | | <code>int ScriptGetGameType()</code> | ||
| Retrieves the set game_type. See [[Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server|this list]] for a settings vs modes overview. | | Retrieves the set game_type. See [[Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server|this list]] for a settings vs modes overview. | ||
|- | |- | ||
| <code>ScriptIsLocalPlayerUsingController</code> | | <code>ScriptIsLocalPlayerUsingController</code> | ||
| <code>bool ScriptIsLocalPlayerUsingController()</code> | | <code>bool ScriptIsLocalPlayerUsingController()</code> | ||
| Returns whether the player is playing with a controller or not. | | Returns whether the player is playing with a controller or not. | ||
|- | |- | ||
| <code>ScriptSetRadarHidden</code> | | <code>ScriptSetRadarHidden</code> | ||
| <code>void ScriptSetRadarHidden(bool)</code> | | <code>void ScriptSetRadarHidden(bool ''hideRadar'')</code> | ||
| Toggles the visibility of the radar hud element. | | Toggles the visibility of the radar hud element. | ||
|- | |- | ||
| <code>SendToConsole</code> | | <code>SendToConsole</code> | ||
| <code>void SendToConsole(string)</code> | | <code>void SendToConsole(string ''command'')</code> | ||
| Send a string to the console as a command | | Send a string to the console as a command. | ||
|- | |- | ||
| <code>SendToConsoleServer</code> | | <code>SendToConsoleServer</code> | ||
| <code>void SendToConsoleServer(string)</code> | | <code>void SendToConsoleServer(string)</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 | ||
|- | |- | ||
| <code>Time</code> | | <code>Time</code> | ||
Line 870: | Line 1,048: | ||
| <code>function UniqueString(string)</code> | | <code>function UniqueString(string)</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> | ||
Line 878: | Line 1,054: | ||
= | == See Also == | ||
[http://pastebin.com/7LRsSjEZ Pastebin with script that suggests it is run when Squirrel VM starts] | * [http://pastebin.com/7LRsSjEZ Pastebin with script that suggests it is run when Squirrel VM starts] | ||
* [[List of L4D2 Script Functions]] | |||
* {{portal2}} [[List of Portal 2 Script Functions]] | |||
[[Category:Counter-Strike: Global Offensive]] | |||
[[Category:Scripting]] |
Revision as of 05:10, 27 September 2015
This list contains the engine-related Squirrel classes, functions and variables available for VScript in
Counter-Strike: Global Offensive . Some of it can be printed in the console by setting
developer
to at least 1, loading a map and executing script_help
. Note that developer
only needs to be non-zero during map-loading, so to dump script_help
to a file do something like this:
developer 3
map de_nuke
developer 0
con_logfile dump.txt
script_help
con_logfile ""
Variables
Instance | Type | Description |
---|---|---|
Entities
|
CEntities
|
Provides access to currently spawned entities. |
Constants
Instance | Type | Description |
---|---|---|
_charsize_
|
integer | |
_floatsize_
|
integer | |
_intsize_
|
integer | |
_version_
|
string | The version of squirrel. |
_versionnumber_
|
integer | The version of squirrel as an integer. |
RAND_MAX
|
integer |
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.
Methods
Function | Signature | Description |
---|---|---|
__KeyValueFromInt
|
void __KeyValueFromInt(string key, int value)
|
Sets a keyvalue from an integer, the keys available for all __KeyValue are from the DEFINE_KEYFIELD in baseentity.cpp (classname,rendermode, renderfx, etc.). |
__KeyValueFromString
|
void __KeyValueFromString(string key, string value)
|
Sets a keyvalue from a string, the keys available for all __KeyValue are from the DEFINE_KEYFIELD in baseentity.cpp (classname,rendermode, renderfx, etc.). |
__KeyValueFromVector
|
void __KeyValueFromVector(string key, Vector value)
|
Sets a keyvalue from a vector, the keys available for all __KeyValue are from the DEFINE_KEYFIELD in baseentity.cpp (classname,rendermode, renderfx, etc.). |
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()
|
Deletes the entity. |
EmitSound
|
void EmitSound(string soundScript)
|
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()
|
[Todo] |
GetAngles
|
Vector GetAngles()
|
Get the entity 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()
|
Returns the maximum extent of the entity bounding box as a local vector. |
GetBoundingMins
|
Vector GetBoundingMins()
|
Returns the maximum extent of the entity bounding box as a local vector. |
GetCenter
|
Vector GetCenter()
|
Returns a local vector of the bounding box center. |
GetClassname
|
string GetClassname()
|
Returns the entity class. This includes player .
|
GetForwardVector
|
Vector GetForwardVector()
|
Get the forward vector of the entity. |
GetHealth
|
int GetHealth()
|
Returns the current health. |
GetLeftVector
|
Vector GetLeftVector()
|
Get the left vector of the entity. |
GetMaxHealth
|
int GetMaxHealth()
|
Returns the maximum health. |
GetModelKeyValues
|
Keyvalues GetModelKeyValues()
|
Returns the [$keyvalues] block of the entitys model as a #Keyvalues object. Note that this is not the keyvalues of the entity itself. |
GetModelName
|
string GetModelName()
|
Returns the file name of the entitys model. |
GetMoveParent
|
CBaseEntity GetMoveParent()
|
If in hierarchy, retrieves the entitys parent. |
GetName
|
string GetName()
|
Returns the targetname of the entity. |
GetOrigin
|
Vector GetOrigin()
|
Returns the Entity position in the world. |
GetOwner
|
handle GetOwner()
|
Gets this entity's owner. |
GetPreTemplateName
|
string GetPreTemplateName()
|
Get the entity name stripped of template unique decoration. |
GetRootMoveParent
|
handle GetRootMoveParent()
|
If in hierarchy, walks up the hierarchy to find the root parent. |
GetScriptId
|
string GetScriptId()
|
Retrieve the unique identifier used to refer to the entity within the scripting system. |
GetScriptScope
|
handle GetScriptScope()
|
Retrieve the table storing the Entity Script data associated with this entity. |
GetSoundDuration
|
float GetSoundDuration(string soundName, string actorModelName = "")
|
Returns float duration of the sound. Takes soundname and optional actormodelname. |
GetTeam
|
int GetTeam()
|
Returns the team number of a player. Terrorists = 2, CTs = 3. |
GetUpVector
|
Vector GetUpVector()
|
Get the up vector of the entity. |
GetVelocity
|
Vector GetVelocity()
|
Returns a local velocity Vector. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
NextMovePeer
|
handle NextMovePeer()
|
|
PrecacheSoundScript
|
void PrecacheSoundScript(string soundScript)
|
Precache a sound for later playing. |
SetAbsOrigin
|
void SetAbsOrigin(Vector position)
|
Same as SetOrigin(). |
SetAngles
|
void SetAngles(float pitch, float yaw, float roll)
|
Set entity pitch, yaw, roll. Note that it doesn't take a Vector object. |
SetAngularVelocity
|
void SetAngularVelocity(float pitch, float yaw, float roll)
|
Set the local angular velocity - takes float pitch, yaw, roll velocities. |
SetForwardVector
|
void SetForwardVector(Vector forwardVector)
|
Set the orientation of the entity to have this forward vector. |
SetHealth
|
void SetHealth(int newHealth)
|
Sets the current health. |
SetMaxHealth
|
void SetMaxHealth(int maxHealth)
|
Sets a new maximum health. |
SetModel
|
void SetModel(string modelName)
|
Changes the model of the entity. Does not Precache the model. Todo: Check for side effects
|
SetOrigin
|
void SetOrigin(Vector position)
|
Moves the entity to this global position vector. |
SetOwner
|
void SetOwner(handle owner)
|
Sets this entity's owner. |
SetSize
|
void SetSize(Vector, Vector)
|
[Todo] |
SetTeam
|
void SetTeam(int teamNumber)
|
Instantly switches a players team. Terrorists = 2, CTs = 3. |
SetVelocity
|
void SetVelocity(Vector velocity)
|
Gives the entity a new local velocity. |
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. When the function is called, the activating and calling entities Script Handles are written to the receiving entitys Script Scope in the activator and caller variables. 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()
|
Called immediately after the entity spawns. This could be used to have an entity register itself with a master script, or adjusting the entity parameters in a programmatic way. |
Precache
|
void Precache()
|
Called after the script executes. Can be used to call precache functions for models and sounds on map load. |
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. Todo: How do you find the 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
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(CBaseEntity 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. |
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.
- This could be used to dynamically assign target names, colors, even models. Unfortunately, models don't work like one would think. Yes, it is possible to change that gas tank into a football model, will even keep the weapon_gascan class, but it won't behave like one.
function PreSpawnInstance( entityClass, entityName )
{
return
{
rendercolor = "0 255 0"
targetname = "mySpawnedEntity"
};
}
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( name, handle in entities )
{
printl( name + ": " + handle );
}
}
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. |
CCallChainer
[Todo]
Methods
Function | Signature | Description |
---|---|---|
constructor
|
[Todo] constructor()
|
|
PostScriptExecute
|
[Todo] PostScriptExecute()
|
|
Call
|
[Todo] Call()
|
Members
Instance | Type | Description |
---|---|---|
chains
|
null
|
|
prefix
|
null
|
|
scope
|
null
|
CEntities
Game 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.
Methods
Function | Signature | Description |
---|---|---|
CreateByClassname
|
handle CreateByClassname(string class)
|
Creates an entity by class name. |
FindByClassname
|
handle FindByClassname(handle previous, string class)
|
Find entities by class name. |
FindByClassnameNearest
|
handle FindByClassnameNearest(string class, Vector origin, float radius)
|
Find the entity with the given class name nearest to the specified point. |
FindByClassnameWithin
|
handle FindByClassnameWithin(handle previous, string class, Vector origin, float radius)
|
Find entities by class name within a radius. |
FindByModel
|
handle FindByModel(handle previous, string filename)
|
Find entities by model name. |
FindByName
|
handle FindByName(handle previous, string name)
|
Find entities by name. |
FindByNameNearest
|
handle FindByNameNearest(string name, Vector origin, float radius)
|
Find entities by name nearest to a point. |
FindByNameWithin
|
handle FindByNameWithin(handle previous, string name, Vector origin, float radius)
|
Find entities by name within a radius. |
FindByTarget
|
handle FindByTarget(handle previous, string targetname)
|
Find entities by its target. |
FindInSphere
|
handle FindInSphere(handle previous, Vector origin, float radius)
|
Find entities within a radius. |
First
|
handle First()
|
Begin an iteration over the list of entities. |
Next
|
handle Next(handle previous)
|
Continue an iteration over the list of entities, providing reference to a previously found entity. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
CPlayerVoiceListener
Methods
Function | Signature | Description |
---|---|---|
GetPlayerSpeechDuration
|
float GetPlayerSpeechDuration(int)
|
Returns the number of seconds the player has been continuously speaking. |
IsPlayerSpeaking
|
bool IsPlayerSpeaking(int)
|
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 keyName)
|
Find a sub key by the key name. |
GetFirstSubKey
|
CScriptKeyValues GetFirstSubKey()
|
Return the first sub key object. |
GetKeyBool
|
bool GetKeyBool(string keyName)
|
Return the key value as a bool. |
GetKeyFloat
|
float GetKeyFloat(string keyName)
|
Return the key value as a float. |
GetKeyInt
|
int GetKeyInt(string keyName)
|
Return the key value as an integer. |
GetKeyString
|
string GetKeyString(string keyName)
|
Return the key value as a string. |
GetNextKey
|
handle GetNextKey()
|
Return the next neighbor key object to the one the method is called on. |
IsKeyEmpty
|
bool IsKeyEmpty(string keyName)
|
Returns true if the named key has no value. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
ReleaseKeyValues
|
void ReleaseKeyValues()
|
Releases the contents of the instance. |
CSimpleCallChainer
Seems to have the same members as CCallChainer. [Todo]
LateBinder
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 arithmetic operations with both Vectors and scalar values.

Methods
Function | Signature | Description |
---|---|---|
constructor
|
Vector(float x, float y, float z)
|
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()
|
Magnitude of the vector. |
LengthSqr
|
float LengthSqr()
|
The magnitude of the vector squared. Faster than the above method. |
Length2D
|
float Length2D()
|
Returns the magnitude of the vector on the x-y plane. |
Length2DSqr
|
float Length2DSqr()
|
Returns the square of the magnitude of the vector on the x-y plane. Faster than the above method. |
Norm
|
float Norm()
|
Seems to also return 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 min, vector max, int r, int g, int b, int alpha, float duration)
|
Draw a debug overlay box. |
DebugDrawLine
|
void DebugDrawLine(Vector start, Vector end, int red, int green, int blue', bool zTest, float time)
|
Draw a debug line between two points. |
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 just like print but also appends a newline. |
ScriptPrintMessageCenterAll
|
void ScriptPrintMessageCenterAll(string message)
|
Prints an alert message in the center of the screen to all players. |
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 teamNumber, string message)
|
Prints a message in chat to the specified team. |
ShowMessage
|
void ShowMessage(string)
|
Print a hud message on all clients. ![]() |
__DumpScope
|
void __DumpScope(int indentation, handle scope)
|
Dumps contents of everything in the scope. |
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 bestTime)
|
Sets the player's best time for completing the timed course. |
ScriptSetMiniScoreHidden
|
void ScriptSetMiniScoreHidden(bool scoreHidden)
|
Toggles the visibility of the miniscoreboard hud element. |
ScriptSetPlayerCompletedTraining
|
void ScriptSetPlayerCompletedTraining(bool trainingCompleted)
|
Sets whether the player has completed the initial portion of the training map. |
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). |
Other
Function | Signature | Description |
---|---|---|
Assert
|
void Assert(bool value, string optional message)
|
Test value and if not true, throws exception, optionally with message. |
CreateProp
|
handle CreateProp(string class, 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. |
DoIncludeScript
|
bool DoIncludeScript(string filename, table scope)
|
Execute a script with the script scope set to the specified table. |
DoEntFire
|
void DoEntFire(string target, string action, string value, float delay, handle activator, handle caller)
|
Generate an entity I/O event. The caller argument takes a script handle, so it can be used with target set to !self to fire inputs to entities without usable targetnames. |
EntFire
|
function EntFire(string target, string action, string value, float delay = 0.0, handle activator = null)
|
Generate and entity I/O event. |
EntFireByHandle
|
void EntFireByHandle(handle target, string action, string 'value, float delay, handle activator, handle caller)
|
Generate and entity I/O event. The first parameter is an entity instance, so the handles of nameless or script generated entities can be passed easily. |
FrameTime
|
float FrameTime()
|
Get the time spent on the server in the last frame |
GetDeveloperLevel
|
int GetDeveloperLevel()
|
Gets the level of the developer mode. |
GetMapName
|
string GetMapName()
|
Get the name of the map. |
LoopSinglePlayerMaps
|
bool LoopSinglePlayerMaps()
|
Run the single player maps in a continuous loop. |
PrintHelp
|
[Todo] | |
RandomFloat
|
float RandomFloat()
|
Generate a random floating point number. |
RandomFloat
|
float RandomFloat(float min, float max)
|
Generate a random floating point number within a range, inclusive |
RandomInt
|
int RandomInt()
|
Generate a random integer. |
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 or func)
|
Name suggests it would print the calling format for a native function, but I can't get it to output anything other than <unnamed>
|
ScriptGetGameMode
|
int ScriptGetGameMode()
|
Retrieves the set game_mode. See this list for a settings vs modes overview. |
ScriptGetGameType
|
int ScriptGetGameType()
|
Retrieves the set game_type. See this list for a settings vs modes overview. |
ScriptIsLocalPlayerUsingController
|
bool ScriptIsLocalPlayerUsingController()
|
Returns whether the player is playing with a controller or not. |
ScriptSetRadarHidden
|
void ScriptSetRadarHidden(bool hideRadar)
|
Toggles the visibility of the radar hud element. |
SendToConsole
|
void SendToConsole(string command)
|
Send a string to the console as a command. |
SendToConsoleServer
|
void SendToConsoleServer(string)
|
Send a string that gets executed on the server as a ServerCommand |
Time
|
float Time()
|
Get the current server time |
TraceLine
|
float TraceLine(Vector, Vector, handle)
|
given 2 points & ent to ignore, return fraction along line that hits world or models |
UniqueString
|
function UniqueString(string)
|
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
|