Zh/List of CS:GO Script Functions: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
No edit summary
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified)
 
(57 intermediate revisions by 11 users not shown)
Line 1: Line 1:
{{otherlang2
{{LanguageBar|title = CSGO脚本函数列表}}
|en=List_of_Counter-Strike:_Global_Offensive_Script_Functions
{{Delisted|csgo}}
}}


{{toc-right}}
{{toc-right}}


{{sq}} 这份清单包含了{{game link|Counter-Strike: Global Offensive}}中的与引擎相关的可用于[[VScript]][[Squirrel]]类、函数以及 可用的变量。加载一个地图然后执行<code>script_help</code>,并且将<code>developer</code>的值设置为至少1, 可以把这份清单中的部分内容显示于控制台中。 值得一提的是,<code>developer</code> 只要不为0,且加载了任意的地图, 就可以把<code>script_help</code>指令所显示的内容转存到文件中。步骤如下(请一步一步地在控制台中键入每一行指令):
{{sq}} 这份清单包含了{{csgo|4}}中的与引擎相关的可用于{{L|VScript}}{{L|Squirrel}}类、函数以及可用的变量. 加载一个地图然后执行<code>script_help</code>, 并且将<code>developer</code>的级别设置为至少1, 可以把这份清单中的部分内容显示于控制台中.  值得一提的是, <code>developer</code>的级别只要不为0, 且加载了任意的地图, 就可以把<code>script_help</code>指令所显示的内容转存到文件中. 步骤如下(请一步一步地在控制台中键入每一行指令):


<code>
<code>
Line 11: Line 10:
  map de_nuke
  map de_nuke
  developer 0
  developer 0
  con_logfile dump.txt
  con_logfile dump.log
  script_help
  script_help
  con_logfile ""
  con_logfile ""
</code>
</code>
 
这条内容由[//steamcommunity.com/id/utagawashii/ Dazai Nerau]译自英文版页面. 欢迎任何人补充新内容或者修改其中的错误.
 
 
 
 
 
 
 
== 变量 ==
== 变量 ==


Line 66: Line 58:
|  
|  
|-
|-
|<code>PI</code>
|float
|3.14159
|}
|}


