本帖最后由 2fast 于 2013-5-29 09:26 编辑
fnc_cfgVehicles_getClass =
{
private ["_classType","_i","_list","_item","_side"];
_classType = _this select 0;
_side = if(count _this>1)then{_this select 1}else{-1};
_list = [];
for "_i" from 0 to ((count (configFile >> "CfgVehicles"))-1) do
{
_item=((configFile >> "CfgVehicles") select _i);
if(isClass _item) then
{
if (getNumber (_item >> "scope") == 2) then //scope: public
{
if (getText (_item >> "vehicleClass") == _classType) then
{
if(_side==-1)then
{
_list set [count _list, configName _item];
}else{
if (getNumber (_item >> "side") == _side) then
{
_list set [count _list, configName _item];
};
};
};
};
};
};
_list
};
用法是
_list = [_type,_side] call fnc_cfgVehicles_getClass;
_type 可以写 "Car" "Men", "Air" "Ship" "Ammo" "Support" "Armored" "Backpacks" 等等种类
_side是写阵营 1是blue, 2是red, 3是civilian,不写的话就是无限制
_list出来的就是载具的名单
没有测试。
跟我之前发的脚本主要区别在于加了
if (getNumber (_item >> "side") == _side) then
{
_list set [count _list, configName _item];
};
这是读取每个class在config中side的设置,这个决定的载具是属于红蓝还是绿。当然也有平民,逻辑等等其它的值
去six config browser看看载具的Config
http://browser.six-projects.net/ ... F/config?version=69 蓝方载具
http://browser.six-projects.net/ ... F/config?version=69 红方
http://browser.six-projects.net/ ... d/config?version=69 平民
看他们的side值是不是不一样?这就是把他们分开的关键。 getNumber (_item >> "side") 就是读这个值的关键. |