maaarv 1 Posted June 28, 2021 Hello We are currently developing an Sandbox Arma 3 Server. i want to make a Sniping spot where you can Snipe some AI´s the AI´s are set to: this disableai "ALL"; i got a simple Respawn script from a another forum post. which looks like this: Spoiler /////////////////////////////////////////////////////////////////////////////////////////////////// // EDIT THIS BELOW FOR true/false. _respawnAllAtOnce = true; // true/false only! edit this to suit the respawning needs, per unit or all at once. /////////////////////////////////////////////////////////////////////////////////////////////////// // DONT EDIT BELOW HERE! params ["_unit"]; // parse the unit to this script. via unit init line... [this] execVM "thisScript.sqf"; if (isNil "_unit") exitWith { diag_log format ["[ERROR] -> unit not able to init respawner"]; }; /////////////////////////////////////////////////////////////////////////////////////////////////// // respawner global function unitRespawner = { params ["_unit","_unitPos","_unitDir","_unitType","_unitGroup","_respawnAllAtOnce"]; _unitVarName = vehicleVarName _unit; // unit variable name. [_unit] joinSilent _unitGroup; // join the unit back to the same group. _unitDescription = getText (configfile >> "CfgVehicles" >> _unitType >> "displayName"); // get the display name of the unit via the configuration file (text). systemChat format ["SPAWNED %1 at position %2, facing %3 degrees (%4 | %5)",_unitVarName,_unitPos,_unitDir,_unitType,_unitDescription]; _unit disableAI "ALL"; { _x addCuratorEditableObjects [[_unit],false]; // add unit for zeus access/monitoring to all curators. } forEach allCurators; while {alive _unit} do // loop forever (until the unit is deceased). { waitUntil {!alive _unit}; // wait until the unit is dead. if (_respawnAllAtOnce) then // if true, wait until all AI are deceased then respawn them, else respawn 10 seconds after each unit is deceased. { waitUntil {count (nearestObjects [_unit,["CAManBase"],100] select {(side _x isEqualTo EAST) && (alive _x) && (vehicleVarName _x != "")}) isEqualTo 0}; // wait until ALL of the OPFOR (EAST) AI are deceased to respawn them. }; if (!alive _unit) exitWith // if unit is no longer alive execute the code within then exit the routine. { /////////////////////////////////////////////////////////////////////////////////////// uiSleep 10; // sleep for 10 seconds until clean up and recreate unit. /////////////////////////////////////////////////////////////////////////////////////// deleteVehicle _unit; // delete the deceased unit. {deleteVehicle _x;} forEach (nearestObjects [_unitPos,["GroundWeaponHolder","WeaponHolderSimulated"],5]); // gather all the weapon holder objects within 5 meters of the deceased unit position and delete them. /////////////////////////////////////////////////////////////////////////////////////// _unitNew = _unitGroup createUnit [_unitType, _unitPos, [], 0, "CAN_COLLIDE"]; // recreate the unit as a UNIT, not a VEHICLE. _unitNew setVehicleVarName _unitVarName; // re-add the unit variable name. _unitNew setPos _unitPos; // set the position to the original. _unitNew setDir _unitDir; // set the direction of the original. [_unitNew,_unitPos,_unitDir,_unitType,_unitGroup,_respawnAllAtOnce] spawn unitRespawner; // spawn a new thread for the global function 'unitRespawner' for the recreated unit. /////////////////////////////////////////////////////////////////////////////////////// }; }; }; the Problem is that when the ai Respawns the init isn´t there anymore so they run around and shoot at the players how can i fix that? thanks for you´re help Marvin Admin at German-Gamers.net Share this post Link to post Share on other sites
_-xXShArK_OGXx-_ 6 Posted July 2, 2021 what if you add _unitNew disableAI "ALL"; ?? maby like: _unitNew = _unitGroup createUnit [_unitType, _unitPos, [], 0, "CAN_COLLIDE"]; // recreate the unit as a UNIT, not a VEHICLE. _unitNew disableAI "ALL"; _unitNew setVehicleVarName _unitVarName; // re-add the unit variable name. _unitNew setPos _unitPos; // set the position to the original. _unitNew setDir _unitDir; // set the direction of the original. [_unitNew,_unitPos,_unitDir,_unitType,_unitGroup,_respawnAllAtOnce] spawn unitRespawner; // spawn a new thread for the global function 'unitRespawner' for the recreated unit. Share this post Link to post Share on other sites
pierremgi 4738 Posted July 4, 2021 You can add a variable on these units for some behaviors like respawning, disabling simulation... Example: this setVariable ["RespawnDisabled",true ]; // in init field of the unit. true = must be disabled Now, you can sort the units by: !isNil {_unit getvariable "RespawnDisabled"} // this unit must respawn then: _unit getVariable "RespawnDisabled" // false: not disabled, true: disabled How to make it work: on each group of units you want to respawn (single player or multi),... or on each unit write something like : {_x setVariable ["respawnDisabled",TRUE,TRUE]; _x disableAI "all"} count units this; or {_x setVariable ["respawnDisabled",FALSE,TRUE]} count units this; Then run this simple respawn code (you can add features but it's basic and working): RESPTIMER = 10; addMissionEventHandler ["entityKilled", { params ["_unit"]; if (!isNil {_unit getVariable "respawnDisabled"}) then { if (!isMultiplayer or !(_unit in playableUnits)) then { private _unitGroup = group _unit; [_unit,_unitGroup] spawn { params ["_unit","_unitGroup",["_unitNew",objNull]]; private _loadout = getUnitLoadout _unit; sleep RESPTIMER; private _unitNew = _unitGroup createUnit [typeOf _unit,getpos _unit, [], 0, "CAN_COLLIDE"]; _unitNew setVariable ["respawnDisabled", _unit getVariable "respawnDisabled",TRUE]; _unitNew setUnitLoadout _loadout; [_unitNew] joinSilent _unitGroup; if (_unitNew getVariable ["respawnDisabled",false]) then { _unitNew disableAI "all"; }; {deleteVehicle _x} forEach (nearestObjects [getpos _unit,["GroundWeaponHolder","WeaponHolderSimulated"],5]); deleteVehicle _unit; }; }; }; }]; Share this post Link to post Share on other sites