Haymaker 13 Posted June 4, 2017 // _warlord is a unit classname, _position is a predetermined location, _group is a group (just clarifying) _warlord createUnit [_position, _group]; _cellLeader = nearestObject [_position, _warlord]; _cellLeader execVM "scripts\warlord.sqf"; warlord.sqf: _this addEventHandler ["killed", {success = success - 1; Hint "You have killed a cell leader";}]; Does absolutely nothing. I also tried adding the event handler to execute the script, with the script only containing the calculations (success = success - 1;). Not sure why I can't get this to work! All help is appreciated. Share this post Link to post Share on other sites
pierremgi 4624 Posted June 4, 2017 You need to apply the EH to an unit (or a vehicle). But your nearestObject (in this syntax) return a <null object>. You can try: (nearestObjects [_position, ["CAManBase"], 2]) select 0; or even better: _position nearEntities [_warlord,2] select 0; Why don't you use the first syntax for createUnit? You will not have to search for a nearest object. _cellLeader = _group createUnit [_warlord, _position,[],0,"NONE"]; _cellLeader addEventHandler ["killed", {code}]; 1 Share this post Link to post Share on other sites
Haymaker 13 Posted June 4, 2017 13 hours ago, pierremgi said: You need to apply the EH to an unit (or a vehicle). But your nearestObject (in this syntax) return a <null object>. You can try: (nearestObjects [_position, ["CAManBase"], 2]) select 0; or even better: _position nearEntities [_warlord,2] select 0; Why don't you use the first syntax for createUnit? You will not have to search for a nearest object. _cellLeader = _group createUnit [_warlord, _position,[],0,"NONE"]; _cellLeader addEventHandler ["killed", {code}]; Cheers! I'm going to have to credit you with all the help you've been giving me Share this post Link to post Share on other sites
killzone_kid 1326 Posted June 4, 2017 16 hours ago, Haymaker said: Does absolutely nothing. Works for me just fine Share this post Link to post Share on other sites
pierremgi 4624 Posted June 4, 2017 15 minutes ago, killzone_kid said: Works for me just fine Tested: Place a player + a unit named bob. Run myUnit = nearestObject [getPos bob,typeOf bob]; // or the position or bob and the class name (supposed to be the main syntax of this command) myUnit is just a null-object. The other syntax or commands I gave, work. Did I missed something? Share this post Link to post Share on other sites
killzone_kid 1326 Posted June 4, 2017 7 minutes ago, pierremgi said: Did I missed something? Your example works for me and I get bob returned with nearestObject. Share this post Link to post Share on other sites
pierremgi 4624 Posted June 4, 2017 Just now, killzone_kid said: Your example works for me and I get bob returned with nearestObject. Wow, strange! I'm on vanilla APEX 1.70 + all DLCs, (no mods at all), ALTIS airport, 2 BLUFOR, on runway, one player + bob. SP preview. Tested several times, even after some Arma restarts.... Always a null object (console or script). No problem with bob's position ([14875.9,16444.3,0.00143814]) or class ("B_soldier_AAT_F"). in watch lines: getpos bob nearEntities [typeOf bob,2] returns [bob] nearestObject [bob,"B_Soldier_AAT_F"] or nearestObject [getPos bob,typeOf bob] returns <NULL-object> Difficult to understand. Share this post Link to post Share on other sites
killzone_kid 1326 Posted June 4, 2017 3 minutes ago, pierremgi said: Difficult to understand "B_Soldier_AAT_F" is indeed not detected, try generic unit, something like "B_Soldier_F" 1 Share this post Link to post Share on other sites
pierremgi 4624 Posted June 4, 2017 10 minutes ago, killzone_kid said: "B_Soldier_AAT_F" is indeed not detected, try generic unit, something like "B_Soldier_F" Yep, that works for rifleman! As far as the position is a sharp reference for this command, the workaround here seems to be: nearestObject [bob,"CAManBase"]; Share this post Link to post Share on other sites