List of CS:GO Script Functions
I'll update this page whenever I learn something new, but for now it's still very lacking. Especially regarding descriptions.
About
This list contains most engine-related Squirrel classes, functions and variables available for VScript in
Counter-Strike: Global Offensive . Most 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 ""
The other classes, functions and variables not found in script_help
have simply been stumbled upon while messing around with VScript.
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()
|
[Todo] |
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. |
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 CBaseEntity::GetTeam()
|
Returns the team number of a player. |
GetUpVector
|
Vector CBaseEntity::GetUpVector()
|
Get the up vector of the entity. |
GetVelocity
|
Vector CBaseEntity::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 origin)
|
[Todo] |
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)
|
Todo: Does this actually change the team?
|
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
Function | Signature | Description |
---|---|---|
GetAttachmentAngles
|
Vector CBaseAnimating::GetAttachmentAngles(int)
|
Get the attachment id's angles as a p,y,r vector |
GetAttachmentOrigin
|
Vector CBaseAnimating::GetAttachmentOrigin(int)
|
Get the attachment id's origin vector |
IsSequenceFinished
|
bool CBaseAnimating::IsSequenceFinished()
|
Ask whether the main sequence is done playing |
LookupAttachment
|
int CBaseAnimating::LookupAttachment(string)
|
Get the named attachment id |
SetBodygroup
|
void CBaseAnimating::SetBodygroup(int, int)
|
Sets a bodygroup |
CBaseFlex extends CBaseAnimating
Function | Signature | Description |
---|---|---|
GetCurrentScene
|
handle CBaseFlex::GetCurrentScene()
|
Returns the instance of the oldest active scene entity (if any). |
GetSceneByIndex
|
handle CBaseFlex::GetSceneByIndex(int)
|
Returns the instance of the scene entity at the specified index. |
CBasePlayer extends CBaseAnimating
Function | Signature | Description |
---|---|---|
IsNoclipping
|
bool CBasePlayer::IsNoclipping()
|
Returns true if the player is in noclip mode. |
CBaseMultiplayerPlayer extends CBasePlayer
Function | Signature | Description |
---|
CEnvEntityMaker extends CBaseEntity
Function | Signature | Description |
---|---|---|
SpawnEntity
|
void CEnvEntityMaker::SpawnEntity()
|
Create an entity at the location of the maker |
SpawnEntityAtEntityOrigin
|
void CEnvEntityMaker::SpawnEntityAtEntityOrigin(handle)
|
Create an entity at the location of a specified entity instance |
SpawnEntityAtLocation
|
void CEnvEntityMaker::SpawnEntityAtLocation(Vector, Vector)
|
Create an entity at a specified location and orientaton, orientation is Euler angle in degrees (pitch, yaw, roll) |
SpawnEntityAtNamedEntityOrigin
|
void CEnvEntityMaker::SpawnEntityAtNamedEntityOrigin(string)
|
Create an entity at the location of a named entity |
CSceneEntity extends CBaseEntity
Function | Signature | Description |
---|---|---|
AddBroadcastTeamTarget
|
void CSceneEntity::AddBroadcastTeamTarget(int)
|
Adds a team (by index) to the broadcast list |
EstimateLength
|
float CSceneEntity::EstimateLength()
|
Returns length of this scene in seconds. |
FindNamedEntity
|
handle CSceneEntity::FindNamedEntity(string)
|
given an entity reference, such as !target, get actual entity from scene object |
IsPaused
|
bool CSceneEntity::IsPaused()
|
If this scene is currently paused. |
IsPlayingBack
|
bool CSceneEntity::IsPlayingBack()
|
If this scene is currently playing. |
LoadSceneFromString
|
bool CSceneEntity::LoadSceneFromString(string, string)
|
given a dummy scene name and a vcd string, load the scene |
RemoveBroadcastTeamTarget
|
void CSceneEntity::RemoveBroadcastTeamTarget(int)
|
Removes a team (by index) from the broadcast list |
CTriggerCamera extends CBaseEntity
Function | Signature | Description |
---|---|---|
GetFov
|
int CTriggerCamera::GetFov()
|
get camera's current fov setting as integer |
SetFov
|
void CTriggerCamera::SetFov(int, float)
|
set camera's current fov in integer degrees and fov change rate as float |
CCallChainer
Function | Signature | Description |
---|---|---|
Call
| ||
chains
| ||
constructor
| ||
PostScriptExecute
| ||
prefix
| ||
scope
|
CEntities
Function | Signature | Description |
---|---|---|
CreateByClassname
|
handle CEntities::CreateByClassname(string)
|
Creates an entity by classname |
FindByClassname
|
handle CEntities::FindByClassname(handle, string)
|
Find entities by class name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
FindByClassnameNearest
|
handle CEntities::FindByClassnameNearest(string, Vector, float)
|
Find entities by class name nearest to a point. |
FindByClassnameWithin
|
handle CEntities::FindByClassnameWithin(handle, string, Vector, float)
|
Find entities by class name within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
FindByModel
|
handle CEntities::FindByModel(handle, string)
|
Find entities by model name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
FindByName
|
handle CEntities::FindByName(handle, string)
|
Find entities by name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
FindByNameNearest
|
handle CEntities::FindByNameNearest(string, Vector, float)
|
Find entities by name nearest to a point. |
FindByNameWithin
|
handle CEntities::FindByNameWithin(handle, string, Vector, float)
|
Find entities by name within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
FindByTarget
|
handle CEntities::FindByTarget(handle, string)
|
Find entities by targetname. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
FindInSphere
|
handle CEntities::FindInSphere(handle, Vector, float)
|
Find entities within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
First
|
handle CEntities::First()
|
Begin an iteration over the list of entities |
IsValid
| ||
Next
|
handle CEntities::Next(handle)
|
Continue an iteration over the list of entities, providing reference to a previously found entity |
CPlayerVoiceListener
Function | Signature | Description |
---|---|---|
GetPlayerSpeechDuration
|
float CPlayerVoiceListener::GetPlayerSpeechDuration(int)
|
Returns the number of seconds the player has been continuously speaking. |
IsPlayerSpeaking
|
bool CPlayerVoiceListener::IsPlayerSpeaking(int)
|
Returns whether the player specified is speaking. |
IsValid
|
CScriptKeyValues
Function | Signature | Description |
---|---|---|
constructor
| ||
FindKey
|
handle CScriptKeyValues::FindKey(string)
|
Given a KeyValues object and a key name, find a KeyValues object associated with the key name |
GetFirstSubKey
|
handle CScriptKeyValues::GetFirstSubKey()
|
Given a KeyValues object, return the first sub key object |
GetKeyBool
|
bool CScriptKeyValues::GetKeyBool(string)
|
Given a KeyValues object and a key name, return associated bool value |
GetKeyFloat
|
float CScriptKeyValues::GetKeyFloat(string)
|
Given a KeyValues object and a key name, return associated float value |
GetKeyInt
|
int CScriptKeyValues::GetKeyInt(string)
|
Given a KeyValues object and a key name, return associated integer value |
GetKeyString
|
string CScriptKeyValues::GetKeyString(string)
|
Given a KeyValues object and a key name, return associated string value |
GetNextKey
|
handle CScriptKeyValues::GetNextKey()
|
Given a KeyValues object, return the next key object in a sub key group |
IsKeyEmpty
|
bool CScriptKeyValues::IsKeyEmpty(string)
|
Given a KeyValues object and a key name, return true if key name has no value |
IsValid
| ||
ReleaseKeyValues
|
void CScriptKeyValues::ReleaseKeyValues()
|
Given a root KeyValues object, release its contents |
CSimpleCallChainer
Function | Signature | Description |
---|---|---|
Call
| ||
chain
| ||
constructor
| ||
exactMatch
| ||
PostScriptExecute
| ||
prefix
| ||
scope
|
LateBinder
Function | Signature | Description |
---|---|---|
Begin
| ||
End
| ||
EstablishDelegation
| ||
HookRootMetamethod
| ||
Log
| ||
m_bindNamesStack
| ||
m_fixupSet
| ||
m_log
| ||
m_logIndent
| ||
m_targetTable
| ||
RemoveDelegation
| ||
Resolve
| ||
UnhookRootMetamethod
|
regexp
Function | Signature | Description |
---|---|---|
capture
| ||
constructor
| ||
match
| ||
search
| ||
subexpcount
|
Vector
Function | Signature | Description |
---|---|---|
constructor
| ||
Cross
| ||
Dot
| ||
Length
| ||
Length2D
| ||
Length2DSqr
| ||
LengthSqr
| ||
Norm
| ||
ToKVString
|
General functions
Function | Signature | Description |
---|---|---|
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
|
handle CreateSceneEntity(string scene)
|
Create a scene entity to play the specified scene .vcd file. |
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. |
DoIncludeScript
|
bool DoIncludeScript(string filename, table scope)
|
Execute a script with the script scope set to the specified table. |
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 'developer' |
GetMapName
|
string GetMapName()
|
Get the name of the map. |
LoopSinglePlayerMaps
|
bool LoopSinglePlayerMaps()
|
Run the single player maps in a continuous loop. |
Msg
|
void Msg(any)
|
Equivalent to print
|
PrintHelp
| ||
printl
|
void printl(any)
|
Prints the given argument to the standard out (console) just like print but also appends a newline. |
RandomFloat
|
float RandomFloat(float, float)
|
Generate a random floating point number within a range, inclusive |
RandomInt
|
int RandomInt(int, int)
|
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>
|
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. |
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. |
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. |
ScriptIsLocalPlayerUsingController
|
bool ScriptIsLocalPlayerUsingController()
|
Returns whether the player is playing with a controller or not. |
ScriptPrintMessageCenterAll
|
void ScriptPrintMessageCenterAll(string)
|
Prints an alert message in the center print method to all players. |
ScriptPrintMessageCenterTeam
|
void ScriptPrintMessageCenterTeam(int, string)
|
Prints an alert message in the center print method to the specified team. |
ScriptPrintMessageChatAll
|
void ScriptPrintMessageChatAll(string)
|
Prints a message in chat to all players. |
ScriptPrintMessageChatTeam
|
void ScriptPrintMessageChatTeam(int, string)
|
Prints a message in chat to the specified team. |
ScriptSetBestTrainingCourseTime
|
void ScriptSetBestTrainingCourseTime(int)
|
Sets the player's best time for completing the timed course. |
ScriptSetMiniScoreHidden
|
void ScriptSetMiniScoreHidden(bool)
|
Toggles the visibility of the miniscoreboard hud element. |
ScriptSetPlayerCompletedTraining
|
void ScriptSetPlayerCompletedTraining(bool)
|
Sets whether the player has completed the initial portion of the training map. |
ScriptSetRadarHidden
|
void ScriptSetRadarHidden(bool)
|
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). |
SendToConsole
|
void SendToConsole(string)
|
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 |
ShowMessage
|
void ShowMessage(string)
|
Print a hud message on all clients |
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. |
__DumpScope
| ||
__ReplaceClosures
|
Other
Pastebin with script that suggests it is run when Squirrel VM starts