Grenadier ITF 6 Posted January 10, 2020 As the title suggests I can't pass the _target variable._target = _this select 0; _id=(findDisplay 46) displayAddEventHandler ["KeyDown", "if(_this select 1==22)then {_nul =[_target] execVM 'koc.sqf'};"]; any suggestions would be welcome :)) Share this post Link to post Share on other sites
Mr H. 402 Posted January 10, 2020 Target has to be defined within the scope of your event handler action. You can store/retrieve it in missionnamespace for example. It depends on what type of data you are trying to pass. 2 Share this post Link to post Share on other sites
Larrow 2819 Posted January 10, 2020 Or store _target on the display using setVariable, then retrieve it from the display inside the EH. Rather than using a global variable. Spoiler _target = _this select 0; findDisplay 46 setVariable[ "TAG_target", _target ]; _id = findDisplay 46 displayAddEventHandler[ "KeyDown", { params[ "_display", "_keyCode", "_shft", "_ctr", "_alt" ]; if ( _keyCode == 22 ) then { _target = _display getVariable "TAG_target"; _nul = [ _target ] execVM 'koc.sqf'; }; }]; 2 1 Share this post Link to post Share on other sites
Grenadier ITF 6 Posted January 10, 2020 16 minutes ago, Larrow said: Or store _target on the display using setVariable, then retrieve it from the display inside the EH. Rather than using a global variable. Hide contents _target = _this select 0; findDisplay 46 setVariable[ "TAG_target", _target ]; _id = findDisplay 46 displayAddEventHandler[ "KeyDown", { params[ "_display", "_keyCode", "_shft", "_ctr", "_alt" ]; if ( _keyCode == 22 ) then { _target = _display getVariable "TAG_target"; _nul = [ _target ] execVM 'koc.sqf'; }; }]; thanks. tried but without success. from the koc.sqf file variable not defined Share this post Link to post Share on other sites
Grenadier ITF 6 Posted January 10, 2020 22 minutes ago, Mr H. said: Target has to be defined within the scope of your event handler action. You can store/retrieve it in missionnamespace for example. It depends on what type of data you are trying to pass. the target is an object, vehicle, unit or other Share this post Link to post Share on other sites
Grenadier ITF 6 Posted January 10, 2020 Resolved. thank you guys _target = _this select 0; missionNamespace setVariable ["YourString",_target]; _id=(findDisplay 46) displayAddEventHandler ["KeyDown", "if(_this select 1==22)then { _target = missionNamespace getVariable 'YourString'; _nul =[_target] execVM 'koc.sqf'};"]; DONE! Share this post Link to post Share on other sites
pierremgi 4836 Posted January 10, 2020 Then, same as: YourString = _this select 0; _id=(findDisplay 46) displayAddEventHandler ["KeyDown", { if(_this select 1==22)then { [YourString] execVM "koc.sqf" }; }]; 1 Share this post Link to post Share on other sites