Jump to content

Recommended Posts

Hi guys,

Recently started giving scripting a bit of attention but ran into a problem. Iam trying to create a simple script that would put hit markers onto targets and subsequently addAction to delete them. The last part is what Iam struggling with as I am not able to get the spawned spheres into array to delete them:
 

_targets = [0,0] nearObjects ["TargetBase", 9999999];
_bulletholes = {_x addEventHandler ["HitPart", {_spr = "Sign_Sphere10cm_F" createVehicle [0,0,0]; _spr setPosASL (_this select 0 select 3);}];} forEach _targets;
hint format ["%1,%2,%3", _bulletholes];


_targets just looks for TargetBase objects

_bulletholes tries to create the Hit Markers using eventHandler HitPart.

But when i try to use the bulletholes variable it just returns count of spheres created, not the objects themselves.

Thanks for your help,

Simple

Share this post


Link to post
Share on other sites

 

Quote

forEach returns any (the last passed value will be the return value or just Nothing, depends on the function called).
_var = {_x} forEach [ nil,"s",objNull,configFile ]; // return bin\config.bin
_var = {_x setCaptive true} forEach allUnits; // return nothing

Source: https://community.bistudio.com/wiki/forEach

 

If its the objects with the EVH on them that you want saved to an array, use this:

_targets = [0,0] nearObjects ["TargetBase", 9999999];
_bulletholes = [];
{
	_bulletholes pushback _x;
	_x addEventHandler ["HitPart", {_spr = "Sign_Sphere10cm_F" createVehicle [0,0,0]; _spr setPosASL (_this select 0 select 3);}];
} forEach _targets;
hint str _bulletholes;

 

If its the spheres spawned after they are hit, use this:

_targets = [0,0] nearObjects ["TargetBase", 9999999]; 
bulletholes = []; 
{ 
	_x addEventHandler ["HitPart", { 
		_spr = "Sign_Sphere10cm_F" createVehicle [0,0,0]; 
		_spr setPosASL (_this select 0 select 3); 
		bulletholes pushback _spr; 
		hint str bulletholes;
	}]; 
} forEach _targets;

 

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

×