Line 76: Line 71:
所有游戏中的脚本句柄都可以从[[#CEntities|Entities]]中访问. 实体脚本可以通过 <code>self</code>来访问它们自身的脚本句柄.
所有游戏中的脚本句柄都可以从[[#CEntities|Entities]]中访问. 实体脚本可以通过 <code>self</code>来访问它们自身的脚本句柄.


==== Methods ====
==== 方法 ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! 函数
! 函数
Line 84: Line 79:
| <code>__KeyValueFromInt</code>
| <code>__KeyValueFromInt</code>
| <code>void __KeyValueFromInt(string ''key'', int ''value'')</code>
| <code>void __KeyValueFromInt(string ''key'', int ''value'')</code>
| 以整数设置实体的[[Keyvalue|键值(KeyValue)]]. 这个函数只修改数值而不执行实体处理KeyValue所需要的任何代码, 所以可能会有令人意想不到的副作用.
| 以整数设置实体的{{L|Keyvalue|键值(KeyValue)}}. 这个函数只修改数值而不执行实体处理KeyValue所需要的任何代码, 所以可能会有令人意想不到的副作用.
|-
|-
| <code>__KeyValueFromFloat</code>
| <code>__KeyValueFromFloat</code>
Line 124: Line 119:
| <code>FirstMoveChild</code>
| <code>FirstMoveChild</code>
| <code>handle FirstMoveChild()</code>
| <code>handle FirstMoveChild()</code>
|
| 如果在层级中则获取第一个移动的子对象.
|-
|-
| <code>GetAngles</code>
| <code>GetAngles</code>
| <code>Vector GetAngles()</code>
| <code>Vector GetAngles()</code>
| 以[[#Vector|向量]]形式获取实体的章动角(pitch)、进动角(yaw)和自转角(roll).
| 以[[#Vector|向量]]形式获取实体的欧拉角(pitch, yaw, roll).
|-
|-
| <code>GetAngularVelocity</code>
| <code>GetAngularVelocity</code>
Line 136: Line 131:
| <code>GetBoundingMaxs</code>
| <code>GetBoundingMaxs</code>
| <code>Vector GetBoundingMaxs()</code>
| <code>Vector GetBoundingMaxs()</code>
| 将实体边界框的最大范围以向量返回。
| 将实体边界框的最大范围以向量返回.
|-
| <code>GetBoundingMaxsOriented</code>
| <code>Vector GetBoundingMaxsOriented()</code>
| 将以对象为中心并考虑对象方向的实体边界框的最大范围以向量返回.
|-
|-
| <code>GetBoundingMins</code>
| <code>GetBoundingMins</code>
| <code>Vector GetBoundingMins()</code>
| <code>Vector GetBoundingMins()</code>
| 将实体边界框的最小范围以向量返回.
| 将实体边界框的最小范围以向量返回.
|-
| <code>GetBoundingMinsOriented</code>
| <code>Vector GetBoundingMinsOriented()</code>
| 将以对象为中心并考虑对象方向的实体边界框的最小范围以向量返回.
|-
|-
| <code>GetCenter</code>
| <code>GetCenter</code>
Line 192: Line 195:
| <code>GetPreTemplateName</code>
| <code>GetPreTemplateName</code>
| <code>string GetPreTemplateName()</code>
| <code>string GetPreTemplateName()</code>
| 获取去除独特模版装饰的实体名.
| Get the entity name stripped of template unique decoration.
|-
|-
| <code>GetRootMoveParent</code>
| <code>GetRootMoveParent</code>
Line 224: Line 227:
| <code>IsValid</code>
| <code>IsValid</code>
| <code>bool IsValid()</code>
| <code>bool IsValid()</code>
| 句柄是否属于有效的实体.
| 返回句柄是否属于有效的实体.
|-
|-
| <code>NextMovePeer</code>
| <code>NextMovePeer</code>
| <code>handle NextMovePeer()</code>
| <code>handle NextMovePeer()</code>
|
| 返回统一移动层级的下一个实体.
|-
|-
| <code>PrecacheModel</code>
| <code>PrecacheModel</code>
| <code>void PrecacheModel(string ''modelPath'')</code>
| <code>void PrecacheModel(string ''modelPath'')</code>
| 在地图加载完成后预缓存一个模型.
| 在地图加载完成后预缓存一个模型,资源占用大.
|-
|-
| <code>PrecacheScriptSound</code>
| <code>PrecacheScriptSound</code>
| <code>void PrecacheScriptSound(string ''soundName'')</code>
| <code>void PrecacheScriptSound(string ''soundName'')</code>
|
| 在地图加载完成后预缓存一个声音,资源占用大.
|-
|-
| <code>PrecacheSoundScript</code>
| <code>PrecacheSoundScript</code>
| <code>void PrecacheSoundScript(string ''soundScript'')</code>
| <code>void PrecacheSoundScript(string ''soundScript'')</code>
| 预缓存一个将会被播放的声音.
| 预缓存一个将会被播放的声音,资源占用大.
|-
|-
| <code>SetAbsOrigin</code>
| <code>SetAbsOrigin</code>
| <code>void SetAbsOrigin(Vector ''position'')</code>
| <code>void SetAbsOrigin(Vector ''position'')</code>
| 与SetOrigin()功能相同.
| 与SetOrigin()功能相同,设置实体的绝对位置.
|-
|-
| <code>SetAngles</code>
| <code>SetAngles</code>
Line 280: Line 283:
| <code>SetSize</code>
| <code>SetSize</code>
| <code>void SetSize(Vector, Vector)</code>
| <code>void SetSize(Vector, Vector)</code>
|
| 设置碰撞体积大小.
|-
|-
| <code>SetTeam</code>
| <code>SetTeam</code>
Line 289: Line 292:
| <code>void SetVelocity(Vector ''velocity'')</code>
| <code>void SetVelocity(Vector ''velocity'')</code>
| 设置实体的速度向量.
| 设置实体的速度向量.
|-
| <code>StopSound</code>
| <code>void StopSound(String ''soundname'')</code>
| 停止一个在实体上播放的声音.
|-
|-
| <code>ValidateScriptScope</code>
| <code>ValidateScriptScope</code>
| <code>bool ValidateScriptScope()</code>
| <code>bool ValidateScriptScope()</code>
| 实体的脚本数据是否已被创建.
| 返回实体的脚本域是否已被创建.
|-
|-
|}
|}
Line 310: Line 317:
| <code>OnPostSpawn</code>
| <code>OnPostSpawn</code>
| <code>void OnPostSpawn()</code>
| <code>void OnPostSpawn()</code>
| 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.
| 在实体生成时立即被调用. 这个函数可以用于让实体向主脚本注册自身,或以编程方式调整实体参数.
|-
|-
| <code>Precache</code>
| <code>Precache</code>
| <code>void Precache()</code>
| <code>void Precache()</code>
| Called after the script executes. Can be used to call precache functions for models and sounds on map load.
| 在脚本执行后调用. 可用于在地图加载时调用模型和声音的预缓存函数.
|}
|}


Line 320: Line 327:
Extends [[#CBaseEntity|CBaseEntity]]
Extends [[#CBaseEntity|CBaseEntity]]


Script handle class for animating entities such as props.
动画实体(如props)的脚本句柄类.


==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>GetAttachmentAngles</code>
| <code>GetAttachmentAngles</code>
| <code>Vector GetAttachmentAngles(int ''id'')</code>
| <code>Vector GetAttachmentAngles(int ''id'')</code>
| Get the attachment ID's angles as a pitch, yaw, roll vector.
| 以pitch, yaw, roll向量的形式获取附件ID的角度.
|-
|-
| <code>GetAttachmentOrigin</code>
| <code>GetAttachmentOrigin</code>
| <code>Vector GetAttachmentOrigin(int 'id')</code>
| <code>Vector GetAttachmentOrigin(int 'id')</code>
| Get the attachment ID's origin vector.
| 获取附件ID的位置向量.
|-
|-
| <code>IsSequenceFinished</code>
| <code>IsSequenceFinished</code>
| <code>bool IsSequenceFinished()</code>
| <code>bool IsSequenceFinished()</code>
| Ask whether the main sequence is done playing.
| 返回主序列是否已经播放完成.
|-
|-
| <code>LookupAttachment</code>
| <code>LookupAttachment</code>
| <code>int LookupAttachment(string ''attachmentName'')</code>
| <code>int LookupAttachment(string ''attachmentName'')</code>
| Get the named attachment ID.
| 获取指定名字的附件ID.
|-
|-
| <code>SetBodygroup</code>
| <code>SetBodygroup</code>
| <code>void SetBodygroup(int ''groupIndex'', int ''value'')</code>
| <code>void SetBodygroup(int ''groupIndex'', int ''value'')</code>
| Sets the models bodygroup value by index. {{todo|How do you find the index?}}
| 通过索引设置模型的bodygroup的值.BodyGroup是写死在qc内部的用来定义模型SubModel的信息。
|}
|}


=== CBaseFlex ===
=== CBaseFlex ===
Line 355: Line 361:
==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>GetCurrentScene</code>
| <code>GetCurrentScene</code>
| <code>handle GetCurrentScene()</code>
| <code>handle GetCurrentScene()</code>
| Returns the instance of the oldest active scene entity (if any).
| 返回最早的活动场景实体的实例 (备注:如果有的话).
|-
|-
| <code>GetSceneByIndex</code>
| <code>GetSceneByIndex</code>
| <code>handle GetSceneByIndex(int ''index'')</code>
| <code>handle GetSceneByIndex(int ''index'')</code>
| Returns the instance of the scene entity at the specified index.
| 返回指定索引的场景实体的实例.
|}
|}


=== CBasePlayer ===
=== CBasePlayer ===
Line 374: Line 379:
==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>IsNoclipping</code>
| <code>IsNoclipping</code>
| <code>bool IsNoclipping()</code>
| <code>bool IsNoclipping()</code>
| Returns true if the player is in noclip mode.
| 返回玩家是否处于noclip状态.
|}
|}


Line 386: Line 391:
Extends [[#CBasePlayer|CBasePlayer]]
Extends [[#CBasePlayer|CBasePlayer]]


Script handle class for the CS:GO players. No additional methods.
CSGO玩家的脚本句柄类,无附带方法。




Line 392: Line 397:
Extends [[#CBaseEntity|CBaseEntity]]
Extends [[#CBaseEntity|CBaseEntity]]


Script handle class for [[env_entity_maker]].  
{{L|env_entity_maker}}的脚本句柄类.  


==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>SpawnEntity</code>
| <code>SpawnEntity</code>
| <code>void SpawnEntity()</code>
| <code>void SpawnEntity()</code>
| Create an entity at the location of the maker
| 在制造器的位置上创建一个实体
|-
|-
| <code>SpawnEntityAtEntityOrigin</code>
| <code>SpawnEntityAtEntityOrigin</code>
| <code>void SpawnEntityAtEntityOrigin(CBaseEntity ''entity'')</code>
| <code>void SpawnEntityAtEntityOrigin(CBaseEntity ''entity'')</code>
| Create an entity at the location of a specified entity instance.
| 在指定实体实例的位置上创建一个实体.
|-
|-
| <code>SpawnEntityAtLocation</code>
| <code>SpawnEntityAtLocation</code>
| <code>void SpawnEntityAtLocation(Vector ''origin'', Vector ''orientation'')</code>
| <code>void SpawnEntityAtLocation(Vector ''origin'', Vector ''orientation'')</code>
| Create an entity at a specified location and orientation, orientation is Euler angle in degrees (pitch, yaw, roll).
| 在指定的位置和方向上创建一个实体,方向为以度为单位的欧拉角(pitch, yaw, roll).
|-
|-
| <code>SpawnEntityAtNamedEntityOrigin</code>
| <code>SpawnEntityAtNamedEntityOrigin</code>
| <code>void SpawnEntityAtNamedEntityOrigin(string ''targetName'')</code>
| <code>void SpawnEntityAtNamedEntityOrigin(string ''targetName'')</code>
| Create an entity at the location of a named entity.
| 在一个指定名字的实体的位置上创建一个实体。
|}
 
=== CFuncTrackTrain ===
Extends [[#CFuncTrackTrain|CFuncTrackTrain]]
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! 函数
! 签名
! 描述
|-
| <code>GetFuturePosition</code>
| <code>Vector GetFuturePosition(float, float)</code>
| 获取track在未来X秒的内的位置.
|}
|}
=== CGameCoopMissionManager ===
Extends [[#CGameCoopMissionManager|CGameCoopMissionManager]]
==== Methods ====
{| class="standard-table" style="width: 100%;"
! 函数
! 签名
! 描述
|-
| <code>GetWaveNumber</code>
| <code>int GetWaveNumber()</code>
| 获取玩家已经完成的合作模式波数.
|}
=== CHostage ===
Extends [[#CGameCoopMissionManager|CGameCoopMissionManager]]
==== Methods ====
{| class="standard-table" style="width: 100%;"
! 函数
! 签名
! 描述
|-
| <code>IsBeingCarried</code>
| <code>bool IsBeingCarried()</code>
| 返回人质当前是否正在被护送.
|}




Line 421: Line 469:
Extends [[#CBaseEntity|CBaseEntity]]
Extends [[#CBaseEntity|CBaseEntity]]


Script handle class for [[point_template]].
{{L|point_template}}的脚本句柄类.


==== Hooks ====
==== Hooks ====


;<code>table PreSpawnInstance(string ''entityClass'', string ''entityName'')</code>
;<code>table PreSpawnInstance(string ''entityClass'', string ''entityName'')</code>
:If this is defined, it will be called right before the entity is created, and any KeyValues returned will be assigned to the entity.
:如果定义了此Hook,它将在实体创建之前被调用,并且返回的任何KeyValues都将被分配给该实体。


<source lang="cpp">function PreSpawnInstance( entityClass, entityName )
<source lang="cpp">function PreSpawnInstance( entityClass, entityName )
Line 441: Line 489:


;<code>void PostSpawn(table ''entities'')</code>
;<code>void PostSpawn(table ''entities'')</code>
:Called after the entities are spawned. A table with the handles of the spawned entities indexed by name is passed to the function. Could use this to connect outputs or do whatever needs to be done after the entity was created.  
:在实体生成后调用. 具有按名称索引的已生成的实体句柄的表被传递给该函数. 可以使用它来关联输出或在创建实体后做任何你想做的事情.


<source lang="cpp">function PostSpawn( entities )
<source lang="cpp">function PostSpawn( entities )
Line 460: Line 508:


{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>AddBroadcastTeamTarget</code>
| <code>AddBroadcastTeamTarget</code>
| <code>void AddBroadcastTeamTarget(int ''index'')</code>
| <code>void AddBroadcastTeamTarget(int ''index'')</code>
| Adds a team (by index) to the broadcast list.
| 添加一个队伍(通过索引)到广播列表中.
|-
|-
| <code>EstimateLength</code>
| <code>EstimateLength</code>
| <code>float EstimateLength()</code>
| <code>float EstimateLength()</code>
| Returns length of this scene in seconds.
| 以秒为单位返回此场景的长度.
|-
|-
| <code>FindNamedEntity</code>
| <code>FindNamedEntity</code>
| <code>handle FindNamedEntity(string ''reference'')</code>
| <code>handle FindNamedEntity(string ''reference'')</code>
| given an entity reference, such as !target, get actual entity from scene object.
| 给定一个实体参照, 比如 !target, 以从场景对象中获取真正的实体.
|-
|-
| <code>IsPaused</code>
| <code>IsPaused</code>
| <code>bool IsPaused()</code>
| <code>bool IsPaused()</code>
| If this scene is currently paused.
| 返回这个场景是否暂停.
|-
|-
| <code>IsPlayingBack</code>
| <code>IsPlayingBack</code>
| <code>bool IsPlayingBack()</code>
| <code>bool IsPlayingBack()</code>
| If this scene is currently playing.
| 返回这个场景是否正在播放.
|-
|-
| <code>LoadSceneFromString</code>
| <code>LoadSceneFromString</code>
| <code>bool LoadSceneFromString(string ''sceneName'', string ''scene'')</code>
| <code>bool LoadSceneFromString(string ''sceneName'', string ''scene'')</code>
| Given a dummy scene name and a vcd string, load the scene.
| 给定一个虚拟的场景名和vcd的字符串, 以加载场景.
|-
|-
| <code>RemoveBroadcastTeamTarget</code>
| <code>RemoveBroadcastTeamTarget</code>
| <code>void RemoveBroadcastTeamTarget(int ''index'')</code>
| <code>void RemoveBroadcastTeamTarget(int ''index'')</code>
| Removes a team (by index) from the broadcast list.
| 从广播列表中删除一个队伍(通过索引).
|}
|}


Line 500: Line 548:
==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>GetFov</code>
| <code>GetFov</code>
| <code>int GetFov()</code>
| <code>int GetFov()</code>
| Get cameras current Field Of View setting as integer.
| 以整数获取当前相机的FOV设置.
|-
|-
| <code>SetFov</code>
| <code>SetFov</code>
| <code>void SetFov(int ''fov'', float ''rate'')</code>
| <code>void SetFov(int ''fov'', float ''rate'')</code>
| Set cameras current FOV in integer degrees and FOV change rate as float.
| 用整数的度数设置相机的FOV, 用浮点数设置FOV的变化率.
|}
|}


Line 516: Line 564:


;<code>void ScriptStartCameraShot(string ''shotType'', handle ''sceneEntity'', handle ''actor1'', handle ''actor2'', float ''duration'')</code>
;<code>void ScriptStartCameraShot(string ''shotType'', handle ''sceneEntity'', handle ''actor1'', handle ''actor2'', float ''duration'')</code>
: ''Called from SceneEntity in response to a CChoreoEvent::CAMERA sent from a VCD.'' {{todo}}
: ''由SceneEntity调用以响应由一个VCD发送来的CChoreoEvent::CAMERA.'' {{todo}}




Line 524: Line 572:
==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>constructor</code>
| <code>constructor</code>
Line 543: Line 591:
==== Members ====
==== Members ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Instance
! 实例
! Type
! 类型
! Description
! 描述
|-
|-
| <code>chains</code>
| <code>chains</code>
Line 562: Line 610:


=== CEntities ===
=== CEntities ===
Game Instance: <code>Entities</code>
游戏实例: <code>Entities</code>


An interface to find and iterate over the script handles for the entities in play.  
一个用于查找和遍历所有游戏中的实体的脚本句柄的接口.
要遍历一组实体, 请将<code>null</code>传递给适当方法中的前置参数以开始遍历, 或引用先前找到的实体以继续搜索.
以下两个示例都实现了遍历整个地图上的所有武器


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.
{| width=100%
|- style="vertical-align:top;"
|
<source lang=cpp>
local ent = null;
while ( ent = Entities.FindByClassname(ent, "weapon_*") )
{
  // ...
}
</source>
|
<source lang=cpp>
for (local ent; ent = Entities.FindByName(ent, "weapon_*"); )
{
  // ...
}
</source>
|}
 
{{Note |
* 变量名 <code>ent</code> 可根据自己情况定义.
* 在循环条件中使用 "{{=}}" 而不是"{{=}}{{=}}"!循环将在 <code>ent</code> 变为 <code>null</code>时停止.在循环体中ent是地图中的武器句柄不会为 <code>null</code>.
* <code>FindBy...</code> 函数的字符串参数支持通配符 <code>*</code>.在上面的示例中 <code>FindByClassname</code> 仅返回类名以 "<code>weapon_</code>" 开头的类或者 <code>null</code>.
}}


==== Methods ====
==== 方法 ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>CreateByClassname</code>
| <code>CreateByClassname</code>
| <code>handle CreateByClassname(string ''class'')</code>
| <code>handle CreateByClassname(string ''class'')</code>
| Creates an entity by class name.
| 通过种类名(class name)创建一个实体.
|-
|-
| <code>FindByClassname</code>
| <code>FindByClassname</code>
| <code>handle FindByClassname(handle ''previous'', string ''class'')</code>
| <code>handle FindByClassname(handle ''previous'', string ''class'')</code>
| Find entities by class name.  
| 通过种类名寻找一个实体.
|-
|-
| <code>FindByClassnameNearest</code>
| <code>FindByClassnameNearest</code>
| <code>handle FindByClassnameNearest(string ''class'', Vector ''origin'', float ''radius'')</code>
| <code>handle FindByClassnameNearest(string ''class'', Vector ''origin'', float ''radius'')</code>
| Find the entity with the given class name nearest to the specified point.
| 查找最接近指定点的指定种类名的实体.
|-
|-
| <code>FindByClassnameWithin</code>
| <code>FindByClassnameWithin</code>
| <code>handle FindByClassnameWithin(handle ''previous'', string ''class'', Vector ''origin'', float ''radius'')</code>
| <code>handle FindByClassnameWithin(handle ''previous'', string ''class'', Vector ''origin'', float ''radius'')</code>
| Find entities by class name within a radius.  
| 在一个范围内查找一个指定种类名的实体.  
|-
|-
| <code>FindByModel</code>
| <code>FindByModel</code>
| <code>handle FindByModel(handle ''previous'', string ''filename'')</code>
| <code>handle FindByModel(handle ''previous'', string ''filename'')</code>
| Find entities by model name.  
| 通过模型名查找一个实体.
|-
|-
| <code>FindByName</code>
| <code>FindByName</code>
| <code>handle FindByName(handle ''previous'', string ''name'')</code>
| <code>handle FindByName(handle ''previous'', string ''name'')</code>
| Find entities by name.  
| 通过targetname查找一个实体.
|-
|-
| <code>FindByNameNearest</code>
| <code>FindByNameNearest</code>
| <code>handle FindByNameNearest(string ''name'', Vector ''origin'', float ''radius'')</code>
| <code>handle FindByNameNearest(string ''name'', Vector ''origin'', float ''radius'')</code>
| Find entities by name nearest to a point.
| 查找最接近指定点的指定targetname的实体.
|-
|-
| <code>FindByNameWithin</code>
| <code>FindByNameWithin</code>
| <code>handle FindByNameWithin(handle ''previous'', string ''name'', Vector ''origin'', float ''radius'')</code>
| <code>handle FindByNameWithin(handle ''previous'', string ''name'', Vector ''origin'', float ''radius'')</code>
| Find entities by name within a radius.
| 在一个范围内查找一个指定targetname的实体.
|-
|-
| <code>FindByTarget</code>
| <code>FindByTarget</code>
| <code>handle FindByTarget(handle ''previous'', string ''targetname'')</code>
| <code>handle FindByTarget(handle ''previous'', string ''targetname'')</code>
| Find entities by its target.
| 通过实体自身的target查找一个实体.
|-
|-
| <code>FindInSphere</code>
| <code>FindInSphere</code>
| <code>handle FindInSphere(handle ''previous'', Vector ''origin'', float ''radius'')</code>
| <code>handle FindInSphere(handle ''previous'', Vector ''origin'', float ''radius'')</code>
| Find entities within a radius.
| 在一个范围内查找一个实体.
|-
|-
| <code>First</code>
| <code>First</code>
| <code>handle First()</code>
| <code>handle First()</code>
| Begin an iteration over the list of entities.
| 开始遍历的实体列表.
|-
|-
| <code>Next</code>
| <code>Next</code>
| <code>handle Next(handle ''previous'')</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>
| <code>bool IsValid()</code>
| Whether the handle belongs to a valid entity.
| 返回句柄是否属一个有效的实体.
|}
|}


=== CPlayerVoiceListener ===
=== CPlayerVoiceListener ===
{{todo|What is the int parameter to the methods.}}
{{Warning|此类无效! 此类虽然在 CS:GO 中实现,但所需的 <code>PlayerVoiceListener</code> 实例未实现.}}


==== Methods ====
==== 方法 ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>GetPlayerSpeechDuration</code>
| <code>GetPlayerSpeechDuration</code>
| <code>float GetPlayerSpeechDuration(int)</code>
| <code>float GetPlayerSpeechDuration(int)</code>
| Returns the number of seconds the player has been continuously speaking.
| 返回玩家持续说话的秒数.
|-
|-
| <code>IsPlayerSpeaking</code>
| <code>IsPlayerSpeaking</code>
| <code>bool IsPlayerSpeaking(int)</code>
| <code>bool IsPlayerSpeaking(int)</code>
| Returns whether the player specified is speaking.
| 返回指定玩家是否正在说话.
|-
|-
| <code>IsValid</code>
| <code>IsValid</code>
| <code>bool IsValid()</code>
| <code>bool IsValid()</code>
| Whether the handle belongs to a valid entity.
| 返回句柄是否属于一个有效的实体.
|}
|}


=== CScriptKeyValues ===
=== CScriptKeyValues ===
Script handle representation of a models [[$keyvalues]] block.
代表一个模型的{{L|$keyvalues}}块的脚本句柄.
Sub keys are instances of the same class.
子键是同一类的实例.


==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>constructor</code>
| <code>constructor</code>
Line 665: Line 736:
| <code>FindKey</code>
| <code>FindKey</code>
| <code>CScriptKeyValues FindKey(string ''keyName'')</code>
| <code>CScriptKeyValues FindKey(string ''keyName'')</code>
| Find a sub key by the key name.
| 通过键名找到一个子键.
|-
|-
| <code>GetFirstSubKey</code>
| <code>GetFirstSubKey</code>
| <code>CScriptKeyValues GetFirstSubKey()</code>
| <code>CScriptKeyValues GetFirstSubKey()</code>
| Return the first sub key object.
| 返回第一个子键对象.
|-
|-
| <code>GetKeyBool</code>
| <code>GetKeyBool</code>
| <code>bool GetKeyBool(string ''keyName'')</code>
| <code>bool GetKeyBool(string ''keyName'')</code>
| Return the key value as a bool.
| 以布尔形式返回一个键值.
|-
|-
| <code>GetKeyFloat</code>
| <code>GetKeyFloat</code>
| <code>float GetKeyFloat(string ''keyName'')</code>
| <code>float GetKeyFloat(string ''keyName'')</code>
| Return the key value as a float.
| 以浮点数返回一个键值.
|-
|-
| <code>GetKeyInt</code>
| <code>GetKeyInt</code>
| <code>int GetKeyInt(string ''keyName'')</code>
| <code>int GetKeyInt(string ''keyName'')</code>
| Return the key value as an integer.
| 以整数返回一个键值.
|-
|-
| <code>GetKeyString</code>
| <code>GetKeyString</code>
| <code>string GetKeyString(string ''keyName'')</code>
| <code>string GetKeyString(string ''keyName'')</code>
| Return the key value as a string.
| 以字符串形式返回一个键值.
|-
|-
| <code>GetNextKey</code>
| <code>GetNextKey</code>
| <code>handle GetNextKey()</code>
| <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 IsKeyEmpty(string ''keyName'')</code>
| <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>
| <code>bool IsValid()</code>
| Whether the handle belongs to a valid entity.
| 返回句柄是否属于一个有效的实体.
|-
|-
| <code>ReleaseKeyValues</code>
| <code>ReleaseKeyValues</code>
| <code>void ReleaseKeyValues()</code>
| <code>void ReleaseKeyValues()</code>
| Releases the contents of the instance.
| 释放实例的内容.
|}
|}




=== CSimpleCallChainer ===
=== CSimpleCallChainer ===
Seems to have the same members as [[#CCallChainer|CCallChainer]].
看上去似乎和 [[#CCallChainer|CCallChainer]] 有相同的Members.
{{todo}}
{{todo}}




=== LateBinder ===
== LateBinder ===
Late binding: allows a table to refer to parts of itself, it's children, it's owner, and then have the references fixed up after it's fully parsed.
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.
<source lang=cpp>
<source lang=cpp>
Line 737: Line 808:


When End() is called, all of the unresolved symbols in the tables and arrays will be resolved, any left unresolved will become a string prepended with '~', which later code can deal with.
When End() is called, all of the unresolved symbols in the tables and arrays will be resolved, any left unresolved will become a string prepended with '~', which later code can deal with.


==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>Begin</code>
| <code>Begin</code>
Line 772: Line 844:


=== regexp ===
=== regexp ===
The built-in [http://squirrel-lang.org/doc/sqstdlib3.html#d0e2591 Squirrel class] for regular expressions.
正则表达式的内置[http://squirrel-lang.org/doc/sqstdlib3.html#d0e2591 Squirrel ].


==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>constructor</code>
| <code>constructor</code>
Line 786: Line 858:
| <code>capture</code>
| <code>capture</code>
| <code> [table] capture(''str'', [''start''])</code>
| <code> [table] capture(''str'', [''start''])</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.  
| 返回在字符串str中的一个正则表达式的第一个匹配的包含2个索引("begin""end")的表的数组.为每个捕获的子表达式创建一个数组条目, 如果不匹配, 则返回null. 搜索从字符串的索引开始处开始, 如果忽略start, 则搜索从字符串的起始处开始.
|-
|-
| <code>match</code>
| <code>match</code>
| <code> bool match(''str'')</code>
| <code> bool match(''str'')</code>
| Returns a true if the regular expression matches the string str, otherwise returns false.  
| 如果正则表达式匹配字符串str, 则返回true, 否则返回false.
|-
|-
| <code>search</code>
| <code>search</code>
| <code>table search(''str'', [''start''])</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.  
| 返回包含字符串"str"中正则表达式第一个匹配的两个索引("begin""end")的表, 如果不匹配, 则返回null. 搜索从字符串的索引开始处开始, 如果忽略start, 则搜索从字符串的起始处开始.
|-
|-
| <code>subexpcount</code>
| <code>subexpcount</code>
Line 803: Line 875:


=== Vector ===
=== Vector ===
Squirrel equivalent of the C++ [[Vector]] class.
Squirrel的{{L|Vector}}类与C++相当.
 
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}}
{{Note|声明与操作向量的[http://www.leeland.net/hochsuch.html 例子] }}


==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>constructor</code>
| <code>constructor</code>
| <code>Vector(float ''x'', float ''y'', float ''z'')</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>
| <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>
| <code>float Dot(Vector ''factor'')</code>
| The scalar product of two vectors.  
| 两个向量的标量积.
|-
|-
| <code>Length</code>
| <code>Length</code>
| <code>float Length()</code>
| <code>float Length()</code>
| Magnitude of the vector.
| 向量的幅度.
|-
|-
| <code>LengthSqr</code>
| <code>LengthSqr</code>
| <code>float 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>
| <code>float Length2D()</code>
| Returns the magnitude of the vector on the x-y plane.
| 返回x-y平面上向量的幅度.
|-
|-
| <code>Length2DSqr</code>
| <code>Length2DSqr</code>
| <code>float Length2DSqr()</code>
| <code>float Length2DSqr()</code>
| Returns the square of the magnitude of the vector on the x-y plane. Faster than the above method.
| 返回x-y平面上向量幅度的平方. 比上一个方法更快.
|-
|-
| <code>Norm</code>
| <code>Norm</code>
| <code>float Norm()</code>
| <code>float Norm()</code>
| Will return the vector length as a float. This function will also NORMALIZE the vector, the X, Y, and Z values will each be set to a number between -1 and 1. You can then multiply these values by, for example, 3000 to use the vector to set the velocity of something in game.  
| 以浮点数返回向量的长度. 这个函数同时也会将向量'''标准化''', X, Y和Z值将被设置为-1和1之间的数字. 然后你可以将这些值乘以例如3000, 以使用该向量来设置游戏中某物的速度.  
|-
|-
| <code>ToKVString</code>
| <code>ToKVString</code>
| <code>string ToKVString()</code>
| <code>string ToKVString()</code>
| Returns a string without separations commas.
| 返回一个没有分隔符的字符串.
|}
|}


==== Members ====
==== Members ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Instance
! 实例
! Type
! 类型
! Description
! 描述
|-
|-
| <code>x</code>
| <code>x</code>
| <code>float</code>
| <code>float</code>
| Cartesian X axis.
| 笛卡尔x轴.
|-
|-
| <code>y</code>
| <code>y</code>
| <code>float</code>
| <code>float</code>
| Cartesian Y axis.
| 笛卡尔y轴.
|-
|-
| <code>z</code>
| <code>z</code>
| <code>float</code>
| <code>float</code>
| Cartesian Z axis.
| 笛卡尔z轴.
|}
|}


== 全局函数 ==


== Global functions ==
=== 打印与绘制 ===
 
=== Printing and Drawing ===


{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>DebugDrawBox</code>
| <code>DebugDrawBox</code>
| <code>void DebugDrawBox(vector ''origin'', vector ''min'', vector ''max'', int ''r'', int ''g'', int ''b'', int ''alpha'', float ''duration'')</code>
| <code>void DebugDrawBox(vector ''origin'', vector ''min'', vector ''max'', int ''r'', int ''g'', int ''b'', int ''alpha'', float ''duration'')</code>
| Draw a debug overlay box.
| 绘制一个调试覆盖框(debug overlay box).
|-
|-
| <code>DebugDrawLine</code>
| <code>DebugDrawLine</code>
| <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.
| 在两点间绘制一根调试线(debug line).
|-
|-
| <code>Msg</code>
| <code>Msg</code>
| <code>void Msg(string ''message'')</code>
| <code>void Msg(string ''message'')</code>
| Equivalent to <code>print</code>
| 相当于<code>print</code>
|-
|-
| <code>print</code>
| <code>print</code>
| <code>void print(string ''message'')</code>
| <code>void print(string ''message'')</code>
| Prints the given message to the developer console.
| 将给定的消息打印到开发人员控制台.
|-
|-
| <code>printl</code>
| <code>printl</code>
| <code>void printl(string ''message'')</code>
| <code>void printl(string ''message'')</code>
| Prints the given message to the developer console just like print but also appends a newline.
| 功能同上, 但会在最后附加一个换行符.
|-
| <code>ScriptPrintMessageCenterAllWithParams</code>
| <code>void ScriptPrintMessageCenterAllWithParams(string, string, string, string)</code>
| 在屏幕中央向所有玩家打印消息. 需要传递token/消息. 可以传递null给param1, param2, param3如果你只需要3个以内的参数.
|-
|-
| <code>ScriptPrintMessageCenterAll</code>
| <code>ScriptPrintMessageCenterAll</code>
| <code>void ScriptPrintMessageCenterAll(string ''message'')</code>
| <code>void ScriptPrintMessageCenterAll(string ''message'')</code>
| Prints an alert message in the center of the screen to all players.
| 在屏幕中央向所有玩家打印消息.
|-
|-
| <code>ScriptPrintMessageCenterTeam</code>
| <code>ScriptPrintMessageCenterTeam</code>
| <code>void ScriptPrintMessageCenterTeam(int, string)</code>
| <code>void ScriptPrintMessageCenterTeam(int, string)</code>
| Prints an alert message in the center of the screen to the specified team.
| 在屏幕中央向指定队伍的玩家打印消息.
|-
|-
| <code>ScriptPrintMessageChatAll</code>
| <code>ScriptPrintMessageChatAll</code>
| <code>void ScriptPrintMessageChatAll(string ''message'')</code>
| <code>void ScriptPrintMessageChatAll(string ''message'')</code>
| Prints a message in chat to all players.
| 在聊天框中向所有玩家打印消息.
|-
|-
| <code>ScriptPrintMessageChatTeam</code>
| <code>ScriptPrintMessageChatTeam</code>
| <code>void ScriptPrintMessageChatTeam(int ''teamNumber'', string ''message'')</code>
| <code>void ScriptPrintMessageChatTeam(int ''teamNumber'', string ''message'')</code>
| Prints a message in chat to the specified team.
| 在聊天框中向指定队伍的玩家打印消息.
|-
|-
| <code>ShowMessage</code>
| <code>ShowMessage</code>
| <code>void ShowMessage(string)</code>
| <code>void ShowMessage(string)</code>
| Print a hud message on all clients. {{Bug|Non-functional}}
| 打印一条HUD消息给所有玩家. {{Bug|不起作用}}
|-
|-
| <code>__DumpScope</code>
| <code>__DumpScope</code>
| <code>void __DumpScope(int ''indentation'', handle ''scope'')</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%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>ScriptGetBestTrainingCourseTime</code>
| <code>ScriptGetBestTrainingCourseTime</code>
| <code>int ScriptGetBestTrainingCourseTime()</code>
| <code>int ScriptGetBestTrainingCourseTime()</code>
| Gets the player's best time for completing the timed course.
| 获取玩家完成计时课程的最佳时间.
|-
|-
| <code>ScriptGetPlayerCompletedTraining</code>
| <code>ScriptGetPlayerCompletedTraining</code>
| <code>bool ScriptGetPlayerCompletedTraining()</code>
| <code>bool ScriptGetPlayerCompletedTraining()</code>
| Returns true if the player has completed the initial portion of the training map.
| 如果玩家已完成训练地图的初始部分, 则返回true.
|-
|-
| <code>ScriptGetValveTrainingCourseTime</code>
| <code>ScriptGetValveTrainingCourseTime</code>
| <code>int ScriptGetValveTrainingCourseTime()</code>
| <code>int ScriptGetValveTrainingCourseTime()</code>
| Gets Valve's best time for completing the timed course.
| 获得Valve完成计时课程的最佳时间。
|-
|-
| <code>ScriptHighlightAmmoCounter</code>
| <code>ScriptHighlightAmmoCounter</code>
| <code>void 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>ScriptSetBestTrainingCourseTime</code>
| <code>void ScriptSetBestTrainingCourseTime(int ''bestTime'')</code>
| <code>void ScriptSetBestTrainingCourseTime(int ''bestTime'')</code>
| Sets the player's best time for completing the timed course.
| 设置玩家完成计时课程的最佳时间.
|-
|-
| <code>ScriptSetMiniScoreHidden</code>
| <code>ScriptSetMiniScoreHidden</code>
| <code>void ScriptSetMiniScoreHidden(bool ''scoreHidden'')</code>
| <code>void ScriptSetMiniScoreHidden(bool ''scoreHidden'')</code>
| Toggles the visibility of the miniscoreboard hud element.
| 切换迷你记分牌HUD元素的可见性.
|-
|-
| <code>ScriptSetPlayerCompletedTraining</code>
| <code>ScriptSetPlayerCompletedTraining</code>
| <code>void ScriptSetPlayerCompletedTraining(bool ''trainingCompleted'')</code>
| <code>void ScriptSetPlayerCompletedTraining(bool ''trainingCompleted'')</code>
| Sets whether the player has completed the initial portion of the training map.
| 设置玩家是否完成了训练地图的初始部分.
|-
|-
| <code>ScriptShowExitDoorMsg</code>
| <code>ScriptShowExitDoorMsg</code>
| <code>void ScriptShowExitDoorMsg()</code>
| <code>void ScriptShowExitDoorMsg()</code>
| Shows a message box in trainign when the player exits through the exit door
| 当玩家通过出口门退出时, 在训练课程中显示一个消息框.
|-
|-
| <code>ScriptShowFinishMsgBox</code>
| <code>ScriptShowFinishMsgBox</code>
| <code>void 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>ScriptTrainingGivePlayerAmmo</code>
| <code>void ScriptTrainingGivePlayerAmmo()</code>
| <code>void ScriptTrainingGivePlayerAmmo()</code>
| Refills ammo to max for all weapons the player has (only works in training).
| 对玩家拥有的所有武器重新装填弹药(只在训练模式中有用).
|-
|-
|}
|}


 
=== 合作模式相关 ===
=== Co-op Strike related ===
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! 函数
! Signature
! 签名
! Description
! 描述
|-
|-
| <code>ScriptCoopCollectBonusCoin</code>
| <code>ScriptCoopCollectBonusCoin</code>
| <code>void ScriptCoopCollectBonusCoin()</code>
| <code>void ScriptCoopCollectBonusCoin()</code>
| Marks one of the bonus coins as collected.
| 将其中一个奖励币标记为已收集.
|-
|-
| <code>ScriptCoopGiveC4sToCTs</code>
| <code>ScriptCoopGiveC4sToCTs</code>
| <code>void ScriptCoopGiveC4sToCTs(int)</code>
| <code>void ScriptCoopGiveC4sToCTs(int)</code>
| Will give the number of specified C4s to all alive CT players.
| 将指定数量的C4给予所有活着的CT玩家.
|-
|-
| <code>ScriptCoopMissionGetMissionNumber</code>
| <code>ScriptCoopMissionGetMissionNumber</code>
| <code>int ScriptCoopMissionGetMissionNumber()</code>
| <code>int ScriptCoopMissionGetMissionNumber()</code>
| Gets the mission number for the current map - maps can have multiple missions on them.
| 获取当前地图的任务编号(备注:地图可以有多个任务).
|-
|-
| <code>ScriptCoopMissionRespawnDeadPlayers</code>
| <code>ScriptCoopMissionRespawnDeadPlayers</code>
| <code>void ScriptCoopMissionRespawnDeadPlayers()</code>
| <code>void ScriptCoopMissionRespawnDeadPlayers()</code>
| Respawns players only.
| 仅用于重生玩家.
|-
|-
| <code>ScriptCoopMissionSetNextRespawnIn</code>
| <code>ScriptCoopMissionSetNextRespawnIn</code>
| <code>void ScriptCoopMissionSetNextRespawnIn(float, bool)</code>
| <code>void ScriptCoopMissionSetNextRespawnIn(float, bool)</code>
| Set the next respawn wave to happen in this many seconds.
| 设置下一波重生的发生时间.
|-
|-
| <code>ScriptCoopMissionSpawnFirstEnemies</code>
| <code>ScriptCoopMissionSpawnFirstEnemies</code>
| <code>void ScriptCoopMissionSpawnFirstEnemies(int)</code>
| <code>void ScriptCoopMissionSpawnFirstEnemies(int)</code>
| Spawns the first wave of enemies in coop.
| 在合作模式中生成第一波敌人.
|-
|-
| <code>ScriptCoopMissionSpawnNextWave</code>
| <code>ScriptCoopMissionSpawnNextWave</code>
| <code>void ScriptCoopMissionSpawnNextWave(int)</code>
| <code>void ScriptCoopMissionSpawnNextWave(int)</code>
| Tells the next wave of enemies to spawn in coop. Also respawns player.
| 告知合作模式中下一波将要出生的敌人. 此函数也会复活玩家.
|-
|-
| <code>ScriptCoopResetRoundStartTime</code>
| <code>ScriptCoopResetRoundStartTime</code>
| <code>void ScriptCoopResetRoundStartTime()</code>
| <code>void ScriptCoopResetRoundStartTime()</code>
| Resets the round time and starts the mission.
| 重设回合时间并开始任务.
|-
|-
| <code>ScriptCoopSetBotQuotaAndRefreshSpawns</code>
| <code>ScriptCoopSetBotQuotaAndRefreshSpawns</code>
| <code>void ScriptCoopSetBotQuotaAndRefreshSpawns(int)</code>
| <code>void ScriptCoopSetBotQuotaAndRefreshSpawns(int)</code>
| Sets the bot quota considering the # of players connected and refreshes the spawns.
| 通过考量在线玩家数量来设置机器人数量并刷新复活.
|-
|-
|}
|}


=== 数学 ===
The built-in [http://www.squirrel-lang.org/mainsite/doc/sqstdlib2.html#d0e1519 Squirrel math library].


=== Other ===
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
! Signature
! Signature
! Description
! Description
|-
| <code>abs</code>
| <code> int abs(float ''x'')</code>
| 返回 <code>x</code> 的绝对值
|-
| <code>acos</code>
| <code> float acos(float ''x'')</code>
| 返回对 <code>x</code> 进行acos运算后的值
|-
| <code>asin</code>
| <code> float asin(float ''x'')</code>
| 返回对 <code>x</code> 进行asin运算后的值
|-
| <code>atan</code>
| <code> float atan(float ''x'')</code>
| 返回对 <code>x</code> 进行atan运算后的值
|-
| <code>atan2</code>
| <code> float atan2(float ''x'', float ''y'')</code>
| 返回对 <code>x</code> 进行atan2运算后的值
|-
| <code>ceil</code>
| <code> float ceil(float ''x'')</code>
| 返回对 <code>x</code> 进行向上取整的值,返回值是一个float型整数
|-
| <code>cos</code>
| <code> float cos(float ''x'')</code>
| 返回对 <code>x</code> 进行cos运算后的值
|-
| <code>exp</code>
| <code> float exp(float ''x'')</code>
| 返回 <code>x</code> 的指数运算后的值
|-
| <code>fabs</code>
| <code> float fabs(float ''x'')</code>
| 返回对 <code>x</code> 进行float转型后的值
|-
| <code>floor</code>
| <code> float floor(float ''x'')</code>
| 返回对 <code>x</code> 进行向下取整的值,返回值是一个float型整数
|-
| <code>log</code>
| <code> float log(float ''x'')</code>
| 返回 <code>x</code> 的log e对数
|-
| <code>log10</code>
| <code> float log10(float ''x'')</code>
| 返回 <code>x</code> 的log 10对数
|-
| <code>pow</code>
| <code> float pow(float ''x'', float ''y'')</code>
| 返回<code>x</code> 的 <code>y</code> 次方
|-
| <code>rand</code>
| <code> int rand()</code>
| 返回一个从 0 到 <code>RAND_MAX</code> 的随机int整数
|-
| <code>sin</code>
| <code> float sin(float ''x'')</code>
| 返回对 <code>x</code> 进行sin运算后的值
|-
| <code>sqrt</code>
| <code> float sqrt(float ''x'')</code>
| 返回对 <code>x</code> 进行开平方后的值
|-
| <code>srand</code>
| <code> void srand(float ''seed'')</code>
| 给上面那个随机数定义一个随机seed
|-
| <code>tan</code>
| <code> float tan(float ''x'')</code>
| 返回对 <code>x</code> 进行tan运算后的值
|}
=== 其他 ===
{| class="standard-table" style="width: 100%;"
! 函数
! 签名
! 描述
|-
|-
| <code>Assert</code>
| <code>Assert</code>
| <code>void Assert(bool ''value'', string ''optional message'')</code>
| <code>void Assert(bool ''value'', string ''optional message'')</code>
| Test value and if not true, throws exception, optionally with message.
| 检测布尔值, 如果不是true, 则显示异常, 可附带消息.
|-
|-
| <code>CreateProp</code>
| <code>CreateProp</code>
| <code>handle CreateProp(string ''class'', Vector ''origin'', string ''model'', int ''animation'')</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.}}
| 通过指定的类型和模型创建一个prop. 对于prop_physics, prop_dynamic 和其他一些带模型的实体都有效. 这个函数不会预缓存模型. {{bug|hidetested=1|不会初始化prop的物理属性.}}
|-
|-
| <code>CreateSceneEntity</code>
| <code>CreateSceneEntity</code>
| <code>CSceneEntity CreateSceneEntity(string ''scene'')</code>
| <code>CSceneEntity CreateSceneEntity(string ''scene'')</code>
| Create a scene entity to play the specified scene .vcd file.
| 创建一个场景实体来播放指定的场景.vcd文件.
|-
|-
| <code>DispatchParticleEffect</code>
| <code>DispatchParticleEffect</code>
| <code>void DispatchParticleEffect(string particleName, Vector, Vector)</code>
| <code>void DispatchParticleEffect(string particleName, Vector, Vector)</code>
| Dispatches a one-off particle system.
| 调用一个一次性粒子系统.
|-
|-
| <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.
| 执行脚本域设定为指定的表的脚本.
|-
|-
| <code>DoEntFire</code>
| <code>DoEntFire</code>
| <code>void DoEntFire(string ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code>
| <code>void DoEntFire(string ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code>
| Generate an entity I/O event. 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.
| 生成一个实体I/O事件. ''caller''参数为句柄, 所以 ''target'' 可以设置成''!self'' 来触发没有targetname的实体的输出.
|-
|-
| <code>EntFire</code>
| <code>EntFire</code>
| <code>function EntFire(string ''target'', string ''action'', string ''value'', float ''delay'' = 0.0, handle ''activator'' = null)</code>
| <code>function EntFire(string ''target'', string ''action'', string ''value'', float ''delay'' = 0.0, handle ''activator'' = null)</code>
| Generate an entity I/O event.
| 生成一个实体I/O事件.
|-
|-
| <code>EntFireByHandle</code>
| <code>EntFireByHandle</code>
| <code>void EntFireByHandle(handle ''target'', string ''action'', string 'value'', float ''delay'', handle ''activator'', handle ''caller'')</code>
| <code>void EntFireByHandle(handle ''target'', string ''action'', string 'value'', float ''delay'', handle ''activator'', handle ''caller'')</code>
| Generate an entity I/O event. The first parameter is an entity instance, so the handles of nameless or script generated entities can be passed easily.
| 生成一个实体I/O事件. 第一个参数是一个实体实例, 所以无名的或者由脚本创建的实体的句柄可以被轻松地传递.
|-
|-
| <code>FrameTime</code>
| <code>FrameTime</code>
| <code>float FrameTime()</code>
| <code>float FrameTime()</code>
| Get the time spent on the server in the last frame
| 获取上一帧在服务器上花费的时间.
|-
|-
| <code>GetDeveloperLevel</code>
| <code>GetDeveloperLevel</code>
| <code>int GetDeveloperLevel()</code>
| <code>int GetDeveloperLevel()</code>
| Gets the level of the ''developer'' mode.
| 获取''developer''模式的级别.
|-
|-
| <code>GetMapName</code>
| <code>GetMapName</code>
| <code>string GetMapName()</code>
| <code>string GetMapName()</code>
| Get the name of the map.
| 获取地图名.
|-
|-
| <code>LoopSinglePlayerMaps</code>
| <code>LoopSinglePlayerMaps</code>
| <code>bool LoopSinglePlayerMaps()</code>
| <code>bool LoopSinglePlayerMaps()</code>
| Run the single player maps in a continuous loop.
| 连续循环运行单人游戏地图.
|-
|-
| <code>PrintHelp</code>
| <code>PrintHelp</code>
Line 1,084: Line 1,236:
| <code>RandomFloat</code>
| <code>RandomFloat</code>
| <code>float RandomFloat()</code>
| <code>float RandomFloat()</code>
| Generate a random floating point number.
| 生成一个随机浮点数
|-
|-
| <code>RandomFloat</code>
| <code>RandomFloat</code>
| <code>float RandomFloat(float ''min'', float ''max'')</code>
| <code>float RandomFloat(float ''min'', float ''max'')</code>
| Generate a random floating point number within a range, inclusive
| 在一个给定范围内生成随机浮点数, 范围边界包括在内.
|-
|-
| <code>RandomInt</code>
| <code>RandomInt</code>
| <code>int RandomInt()</code>
| <code>int RandomInt()</code>
| Generate a random integer.
| 生成一个随机整数.
|-
|-
| <code>RandomInt</code>
| <code>RandomInt</code>
| <code>int RandomInt(int ''min'', int ''max'')</code>
| <code>int RandomInt(int ''min'', int ''max'')</code>
| Generate a random integer within a range, inclusive
| 在一个给定范围内生成随机整数, 范围边界包括在内.
|-
|-
| <code>RecordAchievementEvent</code>
| <code>RecordAchievementEvent</code>
| <code>void RecordAchievementEvent(string, int)</code>
| <code>void RecordAchievementEvent(string, int)</code>
| Records achievement event or progress
| 录制成就事件或者进程.
|-
|-
| <code>RetrieveNativeSignature</code>
| <code>RetrieveNativeSignature</code>
| <code>void RetrieveNativeSignature(string ''or'' func)</code>
| <code>void RetrieveNativeSignature(string ''or'' func)</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><unnamed></code>
|-
|-
| <code>ScriptGetGameMode</code>
| <code>ScriptGetGameMode</code>
| <code>int ScriptGetGameMode()</code>
| <code>int ScriptGetGameMode()</code>
| Retrieves the set game_mode. See [[Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server|this list]] for a settings vs modes overview.
| 返回game_mode的设置. 请查阅 [[Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server|CSGODS # 专用服务器]] 了解更多信息.
|-
|-
| <code>ScriptGetGameType</code>
| <code>ScriptGetGameType</code>
| <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.
| 返回game_type的设置. 请查阅 [[Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server|CSGODS # 专用服务器]] 了解更多信息.
|-
|-
| <code>ScriptGetRoundsPlayed</code>
| <code>ScriptGetRoundsPlayed</code>
| <code>int ScriptGetRoundsPlayed()</code>
| <code>int ScriptGetRoundsPlayed()</code>
| Get the number of rounds played so far.
| 获取从游戏开始迄今所经历的回合数.
|-
|-
| <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.
| 返回玩家是否在使用控制器玩游戏.
|-
|-
| <code>ScriptIsWarmupPeriod</code>
| <code>ScriptIsWarmupPeriod</code>
| <code>bool ScriptIsWarmupPeriod()</code>
| <code>bool ScriptIsWarmupPeriod()</code>
| Is it warmup or not.
| 返回是否是热身时间.
|-
|-
| <code>ScriptSetRadarHidden</code>
| <code>ScriptSetRadarHidden</code>
| <code>void ScriptSetRadarHidden(bool ''hideRadar'')</code>
| <code>void ScriptSetRadarHidden(bool ''hideRadar'')</code>
| Toggles the visibility of the radar hud element. Only works in training mode (game_type 2, game_mode 0) and only for the first person connected.
| 切换雷达HUD元素的可见性. 仅适用于训练模式(game_type 2且game_mode 0)并且仅适用于连接的第一个人.
|-
|-
| <code>SendToConsole</code>
| <code>SendToConsole</code>
| <code>void SendToConsole(string ''command'')</code>
| <code>void SendToConsole(string ''command'')</code>
| Send a string to the console as a command.
| 将一串命令以字符串形式发送到控制台.
|-
|-
| <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
| 发送一个字符串, 作为服务器命令在服务器上执行.
|-
|-
| <code>Time</code>
| <code>Time</code>
| <code>float Time()</code>
| <code>float Time()</code>
| Get the current server time
| 获取当前的服务器时间.
|-
|-
| <code>TraceLine</code>
| <code>TraceLine</code>
| <code>float TraceLine(Vector, Vector, handle)</code>
| <code>float TraceLine(Vector, Vector, handle)</code>
| given 2 points & ent to ignore, return fraction along line that hits world or models
| given 2 points & ent to ignore, return fraction along line that hits world or models.
|-
|-
| <code>UniqueString</code>
| <code>UniqueString</code>
| <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.
| 使用可选的根字符串生成一个字符串, 该字符串在脚本VM的整个生命周期中保证是唯一的. 当不知道该表中已经使用了哪些密钥时,对于向表中添加数据来说作用很大.
|-
|-
| <code>__ReplaceClosures</code>
| <code>__ReplaceClosures</code>
|}
|}


== 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]
 
* {{L|Left 4 Dead 2/Script Functions}}
* [[List of L4D2 Script Functions]]
* {{portal2}} {{L|List of Portal 2 Script Functions}}
* {{portal2}} [[List of Portal 2 Script Functions]]
{{ACategory|Counter-Strike: Global Offensive}}
 
{{ACategory|VScript}}
[[Category:Counter-Strike: Global Offensive]]
{{ACategory|Scripting}}
[[Category:Scripting]]

Latest revision as of 07:17, 20 May 2025

English (en)한국어 (ko)Русский (ru)中文 (zh)Translate (Translate)
Icon-delisted.png
本页记录了游戏, 反恐精英:全球攻势 反恐精英:全球攻势,,该游戏已无法通过数字方式购买或下载
在此介绍,供历史和技术参考

Squirrel 这份清单包含了反恐精英:全球攻势 反恐精英:全球攻势中的与引擎相关的可用于VScript(en)Squirrel(en)类、函数以及可用的变量. 加载一个地图然后执行script_help, 并且将developer的级别设置为至少1, 可以把这份清单中的部分内容显示于控制台中. 值得一提的是, developer的级别只要不为0, 且加载了任意的地图, 就可以把script_help指令所显示的内容转存到文件中. 步骤如下(请一步一步地在控制台中键入每一行指令):

developer 3
map de_nuke
developer 0
con_logfile dump.log
script_help
con_logfile ""

这条内容由Dazai Nerau译自英文版页面. 欢迎任何人补充新内容或者修改其中的错误.

变量

实例 类型 描述
Entities CEntities 提供一个对当前已生成的实体的访问方式.

常量

实例 类型 描述
_charsize_ integer
_floatsize_ integer
_intsize_ integer
_version_ string Squirrel的版本号.
_versionnumber_ integer Squirrel的版本号的整数形式.
RAND_MAX integer
PI float 3.14159

CBaseEntity

CBaseEntity是实体的脚本句柄类. 所有已生成的实体都有一个使用CBaseEntity或者其子类的的脚本句柄.

所有游戏中的脚本句柄都可以从Entities中访问. 实体脚本可以通过 self来访问它们自身的脚本句柄.

方法

函数 签名 描述
__KeyValueFromInt void __KeyValueFromInt(string key, int value) 以整数设置实体的键值(KeyValue)(en). 这个函数只修改数值而不执行实体处理KeyValue所需要的任何代码, 所以可能会有令人意想不到的副作用.
__KeyValueFromFloat void __KeyValueFromFloat(string key, float value) 以浮点数设置实体的KeyValue. 这个函数只修改数值而不执行实体处理KeyValue所需要的任何代码, 所以可能会有令人意想不到的副作用.
__KeyValueFromString void __KeyValueFromString(string key, string value) 以字符串设置实体的KeyValue. 这个函数只修改数值而不执行实体处理KeyValue所需要的任何代码, 所以可能会有令人意想不到的副作用.
__KeyValueFromVector void __KeyValueFromVector(string key, Vector value) 向量(Vector)设置实体的KeyValue. 这个函数只修改数值而不执行实体处理KeyValue所需要的任何代码, 所以可能会有令人意想不到的副作用.
ConnectOutput void ConnectOutput(string output, string function) 添加一个I/O关联, 当指定的输出触发时将调用指定的函数.
DisconnectOutput void DisconnectOutput(string output, string function) 从I/O事件中删除一个已关联的脚本函数.
Destroy void Destroy() 删除实体.
EmitSound void EmitSound(string soundScript) 在这个实体上播放声音.
entindex int entindex() 返回实体的索引.
EyePosition Vector EyePosition() 获取眼睛位置的向量(备注:绝对坐标).
FirstMoveChild handle FirstMoveChild() 如果在层级中则获取第一个移动的子对象.
GetAngles Vector GetAngles() 向量形式获取实体的欧拉角(pitch, yaw, roll).
GetAngularVelocity Vector GetAngularVelocity() 获取实体的角速度(备注:返回pitch、yaw、roll的向量).
GetBoundingMaxs Vector GetBoundingMaxs() 将实体边界框的最大范围以向量返回.
GetBoundingMaxsOriented Vector GetBoundingMaxsOriented() 将以对象为中心并考虑对象方向的实体边界框的最大范围以向量返回.
GetBoundingMins Vector GetBoundingMins() 将实体边界框的最小范围以向量返回.
GetBoundingMinsOriented Vector GetBoundingMinsOriented() 将以对象为中心并考虑对象方向的实体边界框的最小范围以向量返回.
GetCenter Vector GetCenter() 返回边界框中心位置的向量.
GetClassname string GetClassname() 返回实体的种类名. (备注:包含player).
GetForwardVector Vector GetForwardVector() 返回实体的前向量.
GetHealth int GetHealth() 返回实体当前的生命值.
GetLeftVector Vector GetLeftVector() 返回实体的左向量.
GetMaxHealth int GetMaxHealth() 返回实体的最大生命值.
GetModelKeyValues Keyvalues GetModelKeyValues() 返回实体模型的[$keyvalues]块作为一个#Keyvalues对象. 请注意, 这并非实体自身的keyvalues.
GetModelName string GetModelName() 返回实体模型的文件名.
GetMoveParent CBaseEntity GetMoveParent() 如果实体位于层次结构(hierarchy)中, 检索实体的父级(parent).
GetName string GetName() 返回实体的targetname.
GetOrigin Vector GetOrigin() 返回实体的位置.
GetOwner handle GetOwner() 获取实体的所有者(owner). (备注:似乎只有当需要在这个实体上使用SetOwner()时这个函数才有用, 可能也不尽然)
GetPreTemplateName string GetPreTemplateName() Get the entity name stripped of template unique decoration.
GetRootMoveParent handle GetRootMoveParent() 如果实体位于层次结构中,顺着层次结构检索实体的根父级.
GetScriptId string GetScriptId() 检索用于引用脚本系统中的实体的唯一标识符.
GetScriptScope handle GetScriptScope() 检索存储与此实体关联的实体脚本数据的表.
GetSoundDuration float GetSoundDuration(string soundName, string actorModelName = "") 以浮点数返回声音的持续时间. (备注:采用"soundName"和可选的"actorModelName"作为搜索参数)
GetTeam int GetTeam() 返回玩家的队伍. (备注:观察者 = 1, 恐怖分子 = 2, 反恐精英 = 3).
GetUpVector Vector GetUpVector() 获取实体的顶向量.
GetVelocity Vector GetVelocity() 返回实体的速度向量.
IsValid bool IsValid() 返回句柄是否属于有效的实体.
NextMovePeer handle NextMovePeer() 返回统一移动层级的下一个实体.
PrecacheModel void PrecacheModel(string modelPath) 在地图加载完成后预缓存一个模型,资源占用大.
PrecacheScriptSound void PrecacheScriptSound(string soundName) 在地图加载完成后预缓存一个声音,资源占用大.
PrecacheSoundScript void PrecacheSoundScript(string soundScript) 预缓存一个将会被播放的声音,资源占用大.
SetAbsOrigin void SetAbsOrigin(Vector position) 与SetOrigin()功能相同,设置实体的绝对位置.
SetAngles void SetAngles(float pitch, float yaw, float roll) 设置实体的pitch, yaw, roll. 请注意, 这里并不使用向量.
SetAngularVelocity void SetAngularVelocity(float pitch, float yaw, float roll) 设置实体的角速度.(备注:采用pitch, yaw和roll的浮点数形式的角速度).
SetForwardVector void SetForwardVector(Vector forwardVector) 设置实体的前向量.
SetHealth void SetHealth(int newHealth) 设置实体的生命值.
SetMaxHealth void SetMaxHealth(int maxHealth) 设置实体的最大生命值.
SetModel void SetModel(string modelName) 改变实体的模型, 这个函数并不预缓存模型!
待完善: 检查副作用
SetOrigin void SetOrigin(Vector position) 将实体移动到指定位置.
SetOwner void SetOwner(handle owner) 设置实体的所有者.
SetSize void SetSize(Vector, Vector) 设置碰撞体积大小.
SetTeam void SetTeam(int teamNumber) 立即转换玩家的团队. (备注:观察者 = 1, 恐怖分子 = 2, 反恐精英 = 3)
SetVelocity void SetVelocity(Vector velocity) 设置实体的速度向量.
StopSound void StopSound(String soundname) 停止一个在实体上播放的声音.
ValidateScriptScope bool ValidateScriptScope() 返回实体的脚本域是否已被创建.

Hooks

如果其中一个函数在实体脚本中被声明, 实体将在适当的情况下自动运行此函数.

函数 签名 描述
InputInputName bool InputInputName() 当实体从I/O系统中接收到输入时调用. 此函数的名称必须是实体input列表中的Input, 例如表示FireUser1的InputFireUser1. 当这个函数被调用时, 激活和调用的实体的脚本句柄会被写入接收输入的实体的脚本数据的activatorcaller变量中. 这个函数必须返回一个布尔值. 将布尔值设定为true允许实体来处理输入, 否则用false阻止之.
OnPostSpawn void OnPostSpawn() 在实体生成时立即被调用. 这个函数可以用于让实体向主脚本注册自身,或以编程方式调整实体参数.
Precache void Precache() 在脚本执行后调用. 可用于在地图加载时调用模型和声音的预缓存函数.

CBaseAnimating

Extends CBaseEntity

动画实体(如props)的脚本句柄类.

Methods

函数 签名 描述
GetAttachmentAngles Vector GetAttachmentAngles(int id) 以pitch, yaw, roll向量的形式获取附件ID的角度.
GetAttachmentOrigin Vector GetAttachmentOrigin(int 'id') 获取附件ID的位置向量.
IsSequenceFinished bool IsSequenceFinished() 返回主序列是否已经播放完成.
LookupAttachment int LookupAttachment(string attachmentName) 获取指定名字的附件ID.
SetBodygroup void SetBodygroup(int groupIndex, int value) 通过索引设置模型的bodygroup的值.BodyGroup是写死在qc内部的用来定义模型SubModel的信息。

CBaseFlex

Extends CBaseAnimating

Methods

函数 签名 描述
GetCurrentScene handle GetCurrentScene() 返回最早的活动场景实体的实例 (备注:如果有的话).
GetSceneByIndex handle GetSceneByIndex(int index) 返回指定索引的场景实体的实例.

CBasePlayer

Extends CBaseAnimating

Methods

函数 签名 描述
IsNoclipping bool IsNoclipping() 返回玩家是否处于noclip状态.

CBaseMultiplayerPlayer

Extends CBasePlayer

CSGO玩家的脚本句柄类,无附带方法。


CEnvEntityMaker

Extends CBaseEntity

env_entity_maker(en)的脚本句柄类.

Methods

函数 签名 描述
SpawnEntity void SpawnEntity() 在制造器的位置上创建一个实体
SpawnEntityAtEntityOrigin void SpawnEntityAtEntityOrigin(CBaseEntity entity) 在指定实体实例的位置上创建一个实体.
SpawnEntityAtLocation void SpawnEntityAtLocation(Vector origin, Vector orientation) 在指定的位置和方向上创建一个实体,方向为以度为单位的欧拉角(pitch, yaw, roll).
SpawnEntityAtNamedEntityOrigin void SpawnEntityAtNamedEntityOrigin(string targetName) 在一个指定名字的实体的位置上创建一个实体。

CFuncTrackTrain

Extends CFuncTrackTrain

Methods

函数 签名 描述
GetFuturePosition Vector GetFuturePosition(float, float) 获取track在未来X秒的内的位置.

CGameCoopMissionManager

Extends CGameCoopMissionManager

Methods

函数 签名 描述
GetWaveNumber int GetWaveNumber() 获取玩家已经完成的合作模式波数.

CHostage

Extends CGameCoopMissionManager

Methods

函数 签名 描述
IsBeingCarried bool IsBeingCarried() 返回人质当前是否正在被护送.


CPointTemplate

Extends CBaseEntity

point_template(en)的脚本句柄类.

Hooks

table PreSpawnInstance(string entityClass, string entityName)
如果定义了此Hook,它将在实体创建之前被调用,并且返回的任何KeyValues都将被分配给该实体。
function PreSpawnInstance( entityClass, entityName )
{
	local keyvalues =
	{ 
   		rendercolor = "0 255 0"
   		targetname = "mySpawnedEntity"
	}
	return keyvalues
	
}
void PostSpawn(table entities)
在实体生成后调用. 具有按名称索引的已生成的实体句柄的表被传递给该函数. 可以使用它来关联输出或在创建实体后做任何你想做的事情.
function PostSpawn( entities )
{
	foreach( name, handle in entities )
	{
		printl( name + ": " + handle )
	}
}


CSceneEntity

Extends CBaseEntity


Methods

函数 签名 描述
AddBroadcastTeamTarget void AddBroadcastTeamTarget(int index) 添加一个队伍(通过索引)到广播列表中.
EstimateLength float EstimateLength() 以秒为单位返回此场景的长度.
FindNamedEntity handle FindNamedEntity(string reference) 给定一个实体参照, 比如 !target, 以从场景对象中获取真正的实体.
IsPaused bool IsPaused() 返回这个场景是否暂停.
IsPlayingBack bool IsPlayingBack() 返回这个场景是否正在播放.
LoadSceneFromString bool LoadSceneFromString(string sceneName, string scene) 给定一个虚拟的场景名和vcd的字符串, 以加载场景.
RemoveBroadcastTeamTarget void RemoveBroadcastTeamTarget(int index) 从广播列表中删除一个队伍(通过索引).


CTriggerCamera

Extends CBaseEntity


Methods

函数 签名 描述
GetFov int GetFov() 以整数获取当前相机的FOV设置.
SetFov void SetFov(int fov, float rate) 用整数的度数设置相机的FOV, 用浮点数设置FOV的变化率.

Hooks

void ScriptStartCameraShot(string shotType, handle sceneEntity, handle actor1, handle actor2, float duration)
由SceneEntity调用以响应由一个VCD发送来的CChoreoEvent::CAMERA. [待完善]


CCallChainer

[待完善]

Methods

函数 签名 描述
constructor [待完善] constructor()
PostScriptExecute [待完善] PostScriptExecute()
Call [待完善] Call()

Members

实例 类型 描述
chains null
prefix null
scope null


CEntities

游戏实例: Entities

一个用于查找和遍历所有游戏中的实体的脚本句柄的接口. 要遍历一组实体, 请将null传递给适当方法中的前置参数以开始遍历, 或引用先前找到的实体以继续搜索. 以下两个示例都实现了遍历整个地图上的所有武器

local ent = null;
while ( ent = Entities.FindByClassname(ent, "weapon_*") )
{
  // ...
}
for (local ent; ent = Entities.FindByName(ent, "weapon_*"); )
{
  // ...
}
Note.png注意:
  • 变量名 ent 可根据自己情况定义.
  • 在循环条件中使用 "=" 而不是"=="!循环将在 ent 变为 null时停止.在循环体中ent是地图中的武器句柄不会为 null.
  • FindBy... 函数的字符串参数支持通配符 *.在上面的示例中 FindByClassname 仅返回类名以 "weapon_" 开头的类或者 null.

方法

函数 签名 描述
CreateByClassname handle CreateByClassname(string class) 通过种类名(class name)创建一个实体.
FindByClassname handle FindByClassname(handle previous, string class) 通过种类名寻找一个实体.
FindByClassnameNearest handle FindByClassnameNearest(string class, Vector origin, float radius) 查找最接近指定点的指定种类名的实体.
FindByClassnameWithin handle FindByClassnameWithin(handle previous, string class, Vector origin, float radius) 在一个范围内查找一个指定种类名的实体.
FindByModel handle FindByModel(handle previous, string filename) 通过模型名查找一个实体.
FindByName handle FindByName(handle previous, string name) 通过targetname查找一个实体.
FindByNameNearest handle FindByNameNearest(string name, Vector origin, float radius) 查找最接近指定点的指定targetname的实体.
FindByNameWithin handle FindByNameWithin(handle previous, string name, Vector origin, float radius) 在一个范围内查找一个指定targetname的实体.
FindByTarget handle FindByTarget(handle previous, string targetname) 通过实体自身的target查找一个实体.
FindInSphere handle FindInSphere(handle previous, Vector origin, float radius) 在一个范围内查找一个实体.
First handle First() 开始遍历的实体列表.
Next handle Next(handle previous) 继续遍历实体列表, 为先前找到的实体提供参照.
IsValid bool IsValid() 返回句柄是否属一个有效的实体.

CPlayerVoiceListener

Warning.png警告:此类无效! 此类虽然在 CS:GO 中实现,但所需的 PlayerVoiceListener 实例未实现.

方法

函数 签名 描述
GetPlayerSpeechDuration float GetPlayerSpeechDuration(int) 返回玩家持续说话的秒数.
IsPlayerSpeaking bool IsPlayerSpeaking(int) 返回指定玩家是否正在说话.
IsValid bool IsValid() 返回句柄是否属于一个有效的实体.

CScriptKeyValues

代表一个模型的$keyvalues(en)块的脚本句柄. 子键是同一类的实例.

Methods

函数 签名 描述
constructor
FindKey CScriptKeyValues FindKey(string keyName) 通过键名找到一个子键.
GetFirstSubKey CScriptKeyValues GetFirstSubKey() 返回第一个子键对象.
GetKeyBool bool GetKeyBool(string keyName) 以布尔形式返回一个键值.
GetKeyFloat float GetKeyFloat(string keyName) 以浮点数返回一个键值.
GetKeyInt int GetKeyInt(string keyName) 以整数返回一个键值.
GetKeyString string GetKeyString(string keyName) 以字符串形式返回一个键值.
GetNextKey handle GetNextKey() 将下一个相邻的键对象返回到调用该方法的对象.
IsKeyEmpty bool IsKeyEmpty(string keyName) 如果指定的键是空值返回真.
IsValid bool IsValid() 返回句柄是否属于一个有效的实体.
ReleaseKeyValues void ReleaseKeyValues() 释放实例的内容.


CSimpleCallChainer

看上去似乎和 CCallChainer 有相同的Members. [待完善]


LateBinder =

Late binding: allows a table to refer to parts of itself, it's children, it's owner, and then have the references fixed up after it's fully parsed.

// Usage:
lateBinder <- LateBinder();
lateBinder.Begin( this );

Test1 <-
{   
   Foo=1
}   

Test2 <-
{   
   FooFoo = "I'm foo foo"
   BarBar="@Test1.Foo"
   SubTable = { boo=[bah, "@Test2.FooFoo", "@Test1.Foo"], booboo2={one=bah, two="@Test2.FooFoo", three="@Test1.Foo"} }
   booboo=[bah, "@Test2.FooFoo", "@Test1.Foo"]
   booboo2={one=bah, two="@Test2.FooFoo", three="@Test1.Foo"}
   bah=wha
}   

lateBinder.End();
delete lateBinder;

When End() is called, all of the unresolved symbols in the tables and arrays will be resolved, any left unresolved will become a string prepended with '~', which later code can deal with.


Methods

函数 签名 描述
Begin
End
EstablishDelegation
HookRootMetamethod
Log
m_bindNamesStack
m_fixupSet
m_log
m_logIndent
m_targetTable
RemoveDelegation
Resolve
UnhookRootMetamethod

regexp

正则表达式的内置Squirrel 类.

Methods

函数 签名 描述
constructor regexp()
capture [table] capture(str, [start]) 返回在字符串str中的一个正则表达式的第一个匹配的包含2个索引("begin"和"end")的表的数组.为每个捕获的子表达式创建一个数组条目, 如果不匹配, 则返回null. 搜索从字符串的索引开始处开始, 如果忽略start, 则搜索从字符串的起始处开始.
match bool match(str) 如果正则表达式匹配字符串str, 则返回true, 否则返回false.
search table search(str, [start]) 返回包含字符串"str"中正则表达式第一个匹配的两个索引("begin"和"end")的表, 如果不匹配, 则返回null. 搜索从字符串的索引开始处开始, 如果忽略start, 则搜索从字符串的起始处开始.
subexpcount


Vector

Squirrel的Vector(en)类与C++相当.

三维向量用向量值和标量值重载了算术运算.

Note.png注意:声明与操作向量的例子

Methods

函数 签名 描述
constructor Vector(float x, float y, float z) 用指定的笛卡尔坐标创建一个新的向量.
Cross float Cross(Vector factor) 两个向量的向量乘积. 返回与输入向量正交的向量.
Dot float Dot(Vector factor) 两个向量的标量积.
Length float Length() 向量的幅度.
LengthSqr float LengthSqr() 向量的幅度的平方. 比上一个方法更快.
Length2D float Length2D() 返回x-y平面上向量的幅度.
Length2DSqr float Length2DSqr() 返回x-y平面上向量幅度的平方. 比上一个方法更快.
Norm float Norm() 以浮点数返回向量的长度. 这个函数同时也会将向量标准化, X, Y和Z值将被设置为-1和1之间的数字. 然后你可以将这些值乘以例如3000, 以使用该向量来设置游戏中某物的速度.
ToKVString string ToKVString() 返回一个没有分隔符的字符串.

Members

实例 类型 描述
x float 笛卡尔x轴.
y float 笛卡尔y轴.
z float 笛卡尔z轴.

全局函数

打印与绘制

函数 签名 描述
DebugDrawBox void DebugDrawBox(vector origin, vector min, vector max, int r, int g, int b, int alpha, float duration) 绘制一个调试覆盖框(debug overlay box).
DebugDrawLine void DebugDrawLine(Vector start, Vector end, int red, int green, int blue', bool zTest, float time) 在两点间绘制一根调试线(debug line).
Msg void Msg(string message) 相当于print
print void print(string message) 将给定的消息打印到开发人员控制台.
printl void printl(string message) 功能同上, 但会在最后附加一个换行符.
ScriptPrintMessageCenterAllWithParams void ScriptPrintMessageCenterAllWithParams(string, string, string, string) 在屏幕中央向所有玩家打印消息. 需要传递token/消息. 可以传递null给param1, param2, param3如果你只需要3个以内的参数.
ScriptPrintMessageCenterAll void ScriptPrintMessageCenterAll(string message) 在屏幕中央向所有玩家打印消息.
ScriptPrintMessageCenterTeam void ScriptPrintMessageCenterTeam(int, string) 在屏幕中央向指定队伍的玩家打印消息.
ScriptPrintMessageChatAll void ScriptPrintMessageChatAll(string message) 在聊天框中向所有玩家打印消息.
ScriptPrintMessageChatTeam void ScriptPrintMessageChatTeam(int teamNumber, string message) 在聊天框中向指定队伍的玩家打印消息.
ShowMessage void ShowMessage(string) 打印一条HUD消息给所有玩家.
Icon-Bug.png错误:不起作用  [todo tested in ?]
__DumpScope void __DumpScope(int indentation, handle scope) 转储域内的所有内容.

训练课程相关

函数 签名 描述
ScriptGetBestTrainingCourseTime int ScriptGetBestTrainingCourseTime() 获取玩家完成计时课程的最佳时间.
ScriptGetPlayerCompletedTraining bool ScriptGetPlayerCompletedTraining() 如果玩家已完成训练地图的初始部分, 则返回true.
ScriptGetValveTrainingCourseTime int ScriptGetValveTrainingCourseTime() 获得Valve完成计时课程的最佳时间。
ScriptHighlightAmmoCounter void ScriptHighlightAmmoCounter() 发送一个刚被指导系统用于显示一个用于突出弹药计数器的提示的事件.
ScriptSetBestTrainingCourseTime void ScriptSetBestTrainingCourseTime(int bestTime) 设置玩家完成计时课程的最佳时间.
ScriptSetMiniScoreHidden void ScriptSetMiniScoreHidden(bool scoreHidden) 切换迷你记分牌HUD元素的可见性.
ScriptSetPlayerCompletedTraining void ScriptSetPlayerCompletedTraining(bool trainingCompleted) 设置玩家是否完成了训练地图的初始部分.
ScriptShowExitDoorMsg void ScriptShowExitDoorMsg() 当玩家通过出口门退出时, 在训练课程中显示一个消息框.
ScriptShowFinishMsgBox void ScriptShowFinishMsgBox() 显示一个消息框,让玩家在完成训练课程后知道下一步该怎么做.
ScriptTrainingGivePlayerAmmo void ScriptTrainingGivePlayerAmmo() 对玩家拥有的所有武器重新装填弹药(只在训练模式中有用).

合作模式相关

函数 签名 描述
ScriptCoopCollectBonusCoin void ScriptCoopCollectBonusCoin() 将其中一个奖励币标记为已收集.
ScriptCoopGiveC4sToCTs void ScriptCoopGiveC4sToCTs(int) 将指定数量的C4给予所有活着的CT玩家.
ScriptCoopMissionGetMissionNumber int ScriptCoopMissionGetMissionNumber() 获取当前地图的任务编号(备注:地图可以有多个任务).
ScriptCoopMissionRespawnDeadPlayers void ScriptCoopMissionRespawnDeadPlayers() 仅用于重生玩家.
ScriptCoopMissionSetNextRespawnIn void ScriptCoopMissionSetNextRespawnIn(float, bool) 设置下一波重生的发生时间.
ScriptCoopMissionSpawnFirstEnemies void ScriptCoopMissionSpawnFirstEnemies(int) 在合作模式中生成第一波敌人.
ScriptCoopMissionSpawnNextWave void ScriptCoopMissionSpawnNextWave(int) 告知合作模式中下一波将要出生的敌人. 此函数也会复活玩家.
ScriptCoopResetRoundStartTime void ScriptCoopResetRoundStartTime() 重设回合时间并开始任务.
ScriptCoopSetBotQuotaAndRefreshSpawns void ScriptCoopSetBotQuotaAndRefreshSpawns(int) 通过考量在线玩家数量来设置机器人数量并刷新复活.

数学

The built-in Squirrel math library.

Function Signature Description
abs int abs(float x) 返回 x 的绝对值
acos float acos(float x) 返回对 x 进行acos运算后的值
asin float asin(float x) 返回对 x 进行asin运算后的值
atan float atan(float x) 返回对 x 进行atan运算后的值
atan2 float atan2(float x, float y) 返回对 x 进行atan2运算后的值
ceil float ceil(float x) 返回对 x 进行向上取整的值,返回值是一个float型整数
cos float cos(float x) 返回对 x 进行cos运算后的值
exp float exp(float x) 返回 x 的指数运算后的值
fabs float fabs(float x) 返回对 x 进行float转型后的值
floor float floor(float x) 返回对 x 进行向下取整的值,返回值是一个float型整数
log float log(float x) 返回 x 的log e对数
log10 float log10(float x) 返回 x 的log 10对数
pow float pow(float x, float y) 返回xy 次方
rand int rand() 返回一个从 0 到 RAND_MAX 的随机int整数
sin float sin(float x) 返回对 x 进行sin运算后的值
sqrt float sqrt(float x) 返回对 x 进行开平方后的值
srand void srand(float seed) 给上面那个随机数定义一个随机seed
tan float tan(float x) 返回对 x 进行tan运算后的值

其他

函数 签名 描述
Assert void Assert(bool value, string optional message) 检测布尔值, 如果不是true, 则显示异常, 可附带消息.
CreateProp handle CreateProp(string class, Vector origin, string model, int animation) 通过指定的类型和模型创建一个prop. 对于prop_physics, prop_dynamic 和其他一些带模型的实体都有效. 这个函数不会预缓存模型.
Icon-Bug.png错误:不会初始化prop的物理属性.
CreateSceneEntity CSceneEntity CreateSceneEntity(string scene) 创建一个场景实体来播放指定的场景.vcd文件.
DispatchParticleEffect void DispatchParticleEffect(string particleName, Vector, Vector) 调用一个一次性粒子系统.
DoIncludeScript bool DoIncludeScript(string filename, table scope) 执行脚本域设定为指定的表的脚本.
DoEntFire void DoEntFire(string target, string action, string value, float delay, handle activator, handle caller) 生成一个实体I/O事件. caller参数为句柄, 所以 target 可以设置成!self 来触发没有targetname的实体的输出.
EntFire function EntFire(string target, string action, string value, float delay = 0.0, handle activator = null) 生成一个实体I/O事件.
EntFireByHandle void EntFireByHandle(handle target, string action, string 'value, float delay, handle activator, handle caller) 生成一个实体I/O事件. 第一个参数是一个实体实例, 所以无名的或者由脚本创建的实体的句柄可以被轻松地传递.
FrameTime float FrameTime() 获取上一帧在服务器上花费的时间.
GetDeveloperLevel int GetDeveloperLevel() 获取developer模式的级别.
GetMapName string GetMapName() 获取地图名.
LoopSinglePlayerMaps bool LoopSinglePlayerMaps() 连续循环运行单人游戏地图.
PrintHelp [待完善]
RandomFloat float RandomFloat() 生成一个随机浮点数
RandomFloat float RandomFloat(float min, float max) 在一个给定范围内生成随机浮点数, 范围边界包括在内.
RandomInt int RandomInt() 生成一个随机整数.
RandomInt int RandomInt(int min, int max) 在一个给定范围内生成随机整数, 范围边界包括在内.
RecordAchievementEvent void RecordAchievementEvent(string, int) 录制成就事件或者进程.
RetrieveNativeSignature void RetrieveNativeSignature(string or func) 理论上这是用来打印本地函数的调用格式的函数, 但它实际上似乎只能输出 <unnamed>
ScriptGetGameMode int ScriptGetGameMode() 返回game_mode的设置. 请查阅 CSGODS # 专用服务器 了解更多信息.
ScriptGetGameType int ScriptGetGameType() 返回game_type的设置. 请查阅 CSGODS # 专用服务器 了解更多信息.
ScriptGetRoundsPlayed int ScriptGetRoundsPlayed() 获取从游戏开始迄今所经历的回合数.
ScriptIsLocalPlayerUsingController bool ScriptIsLocalPlayerUsingController() 返回玩家是否在使用控制器玩游戏.
ScriptIsWarmupPeriod bool ScriptIsWarmupPeriod() 返回是否是热身时间.
ScriptSetRadarHidden void ScriptSetRadarHidden(bool hideRadar) 切换雷达HUD元素的可见性. 仅适用于训练模式(game_type 2且game_mode 0)并且仅适用于连接的第一个人.
SendToConsole void SendToConsole(string command) 将一串命令以字符串形式发送到控制台.
SendToConsoleServer void SendToConsoleServer(string) 发送一个字符串, 作为服务器命令在服务器上执行.
Time float 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) 使用可选的根字符串生成一个字符串, 该字符串在脚本VM的整个生命周期中保证是唯一的. 当不知道该表中已经使用了哪些密钥时,对于向表中添加数据来说作用很大.
__ReplaceClosures

推荐阅读