iV - Ghost 50 Posted July 28, 2018 I wanna clear the area of operations after the tasks are done. But the script should waitUntil no players in the area. This is my code: /* * * Filename: fn_clearAO.sqf * Author: [iV] Ghost * Description: Delete units and mines in the ao plus all empty groups. Then delete taskmarker and pushBack file into array. * * Example: ["M_TaskHR", 500, "scripts\taskmanager\tasks\TaskHR.sqf", iV_Tasks] call iV_fnc_clearAO; * */ // RUN ON DEDICATED SERVER OR PLAYER HOST if (!isServer) exitWith {}; // VARIABLES params ["_markerName", "_radius", "_file", "_array"]; private _pos = getMarkerPos _markerName; private _players = allPlayers - entities "HeadlessClient_F"; private _allObjects = _pos nearEntities ["Man", _radius + 50]; private _allMines = _pos nearEntities ["MineMine", _radius + 50]; // WAIT UNTIL waitUntil { sleep 10; (_players distance _pos) > _radius + 100; // Doesn't work (Only wait 10 seconds) }; // CLEAR AREA, DELETE TASKMARKER & PUSHBACK FILE if ((_players distance _pos) > _radius + 100) exitWith { {deleteVehicle _x} forEach _allObjects; // Works {deleteVehicle _x} forEach _allMines; // Not tested // REMOVE EMPTY GROUPS { if ((count (units _x)) == 0) then { deleteGroup _x; _x = grpNull; _x = nil; }; } foreach allGroups; // TIMEOUT sleep 5; // DELETE TASKMARKER deleteMarker _markerName; // Works // PUSHBACK INTO ARRAY _array pushBack _file; // Doesn't work publicVariable str _array; }; But now I have 2 problems: 1. The script don't waitUntil no players in the area. 2. My _file doesn't pushBack into my _array. Share this post Link to post Share on other sites
stanhope 412 Posted July 28, 2018 You could use a trigger with the condition 'anyplayer' and put your clean-up code in the on-activation of the trigger. https://community.bistudio.com/wiki/setTriggerActivation What is _file? String, object, ...? Share this post Link to post Share on other sites
Schatten 290 Posted July 28, 2018 Well... According BIKI, distance command doesn't accept ARRAYS (except coordinates). But _players is array. So, you need to check distance to EACH unit something like this: _nooneHere = ({(_x distance _pos) <= (_radius + 100)} count _players) == 0; It's absolutely senselessly to do this: _x = grpNull; _x = nil; According BIKI, publicVariable command accepts variable NAME, not VALUE. But "str _array" returns string representation of _array. Possible resolution: myPubVar = _array; publicVariable "myPubVar"; General advice: read BIKI first. 1 Share this post Link to post Share on other sites
iV - Ghost 50 Posted July 28, 2018 @stanhope: _file is a string with my taskpath (E.G. "scripts\taskmanager\tasks\TaskHR.sqf"). After a task is selected, the path is deleted so that it is not used twice. And when a task is completed (canceled, succeeded, failed) the _file should be pushed back in the array. @Schatten: Works now. Thanks for help. Sometimes I can't see the problem. Always use google and the BIKI first. And if I can't find the problem (oftenly a few weeks later) I'm asking for help in the forum. ... private _area = _radius + 100; private _players = allPlayers - entities "HeadlessClient_F"; ... // WAIT UNTIL waitUntil { sleep 10; {_x distance _pos < _area} count _players == 0; }; // CLEAR AREA, DELETE TASKMARKER & PUSHBACK FILE if ({_x distance _pos < _area} count _players == 0) exitWith { ... // PUSHBACK INTO ARRAY _array pushBack _file; publicVariable str _array; }; Share this post Link to post Share on other sites