Jump to content
Sign in to follow this  
stevoau

Returning "any", no Idea why

Recommended Posts

So basically I am trying to create ammo cache's at random locations on the map and spawn soldiers to protect them, what I am doing (because the number of cache's changes every time) is generating a random number from 0 - 999999 and using setVariable to assign it to a cache and a trigger which will spawn and despawn the soldiers when WEST units enter and leave the area respectively.

I have the caches and their triggers spawning fine but I have run into a hiccup, whenever I try to return _x (which SHOULD return the cache object) I get 'any'.

INS_isSame = 
{
_trig = _this select 0;
_idStr = _trig getVariable "tName";

{
	_crId = _x getVariable "cName";
	if (_idStr == _crId) then 
	{

		player sideChat format ["%1", _x];  // PRINTS THE OBJECT
		_x;
	}
} forEach crateGlobal;

_crate;
};

It is being called with

       [i]code code code[/i]

_nTrig setTriggerStatements ["this", 
"																
	_retCrate = [thisTrigger] call INS_isSame;
	Player sideChat format ['%1', _retCrate];  // PRINTS 'ANY'
	_nul = [_retCrate, thisTrigger] call INS_spawnUnits;
", 
"																	
	_nul = [thisTrigger] call INS_deleteUnits;
"];

       [i]code code code[/i]

Anyone know where I am going wrong?

Share this post


Link to post
Share on other sites

Try this

INS_isSame = {
private ["_crate", "_idStr"];

_crate = objNull;

_idStr = (_this select 0) getVariable "tName";

{
	if ((_x getVariable "cName") == _idStr) exitWith {
		player sideChat (format ["%1", _x]);

		_crate = _x;
	};
}
forEach crateGlobal;

_crate
};

Edited by Schatten

Share this post


Link to post
Share on other sites
Try this

INS_isSame = {
private ["_crate", "_idStr"];

_crate = objNull;

_idStr = (_this select 0) getVariable "tName";

{
	if ((_x getVariable "cName") == _idStr) exitWith {
		player sideChat (format ["%1", _x]);

		_crate = _x;
	};
}
forEach crateGlobal;

_crate
};

Yep that worked, THANK YOU!!!!!!

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  

×