Hey guys,
sorry I had to take a big editing break but thanks a lot for the help! I still can't get it to work unfortunately.
@h-
I should have pasted the entire script. Yes, I am calling the _move part as a function, the idea is just to generate waypoints via the waypointstatements so it becomes an infinite loop. I'm not sure that I'm doing things correctly, I know there's other scripts for this but I just really want to learn.
@Bardosy
The concept sounds great, I assigned the varnames but they don't seem to work with my commands. For example, I experimented with this:
player setVehicleVarName format["man%1",MC_globalnamecnt];
MC_globalnamecnt = MC_globalnamecnt+1;
hint format ["%1",player];
The hint returned "Man0" correctly, nothing happened when I tried something like
removeallweapons man0;
MC_globalnamecnt is off course defined in the init.sqf
Anyways, here is the entire script
if (!IsServer) exitwith {};
waituntil {!isnil "bis_fnc_init"};
private ["_man","_marker","_group","_WPos","_WP","_move","_formation"];
_unit = _this select 0;
_marker = _this select 1;
_formation = _this select 2;
_man = nul;
if ( !(_unit iskindof "man")) then {_man = effectivecommander _unit;} else {_man = _unit;};
_man setVehicleVarName format["man%1",MC_globalnamecnt];
MC_globalnamecnt = MC_globalnamecnt+1;
_man = vehiclevarname _man;
//hint format ["%1",_man];
sleep (2 + (random 2));
_man setvariable ["MC_COMPLETE",false,true];
_group = group _man;
_group setformation _formation;
_move = {
_WPos = [([_marker] call SHK_pos), 0];
_WP = _group addWaypoint _WPos;
_WP setWaypointType "Move";
_WP setWaypointbehaviour "careless";
_WP setWaypointspeed "limited";
_WP setWaypointStatements ["true", format ["%1 setvariable ['MC_COMPLETE',true,true];",_man]];
};
[] call _move;
while {{alive _x} count units _group > 0} do {
if ( _man getvariable "MC_COMPLETE") then {
deletewaypoint _WP;
_man setvariable ["MC_COMPLETE",false,true];
[] call _move;
};
sleep 15 + (random 15);
};
Some of that stuff may not make a lot of sense to the experienced scripters, please bear with me
The line "_man setvariable ["MC_COMPLETE",false,true];" is what causes a script error.