Jump to content
Sign in to follow this  
hogmason

check player array distance code producing errors

Recommended Posts

i am getting a heap of strange errors with this code can some one have a look at it for me

the code


waituntil {!isnil "bis_fnc_init"};

    _iedpos = _this select 0;
 _targetarray = [sgt,Medic2,Medic,Sniper,Machinegunner,Morter,Scout,FAC,AssualtTrooper,AssualtTrooper_1,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11];// removed ied tech	 

   while {true} do 
{	
 hint "ur dead";
   _wait = [0.5,1,2,3] call BIS_fnc_selectRandom;
   _distance = [5,10] call BIS_fnc_selectRandom;

       if ({(_x distance _iedpos) <_distance} count _targetarray) exitWith		
       { 	
           hint "FUCK IED RUN";// CHANGE TO PLAY A SOUND
            sleep _wait;			
		_bombtype = ["Bo_Mk82","BO_GBU12_LGB"] call BIS_fnc_selectRandom;
	     _bomb = _bombtype createVehicle position _iedpos;							
	      deletevehicle _iedpos;
                  execVM "HOG_scripts\HOG_ieds\respawn.sqf";			  
       }; 
     sleep 5;	
   };

errors like

Error in expression <t = [1,2,3] call BIS_fnc_selectRandom;

if ({(_x distance _iedpos) <10} count _t>
 Error position: <if ({(_x distance _iedpos) <10} count _t>
 Error if: Type Number, expected Bool


Share this post


Link to post
Share on other sites

{(_x distance _iedpos) <_distance} count _targetarray

Count, counts how many of the elements in the array that fulfils a condition - That is it gives a number. So you are basically saying:

if (3) then { ... };

What your meant is probably that if at least 1 (more than 0) of the people are near the ied then it should do something. That condition would look like this:

{(_x distance _iedpos) <_distance} count _targetarray > 0

Share this post


Link to post
Share on other sites

The if check waits for a boolean. As your error informs you, you're providing it with a count: a number.

if ({(_x distance _iedpos) <_distance} count _targetarray > 0)

would probably work.

Then again, this is exactly what a trigger does.

Share this post


Link to post
Share on other sites

dont want to spawn 100 triggers around my random ieds ;) thanks guys ill test it now.

---------- Post added at 23:28 ---------- Previous post was at 23:21 ----------

works great but now im getting 1 more error


Error in expression <_ied = _iedrandom createVehicle (getpos _iedplace);			
_ied setPos [(getPos _ied>
 Error position: <_iedplace);			
_ied setPos [(getPos _ied>
 Error Undefined variable in expression: _iedplace

this is the code


waituntil {!isnil "bis_fnc_init"};

if (isServer) then 
{
	_gamelogic = center;
	_towns = nearestLocations [getPosATL _gamelogic, ["NameVillage","NameCity","NameCityCapital"], 25000]; 

	for "_i" from 0 to 50 do   
	{

	_iedrandom = ["Land_IED_v1_PMC","Land_IED_v2_PMC","Land_IED_v3_PMC","Land_IED_v4_PMC"] call BIS_fnc_selectrandom;

		_RandomTownPosition = position (_towns select (floor (random (count _towns)))); 
		_distanceaway = 650;
		_list = _RandomTownPosition nearRoads _distanceaway;
		_Randomroad = count _list; 
		_amount = random _Randomroad;
		_iedplace = _list select _amount;
		_offset = random 9;

		_ied = _iedrandom createVehicle (getpos _iedplace);			
		_ied setPos [(getPos _ied select 0) + _offset, (getPos _ied select 1) + _offset, getPos _ied select 2];
		[_ied] spawn ied_detonate;
            _ied setVehicleInit "this addAction ['Disarm IED','HOG_scripts\HOG_ieds\disarm.sqf','player distance _ied<3']";
		   processInitCommands;

			 if (HOG_debug) then 
             {                 
	          [sgt,nil,rgroupChat,"Spawning IED + Debug ON."] call RE; 
                  sleep 0.2;				
                   _handle = [_ied,"IED","ColorGreen","mil_dot"] spawn HOG_debug_mkrs_fnc;
                };				 
			 //sleep 0.5;
	};	

	for "_i" from 0 to 50 do   
	{

	_iedrandom = ["Land_IED_v1_PMC","Land_IED_v2_PMC","Land_IED_v3_PMC","Land_IED_v4_PMC"] call BIS_fnc_selectrandom;

_pos = center;
_radius = random 5000;
_exp = "(1 + houses) * (1 - sea)";
_prec = 50;

_bestplace = selectBestPlaces [_pos,_radius,_exp,_prec,1];
_spot = _bestplace select 0;
_spot2 = _spot select 0;

_spwpos = createMarkerLocal ["iedpos", _spot2];
"iedpos" call fnc_HOG_randomPos;

		_ied = _iedrandom createVehicle (getMarkerPos "iedpos");			

            _ied setVehicleInit "this addAction ['Disarm IED','HOG_scripts\HOG_ieds\disarm.sqf','player distance _ied<3']";
		   processInitCommands;
		    [_ied] spawn ied_detonate;

			 if (HOG_debug) then 
             {                 
	          [sgt,nil,rgroupChat,"Spawning IED + Debug ON."] call RE; 
                  sleep 0.2;				
                   _handle = [_ied,"IED","ColorGreen","mil_dot"] spawn HOG_debug_mkrs_fnc;
                };				 
			 //sleep 0.5;
			 deleteMarker "iedpos";

	};		

};		


Share this post


Link to post
Share on other sites

yeah what can i say im an extreamist lmaorofl

---------- Post added at 09:25 ---------- Previous post was at 09:24 ----------

wait till you play the mission lmao its extream rambos will not last

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  

×