List of CS:GO Script Functions

From Valve Developer Community
Jump to navigation Jump to search

I'll update this page whenever I learn something new, but for now it's still very lacking. Especially regarding descriptions.

About

Squirrel This list contains most engine-related Squirrel classes, functions and variables available for VScript in Counter-Strike: Global Offensive 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.




CBaseEntity

Function Signature Description
ConnectOutput void CBaseEntity::ConnectOutput(string output, string function) Adds an I/O connection that will call the named function when the specified output fires
Destroy void CBaseEntity::Destroy()
DisconnectOutput void CBaseEntity::DisconnectOutput(string output, string function) Removes a connected script function from an I/O event.
EmitSound void CBaseEntity::EmitSound(string) Plays a sound from this entity.
entindex int CBaseEntity::entindex()
EyePosition Vector CBaseEntity::EyePosition() Get vector to eye position - absolute coords
FirstMoveChild handle CBaseEntity::FirstMoveChild()
GetAngles Vector CBaseEntity::GetAngles() Get entity pitch, yaw, roll as a vector
GetAngularVelocity Vector CBaseEntity::GetAngularVelocity() Get the local angular velocity - returns a vector of pitch,yaw,roll
GetBoundingMaxs Vector CBaseEntity::GetBoundingMaxs() Get a vector containing max bounds, centered on object
GetBoundingMins Vector CBaseEntity::GetBoundingMins() Get a vector containing min bounds, centered on object
GetCenter Vector CBaseEntity::GetCenter() Get vector to center of object - absolute coords
GetClassname string CBaseEntity::GetClassname()
GetForwardVector Vector CBaseEntity::GetForwardVector() Get the forward vector of the entity
GetHealth int CBaseEntity::GetHealth()
GetLeftVector Vector CBaseEntity::GetLeftVector() Get the left vector of the entity
GetMaxHealth int CBaseEntity::GetMaxHealth()
GetModelKeyValues handle CBaseEntity::GetModelKeyValues() Get a KeyValue class instance on this entity's model
GetModelName string CBaseEntity::GetModelName() Returns the name of the model
GetMoveParent handle CBaseEntity::GetMoveParent() If in hierarchy, retrieves the entity's parent
GetName string CBaseEntity::GetName()
GetOrigin Vector CBaseEntity::GetOrigin()
GetOwner handle CBaseEntity::GetOwner() Gets this entity's owner
GetPreTemplateName string CBaseEntity::GetPreTemplateName() Get the entity name stripped of template unique decoration
GetRootMoveParent handle CBaseEntity::GetRootMoveParent() If in hierarchy, walks up the hierarchy to find the root parent
GetScriptId string CBaseEntity::GetScriptId() Retrieve the unique identifier used to refer to the entity within the scripting system
GetScriptScope handle CBaseEntity::GetScriptScope() Retrieve the script-side data associated with an entity
GetSoundDuration float CBaseEntity::GetSoundDuration(string, string) Returns float duration of the sound. Takes soundname and optional actormodelname.
GetTeam int CBaseEntity::GetTeam()
GetUpVector Vector CBaseEntity::GetUpVector() Get the up vector of the entity
GetVelocity Vector CBaseEntity::GetVelocity()
IsValid
NextMovePeer handle CBaseEntity::NextMovePeer()
PrecacheSoundScript void CBaseEntity::PrecacheSoundScript(string) Precache a sound for later playing.
SetAbsOrigin void CBaseEntity::SetAbsOrigin(Vector) SetAbsOrigin
SetAngles void CBaseEntity::SetAngles(float, float, float) Set entity pitch, yaw, roll
SetAngularVelocity void CBaseEntity::SetAngularVelocity(float, float, float) Set the local angular velocity - takes float pitch,yaw,roll velocities
SetForwardVector void CBaseEntity::SetForwardVector(Vector) Set the orientation of the entity to have this forward vector
SetHealth void CBaseEntity::SetHealth(int)
SetMaxHealth void CBaseEntity::SetMaxHealth(int)
SetModel void CBaseEntity::SetModel(string)
SetOrigin void CBaseEntity::SetOrigin(Vector)
SetOwner void CBaseEntity::SetOwner(handle) Sets this entity's owner
SetSize void CBaseEntity::SetSize(Vector, Vector)
SetTeam void CBaseEntity::SetTeam(int)
SetVelocity void CBaseEntity::SetVelocity(Vector)
ValidateScriptScope bool CBaseEntity::ValidateScriptScope() Ensure that an entity's script scope has been created
__KeyValueFromFloat
__KeyValueFromInt
__KeyValueFromString
__KeyValueFromVector


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, Vector, string, int) Create a physics prop
CreateSceneEntity handle CreateSceneEntity(string) Create a scene entity to play the specified scene.
DebugDrawBox void DebugDrawBox(Vector, Vector, Vector, int, int, int, int, float) Draw a debug overlay box
DebugDrawLine void DebugDrawLine(Vector, Vector, int, int, int, bool, float) Draw a debug overlay box
DoIncludeScript bool DoIncludeScript(string, handle) Execute a script (internal)
EntFire function EntFire(target, action, value, delay, activator) Generate and entity i/o event
EntFireByHandle void EntFireByHandle(handle, string, string, float, handle, handle) Generate and entity i/o event. First parameter is an entity instance.
FrameTime float FrameTime() Get the time spent on the server in the last frame
GetDeveloperLevel int GetDeveloperLevel() Gets the level of 'develoer'
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 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.
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

Variables

Variable Type Description
Entities CEntities List of all entities on the server.