bosoy07 › Среда
› 18.03.2015
› 17:57
› Сообщение # 1
Полковник
В увольнительной
- Группа:
- Пользователи
- Сообщений:
- 190
Чтобы не мешали поваленные деревья написал скрипт.1. находим массив всех обьектовнапример в радиусе 100 м от игрокаКод obj = nearestObjects [player,[],100]; 2.отсеиваем из массива деревья, проверяем их на дамаг и поднимаем (восстанавливаем).Код obj call fnc_repair_tree; fnc_repair_treeЦитата if !(isClass(configFile>>'CfgPatches'>>'cba_main')) then{ fnc_defaultParam = { /* ---------------------------------------------------------------------------- Function: CBA_fnc_defaultParam Description: Gets a value from parameters list (usually _this) with a default. Example (direct use of function): (begin code) private "_frog"; _frog = [_this, 2, 12] call CBA_fnc_defaultParam; (end code) Example (macro): (begin code) #include "script_component.hpp" DEFAULT_PARAM(2,_frog,12); (end code) Parameters: _params - Array of parameters, usually _this [Array] _index - Parameter index in the params array [Integer: >= 0] _defaultValue - Value to use if the array is too short [Any] Returns: Value of parameter [Any] ---------------------------------------------------------------------------- */ _params = _this select 0; _index = _this select 1; _defaultValue = _this select 2; private "_value"; if (!isNil "_defaultValue") then { _value = _defaultValue; }; if (!isNil "_params" && {(typeName _params) == "ARRAY"} && {count _params > _index} && {!isNil { _params select _index }}) then { _value = _params select _index; }; // Return. if (isNil "_value") then { nil; } else { _value; }; }; fnc_find = { /* ---------------------------------------------------------------------------- Function: CBA_fnc_find Description: Finds a string within another string. Parameters: _haystack - String in which to search [String or ASCII char array] _needle - String to search for [String or ASCII char array] _initialIndex - Initial character index within _haystack to start the search at [Number: 0+, defaults to 0]. Returns: First position of string. Returns -1 if not found [Number] Examples: (begin example) _result = ["frog-headed fish", "f"] call CBA_fnc_find; // _result => 0 _result = ["frog-headed fish", "f", 5] call CBA_fnc_find; // _result => 12 _result = ["frog-headed fish", "fish"] call CBA_fnc_find; // _result => 12 (end) Author: Xeno ---------------------------------------------------------------------------- */ _haystack = _this select 0; _needle = _this select 1; _initialIndex = [_this, 2, 0] call fnc_defaultParam; private ["_haystackCount", "_needleCount", "_foundPos", "_needleIndex", "_doexit", "_notfound"]; if (typeName _haystack == "STRING") then { _haystack = toArray _haystack; }; if (typeName _needle == "STRING") then { _needle = toArray _needle; }; _haystackCount = count _haystack; _needleCount = count _needle; _foundPos = -1; if ((_haystackCount - _initialIndex) < _needleCount) exitWith {_foundPos}; _needleIndex = 0; _doexit = false; for "_i" from _initialIndex to (_haystackCount - 1) do { if (_haystack select _i == _needle select _needleIndex) then { if (_needleCount == 1) exitWith { _foundPos = _i; _doexit = true; }; if (_haystackCount - _i < _needleCount) exitWith {_doexit = true}; _needleIndex = (_needleIndex) + 1; _notfound = false; for "_j" from (_i + 1) to (_i + _needleCount - 1) do { if (_haystack select _j != _needle select _needleIndex) exitWith { _notfound = true; }; _needleIndex = (_needleIndex) + 1; }; if (_notfound) then { _needleIndex = 0; } else { _foundPos = _i; _doexit = true; }; }; if (_doexit) exitWith {}; }; _foundPos }; // ==========================================================// private ["_debug", "_trees"]; _debug = false; _trees = []; { if (([str _x, ": t_"] call fnc_find) > -1 || {([str _x, "palm"] call fnc_find) > -1}) then { _trees set [count _trees,_x]; }; } forEach _this; if _debug then { hint str _trees; copyToClipboard str _trees; {_x setdamage 1;} foreach _trees; sleep 5; }; { if ((damage _x) > 0) then { _x setdamage 0; }; } foreach _trees;}else{ private ["_debug", "_trees"]; _debug = false; _trees = []; { if (([str _x, ": t_"] call CBA_fnc_find) > -1 || {([str _x, "palm"] call CBA_fnc_find) > -1}) then { _trees set [count _trees,_x]; }; } forEach _this; if _debug then { hint str _trees; copyToClipboard str _trees; {_x setdamage 1;} foreach _trees; sleep 5; }; { if ((damage _x) > 0) then { _x setdamage 0; }; } foreach _trees;}; Добавлено (18.03.2015, 17:57) --------------------------------------------- KK_fnc_inString = {/*Author: Killzone_Kid Description:Find a string within a string (case insensitive) Parameter(s):_this select 0: <string> string to be found_this select 1: <string> string to search in Returns:Boolean (true when string is found) How to use:_found = ["needle", "Needle in Haystack"] call KK_fnc_inString;*/ private ["_needle","_haystack","_needleLen","_hay","_found"];_needle = _this select 0;_haystack = toArray (_this select 1);_needleLen = count toArray _needle;_hay = +_haystack;_hay resize _needleLen;_found = false;for "_i" from _needleLen to count _haystack do {if (toString _hay == _needle) exitWith {_found = true};_hay set [_needleLen, _haystack select _i];_hay set [0, "x"];_hay = _hay - ["x"]};_found}; // ==========================================================//private ["_trees"];_trees = [];{if (([": t_",str _x] call KK_fnc_inString) || {(["palm",str _x] call KK_fnc_inString)} || {([": str",str _x] call KK_fnc_inString)}) then{_trees set [count _trees,_x]; };} forEach _this;_trees
Dimon UA
|