Fandom

武装突袭 Wiki

Count

简体 | 繁體

4,827个页面创建
于此维基上
添加新页面
评论0 Share

您使用了广告屏蔽软件!


Wikia通过广告运营为用户提供免费的服务。我们对用户通过嵌入广告屏蔽软件访问网站进行了使用调整。

如果您使用了广告屏蔽软件,将无法使用我们的服务。请您移除广告屏蔽软件,以确保页面正常加载。

Introduced with Operation Flashpoint version 1.00
  Arguments of this scripting command have to be local to the client the command is executed on

点击图片可看到更多讯息

开始使用于

游戏:
Operation Flashpoint
版本:
1.00

描述

描述:
Can be used to count:

  • the number of elements in array
  • the number of elements in array with condition
  • the number of sub-entries in a config object
  • the number of characters in a string (since ["Arma 3","Arma3",127,126674,"Development"])

基本句法

句法:
count array
参数:
array: Array
返回值:
Number

替代句法

句法:
condition count array
参数:
condition: Code that must return true for the tested element to be counted. The variable _x will contain the currently tested element.

array: Array
返回值:
Number

替代句法2

句法:
count configname
参数:
configname: Config
返回值:
Number

替代句法3

句法:
count string
参数:
string: String
返回值:
Number

范例

范例1:
_cnt = count [0,0,1,2]; // returns 4 _cnt = count units group player; // returns number of units in player group

范例2:
_cnt = {_x == 4} count [1,9,8,3,4,4,4,5,6]; // returns 3 _cnt = {alive _x} count allUnits; // returns the number of alive units

范例3:
_cnt = count (configFile >> "CfgVehicles");

范例4:
hint str count "japa is the man!"; //16

额外资讯

多人游戏:
-
也可以看看:

setresizepushBackpushBackUniqueapplyselectreverseselectinfindtoArraytoStringforEachdeleteAtdeleteRangeappendsortparamparamsarrayIntersectcountFriendlycountEnemycountUnknowncountSidecountTypesplitStringjoinString

注意事项

此处撰写句法皆为可行用法. 可到官网[1]专页回报错误. 你可以使用讨论页面或是论坛来进行讨论.
新增注意事项 | 如何新增?

Notes

Posted on April 28, 2007 - 13:49
Kronzky
This conditional count command only works if all the elements in the tested array are of the same type as the tested element.
For example, the following code will created an error, since the elements are of different types (object, number, string): _arr = [ player,100,"one"]; {_x == "one"} count _arr;

Alternatively, to avoid the error use isEqualTo instead of ==. --KK

This one, on the other hand, where all elements are strings, just like the tested element, will return the correct result of 1: _arr = ["one","two","three"]; {_x == "one"} count _arr;


Posted on August 3, 2006 - 14:27
hardrock
Notes from before the conversion: Use this to calculate how many "M16" mags a soldier has left. {_x == "M16"} count magazines soldier1; Take care when using count to determine how many units are left alive in a group: count units group player or count units groupname Will return the number of units the leader of the group thinks are alive. If some units have been killed out of sight of other members of the group then it may take sometime for this to be the actual numbers in the group. To determine exactly how many units are really alive in a group use: {alive _x} count units group player; or {alive _x} count units groupname;

Bottom Section

Posted on December 15, 2014 - 00:01 (UTC)
Heeeere's Johnny!
count can be (ab)used for a very fast and simple check if at least one element in an array fulfills a certain condition: if({if(_x fulfills condition) exitWith {1}; false} count _array isEqualTo 1) then {

   //do whatever here

}; This code will exit the count loop as soon as it finds an element fulfilling the condition, leaving the count with the value of 1, hence make the larger if-condition be true.
If no array element fulfills the condition, the count will be 0 and the if-condition will be false.

Posted on December 29, 2014 - 21:23 (UTC)
Killzone Kid
Quit loop at first fulfilled condition (same as above but faster): 0 = {if (_x == 4) exitWith { //do something when we reach 4 }} count [1,2,3,4,5,6];

Posted on January 2, 2015 - 22:32 (UTC)
Heeeere's Johnny!

Using exitWith inside a count loop will overwrite the default functionality and make count return whatever the exitWith returns: _result = {

   if(_x isEqualTo 3) exitWith {"Hello"}

} count [1,2,3,4,5]; //_result = "Hello"

更多维基

随机维基