Wetherby 10 Posted August 17, 2014 Hello everyone, I search a script capable to spawn unit when is close to a marker, despawn them when player is outside marker and respawn when the player is anew close to marker, i have trying this but for a reason i can't find it doesn't work, ennemi spawn but don't despawn and respawn : the test script if (!isServer) exitWith {}; //parametres _GST1 = creategroup east; _GST2 = creategroup east; _GST3 = creategroup east; _GST4 = creategroup east; _GST5 = creategroup east; _mark = _this select 0; _marksize = getMarkerSize _mark; _markaxisA = _marksize select 0; _sure = _markaxisA - 30; _calcul = round (Random (_markaxisA / 2)); _target = _calcul; _target2 = _markaxisA / 4; _range1 = round (Random 450); _range2 = round (Random 300); _spawnpos = getmarkerpos (_mark); _soldiernumber = NumbermedianST; _pos1 = [getmarkerpos _mark,[30,_sure],[0,90]] call SHK_pos; _pos2 = [getmarkerpos _mark,[30,_sure],[90,180]] call SHK_pos; _pos3 = [getmarkerpos _mark,[30,_sure],[180,270]] call SHK_pos; _pos4 = [getmarkerpos _mark,[30,_sure],[270,0]] call SHK_pos; _allunits = ["B_G_Soldier_F","B_G_Soldier_LAT_F"]; _maxunits = (count _allunits)-1; _allammoboxOPFOR = ["O_supplyCrate_F","Box_IND_Support_F","Box_East_Support_F","Box_IND_Wps_F","Box_East_Wps_F","Box_IND_WpsSpecial_F","Box_East_WpsSpecial_F","I_supplyCrate_F","C_supplyCrate_F","IG_supplyCrate_F","Box_IND_AmmoOrd_F","Box_East_AmmoOrd_F","Box_IND_Grenades_F","Box_East_Grenades_F","Box_IND_WpsLaunch_F","Box_NATO_WpsLaunch_F","Box_East_WpsLaunch_F","Box_IND_Ammo_F","Box_East_Ammo_F","Box_NATO_AmmoVeh_F","Box_IND_AmmoVeh_F","Box_East_AmmoVeh_F","Box_NATO_Support_F","Box_NATO_WpsSpecial_F","Box_NATO_Wps_F","B_supplyCrate_F","Box_NATO_Grenades_F","Box_NATO_AmmoOrd_F","Box_NATO_Ammo_F"]; _maxAmmo = (count _allammoboxOPFOR)-1; //Groupe 1 for "_j" from 0 to _soldiernumber do { _unit1 = _GST1 createUnit [_allunits select (round random _maxunits), _pos1, [], 5, "NONE"]; [_unit1] join _GST1; }; nul = [_GST1,_target] execVM "Patrol\SHK_Patrol.sqf"; //Groupe 2 for "_j" from 0 to _soldiernumber do { _unit2 = _GST2 createUnit [_allunits select (round random _maxunits), _pos2, [], 5, "NONE"]; [_unit2] join _GST2; }; nul = [_GST2,_target] execVM "Patrol\SHK_Patrol.sqf"; //Groupe 3 for "_j" from 0 to _soldiernumber do { _unit3 = _GST3 createUnit [_allunits select (round random _maxunits), _pos3, [], 5, "NONE"]; [_unit3] join _GST3; }; nul = [_GST3,_target] execVM "Patrol\SHK_Patrol.sqf"; //Groupe 4 for "_j" from 0 to _soldiernumber do { _unit4 = _GST4 createUnit [_allunits select (round random _maxunits), _pos4, [], 5, "NONE"]; [_unit4] join _GST4; }; nul = [_GST4,_target] execVM "Patrol\SHK_Patrol.sqf"; //Groupe 5 for "_j" from 0 to _soldiernumber do { _unit5 = _GST5 createUnit [_allunits select (round random _maxunits), _pos5, [], 5, "NONE"]; [_unit5] join _GST5; }; nul = [_GST5,_target] execVM "Patrol\SHK_Patrol.sqf"; //Ammobox OPFOR for "_j" from 0 to 5 do { _veh = createVehicle [_allammoboxOPFOR select (round random _maxAmmo),_spawnpos, [],_range2, "NONE"]; }; _BLUFOR_count = 1; _Exception = 0; _COK = 1; _PS = 0; nul = [_mark] execVM "VPFO\Patrolguer.sqf"; nul = [_mark] execVM "VPFO\HMG Group guer.sqf"; nul = [_mark] execVM "PrepareCOS.sqf"; While (getmarkercolor _mark == "ColorRed" or getmarkercolor _mark == "ColorBlack") do { _BLUFOR_Count = {(side _x) == west} count (nearestObjects [(getMarkerPos _mark), [], _markaxisA]); //_inf_count = {_x isKindof "Man" and (side _x) == west} count (nearestObjects [(getMarkerPos _mark), [], _markaxisA]); //_veh_count = {_x isKindof "Landvehicle" and (side _x) == west} count (nearestobjects[(getmarkerpos _mark),[],_markaxisA]); //_hel_count = {_x isKindof "Helicopter" and (side _x) == west} count (nearestobjects[(getmarkerpos _mark),[],_markaxisA]); //_pla_count = {_x isKindof "Plane" and (side _x) == west} count (nearestobjects[(getmarkerpos _mark),[],_markaxisA]); hint format ["%1",_BLUFOR_count]; if (_COK == 1) then { _G1count = {alive _x} count (units _GST1); _G2count = {alive _x} count (units _GST2); _G3count = {alive _x} count (units _GST3); _G4count = {alive _x} count (units _GST4); _G5count = {alive _x} count (units _GST5); _G1pos = getpos (leader _GST1); _G2pos = getpos (leader _GST2); _G3pos = getpos (leader _GST3); _G4pos = getpos (leader _GST4); _G5pos = getpos (leader _GST5); }; if(_BLUFOR_Count == 0) then { {deletevehicle _x}foreach units _GST1; {deletevehicle _x}foreach units _GST2; {deletevehicle _x}foreach units _GST3; {deletevehicle _x}foreach units _GST4; {deletevehicle _x}foreach units _GST5; _PS = 1; Exception = Exception + 1; }; if (_PS == 1 AND _BLUFOR_Count > 0 AND Exception > 0) then { _GST1 = creategroup east; _GST2 = creategroup east; _GST3 = creategroup east; _GST4 = creategroup east; _GST5 = creategroup east; //Groupe 1 for "_j" from 0 to _soldiernumber do { _unit1 = _GST1 createUnit [_allunits select (round random _maxunits), _pos1, [], 5, "NONE"]; [_unit1] join _GST1; }; nul = [_GST1,_target] execVM "Patrol\SHK_Patrol.sqf"; //Groupe 2 for "_j" from 0 to _soldiernumber do { _unit2 = _GST2 createUnit [_allunits select (round random _maxunits), _pos2, [], 5, "NONE"]; [_unit2] join _GST2; }; nul = [_GST2,_target] execVM "Patrol\SHK_Patrol.sqf"; //Groupe 3 for "_j" from 0 to _soldiernumber do { _unit3 = _GST3 createUnit [_allunits select (round random _maxunits), _pos3, [], 5, "NONE"]; [_unit3] join _GST3; }; nul = [_GST3,_target] execVM "Patrol\SHK_Patrol.sqf"; //Groupe 4 for "_j" from 0 to _soldiernumber do { _unit4 = _GST4 createUnit [_allunits select (round random _maxunits), _pos4, [], 5, "NONE"]; [_unit4] join _GST4; }; nul = [_GST4,_target] execVM "Patrol\SHK_Patrol.sqf"; //Groupe 5 for "_j" from 0 to _soldiernumber do { _unit5 = _GST5 createUnit [_allunits select (round random _maxunits), _pos5, [], 5, "NONE"]; [_unit5] join _GST5; }; nul = [_GST5,_target] execVM "Patrol\SHK_Patrol.sqf"; PS = 0; COK = 1; }; sleep 5; }; thank for your time and help and sorry for bad english Share this post Link to post Share on other sites
Wetherby 10 Posted August 18, 2014 I have trying a long time ago EOS and IIRC he caused some problem with my mission, i go try it with the new version and i feedback to you if it work or not, thank for your help Mario. Share this post Link to post Share on other sites
jshock 513 Posted August 19, 2014 If that doesn't work this thread a bit further down from the original posts could offer an alternative. http://forums.bistudio.com/showthread.php?181246-Triggers-passing-variables-from-in-game-editor-to-sqf-file Share this post Link to post Share on other sites
benw 11 Posted August 19, 2014 (edited) you don't need to delete them, maybe teleport them to a safe place and use the enablesimulationglobal false on them. can i know why you do not use the server to spawn units? some scripts required the server to execute the commands because server is the root for making everything work in singleplayer Edited August 19, 2014 by benw Share this post Link to post Share on other sites
Wetherby 10 Posted August 20, 2014 Thank JShock and benw but after trying EOS and saw it work i decide to use it for my mission but thank anyway. Share this post Link to post Share on other sites