Jump to content
Sign in to follow this  
RonnieJ

addeventhandler not working?

Recommended Posts

Hey guys... im trying to add an event to a spawned unit... using createVehicle its works but then I cant link the rest of the group together (dont know how). Using createUnit they group up correctly but then the event handler wont work??

_generalgrp = CreateGroup East;

//general = createVehicle ["RU_Commander", _pos, [], 0, "NONE"];

general = "RU_Commander" createUnit [_pos, _generalgrp];
general addeventhandler ["killed",{[_this] execVM "cash.sqf";}];

So what am I doing wrong?

general = "RU_Commander" createUnit [_pos, _generalgrp];
general addeventhandler ["killed",{[_this] execVM "cash.sqf";}];

Dosent work with the event handler but gets grouped up correctly.

general = createVehicle ["RU_Commander", _pos, [], 0, "NONE"];
general addeventhandler ["killed",{[_this] execVM "cash.sqf";}];

The eventhandler works but I cant seem to get the spawned unit to group up with _generalgrp.

Share this post


Link to post
Share on other sites

general = "RU_Commander" createUnit [_pos, _generalgrp];
general addeventhandler ["killed",{[_this] execVM "cash.sqf";}];

This syntax of createUnit doesn't return the unit. Thus, it's most of the time useless.

general = createVehicle ["RU_Commander", _pos, [], 0, "NONE"];
general addeventhandler ["killed",{[_this] execVM "cash.sqf";}];

Using createUnit this way does return the object. However, your local variable "_generalgrp" will not exists in cash.sqf.

Share this post


Link to post
Share on other sites

Delete this clamps "",{[_this] execVM "

or better write like below

general addeventhandler ["killed",{_this execVM "cash.sqf";}];

Regards Intruder

Share this post


Link to post
Share on other sites

shk> ye that working with the eventhandler but how do I group units together?

_generalgrp = CreateGroup East;

general = createVehicle ["RU_Commander", _pos, [], 0, "NONE"];

general addeventhandler ["killed",{[_this] execVM "cash.sqf";}];

sold1 = createVehicle ["RUS_Soldier_GL", _pos, [], 0, "NONE"];

sold1 addeventhandler ["killed",{[_this] execVM "cash.sqf";}];

Share this post


Link to post
Share on other sites
_generalgrp = CreateGroup East;
general = _generalgrp createunit ["RU_Commander",_pos,[],0,"none"];
sold1 = _generalgrp createunit ["RUS_Soldier_GL",_pos,[],0,"none"];
{
 _x addeventhandler ["killed",{[_this] execVM "cash.sqf"}];
} foreach units _generalgrp;

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  

×