Jump to content
Sign in to follow this  
Bad_Dad

Help me fix this IED script...

Recommended Posts

Getting this error when launching mission ....

kKc2BQj.png

 

Here is the script.... 

someone please help me fix it. 

//[] execVM "scripts\ied.sqf";
iedMkr=["ied_marker_0","ied_marker_1","ied_marker_2","ied_marker_3","ied_marker_4","ied_marker_5"];	//List of markers to spawn IEDs in
_iedrandomnum = [6,8,10,12,14] call BIS_fnc_selectRandom;
iedNum=_iedrandomnum;					//Number of IEDs per marker, defined in iedMkr	[Default: 5]
iedDmg=true;							//Can the IED be killed with weapons?			[Default: false] TRUE = Yes | FALSE = Can only be disarmed
Dbug=false;								//Show IED markers on map?						[Default: false]


player setUnitTrait ["explosiveSpecialist",true];

//!!DO NOT EDIT BELOW!!
iedBlast=["Bo_Mk82","Rocket_03_HE_F","M_Mo_82mm_AT_LG","Bo_GBU12_LGB","Bo_GBU12_LGB_MI10"];
iedList=["IEDLandBig_F","IEDLandSmall_F","IEDUrbanBig_F","IEDUrbanSmall_F"];
iedAmmo=["IEDUrbanSmall_Remote_Ammo","IEDLandSmall_Remote_Ammo","IEDUrbanBig_Remote_Ammo","IEDLandBig_Remote_Ammo"];
iedJunk=["Land_PlasticBucket_01_closed_F","Land_tires_EP1","Barrel4","Suitcase","Land_Sack_EP1","Land_popelnice","Land_Canister_EP1","land_cwa_wheel_cart","Fuel_can","Land_GasTank_01_khaki_F","Land_CanisterOil_F","Land_FlowerPot_01_F","Tire_Van_02_F","Land_WheelieBin_01_F","Land_Tyre_F","Land_GarbageBarrel_02_buried_F","Land_PaperBox_01_small_destroyed_brown_F","Land_PaperBox_01_small_ransacked_brown_F","Land_PaperBox_01_small_ransacked_white_IDAP_F","Land_FoodContainer_01_White_F","Land_CarBattery_02_F","Land_Pillow_old_F","Land_Pillow_camouflage_F","Land_Pillow_grey_F","Land_TentSolar_01_folded_sand_F"];
if(!Dbug)then{{_x setMarkerAlpha 0;}forEach iedMkr;};

if(!isServer)exitWith{};
iedAct={_iedObj=_this select 0;
if(mineActive _iedObj)then{
_iedBlast=selectRandom iedBlast;
createVehicle[_iedBlast,(getPosATL _iedObj),[],0,""];
createVehicle["Crater",(getPosATL _iedObj),[],0,""];
{deleteVehicle _x}forEach nearestObjects[getPosATL _iedObj,iedJunk,4];
deleteVehicle _iedObj;};};

{private["_ieds","_trig"];_ieds=[];_iedArea=getMarkerSize _x select 0;_iedRoad=(getMarkerPos _x)nearRoads _iedArea;
	for "_i" from 1 to iedNum do{
	if(count _ieds==iedNum*4)exitWith{};
	_iedR=selectRandom _iedRoad;
	_ied=selectRandom iedList;_junk=selectRandom iedJunk;
	_ied=createMine[_ied,getPosATL _iedR,[],8];_ied setPosATL(getPosATL _ied select 2+1);_ied setDir(random 359);
	if(!iedDmg)then{_ied allowDamage false;};
	if(round(random 2)==1)then{_iedJunk=createVehicle[_junk,getPosATL _ied,[],0,""];_iedJunk setPosATL(getPosATL _iedJunk select 2+1);_iedJunk enableSimulationGlobal false;};
	_jnkR=selectRandom _iedRoad;_junk=createVehicle[_junk,getPosATL _jnkR,[],8,""];_junk setPosATL(getPosATL _junk select 2+1);
	_junk enableSimulationGlobal false;
	_trig=createTrigger["EmptyDetector",getPosATL _ied];
	_trig setTriggerArea[10,10,0,FALSE,10];
	_trig setTriggerActivation["ANY","PRESENT",false];
	_trig setTriggerTimeout[1,1,1,true];
	if(isMultiplayer)then{
	_trig setTriggerStatements[
		"{vehicle _x in thisList && speed vehicle _x>4}count playableUnits>0",
		"{if((typeOf _x)in iedAmmo)then{[_x]call iedAct;};}forEach nearestObjects[thisTrigger,[],10];",
		"deleteVehicle thisTrigger"];}else{
	_trig setTriggerStatements[
		"{vehicle _x in thisList && isPlayer vehicle _x && speed vehicle _x>4}count allUnits>0",
		"{if((typeOf _x)in iedAmmo)then{[_x]call iedAct;};}forEach nearestObjects[thisTrigger,[],10];",
		"deleteVehicle thisTrigger"];};

	_ieds pushBack _ied;
	if(Dbug)then{
		iedMkrs=[];
		_iedPos=getPosWorld _ied;
		_mkrID=format["m %1",_iedPos];
		_mkr=createMarker[_mkrID,getPosWorld _ied];
		_mkr setMarkerShape"ICON";_mkr setMarkerType"mil_dot";_mkr setMarkerBrush"Solid";_mkr setMarkerAlpha 1;_mkr setMarkerColor"ColorEast";
		iedMkrs pushBack _mkr;};
	};
}forEach iedMkr;
sleep 5;
{CIVILIAN revealMine _x; Resistance revealMine _x;}forEach allMines;

 

Share this post


Link to post
Share on other sites

Please don't post in caps lock, titles included.

 

The relevant section:

{ //...
_iedArea = getMarkerSize _x select 0;
_iedRoad = (getMarkerPos _x) nearRoads _iedArea;
	for "_i" from 1 to iedNum do {
	if (count _ieds == iedNum*4) exitWith {};
	_iedR = selectRandom _iedRoad;
// ...
} forEach iedMkr;

So, first guess is that there are no valid road segments in at least one of the marker areas. Since there is no check for an empty array, you get an error. You should do some basic testing to make sure you are returning road segments in a reliable manner.

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×