Jump to content
Sign in to follow this  
Kovah85

What have I done wrong here?

Recommended Posts

Maybe someone could help me out here, I can't seem to make this work:

{if (isnil (_x getVariable "handled")) then
{
_x setVariable ["handled", 1, true];
_x addEventHandler ["killed", "[_this select 0, _this select 1]execVM 'killed.sqf'"];
}} forEach allUnits;

No errors or anything... just doesn't... do... anything. Even adding an ELSE doesn't do anything.

EDIT: Take note, this is just a snippet that I hastily edited to make readable on the forum.

Edited by Kovah85

Share this post


Link to post
Share on other sites

Oh crap. I meant to post there. Sorry.

Share this post


Link to post
Share on other sites

Try this:

{
if (isnil (_x getVariable "handled")) then {
	{
		_x setVariable ["handled", 1, true];
		_x addEventHandler ["killed", "{[_this select 0, _this select 1] execVM "killed.sqf"}];
	} forEach allUnits;
};
} forEach allUnits;

Edited by IndeedPete

Share this post


Link to post
Share on other sites

{_x addEventHandler ["killed", []execVM 'killed.sqf'];

} forEach allUnits;

Share this post


Link to post
Share on other sites

I had a similar issue with the isnil check on a getvariable, but decided it was because isnil wants a variable in quotes. I worked it out to something like this:

{
_dummy = _x getVariable "handled";
if (isnil "_dummy") then {
	{
		_x setVariable ["handled", 1, true];
		_x addEventHandler ["killed", "{[_this select 0, _this select 1] execVM "killed.sqf"}];
	} forEach allUnits;
};
} forEach allUnits;

But, I think Reimann may have the real answer. ;)

Share this post


Link to post
Share on other sites

_x addEventHandler ["killed",{[_this select 0, _this select 1] execVM "killed.sqf"}];

This is not OFP, code should be contained within { }'s not quotes. Also you don't really need to have all those parameters, just pass _this to the script even if all you need are just the first 2 arguments.

_x addEventHandler ["killed",{_this execVM "killed.sqf"}];

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  

×