RonnieJ 10 Posted July 31, 2010 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
shuko 59 Posted July 31, 2010 RonnieJ said: 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. RonnieJ said: 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
intruder_ger 10 Posted July 31, 2010 Delete this clamps "",{[_this] execVM " or better write like below Quote general addeventhandler ["killed",{_this execVM "cash.sqf";}]; Regards Intruder Share this post Link to post Share on other sites
RonnieJ 10 Posted July 31, 2010 shk> ye that working with the eventhandler but how do I group units together? Quote _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
shuko 59 Posted July 31, 2010 _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
RonnieJ 10 Posted July 31, 2010 Thx m8 its working great! :) Share this post Link to post Share on other sites