D. Patterson 14 Posted November 9, 2014 As soon as a player gets in a boat, I want to enable a hotkey to run a script. As soon as the player leaves the boat, it runs the script again (Without them having to hit the hotkey). displaySetEventHandler makes no sense to me and I cant even get it to work with simple hint scripts and no conditions. Google doesn't produce any helpful answers either. I'd like to avoid triggers or waitUntils if possible. Share this post Link to post Share on other sites
dreadedentity 278 Posted November 9, 2014 (edited) Display event handlers are fun. Really fun, even. In this case, it would be much easier to just use an addAction, though. Check this out: [] spawn { while {true} do { waitUntil {(typeOf(vehicle(player))) == "BOAT_CLASSNAME"}; _hotKey = player addAction ["", { 0 = [] execVM "myScript.sqf"; }, 6, [], false, true, "User20", "(typeOf(vehicle(player))) == 'BOAT_CLASSNAME'"]; waitUntil {(vehicle(player)) == player}; player removeAction _hotkey; 0 = [] execVM "myScript.sqf"; }; }; All you have to do is replace BOAT_CLASSNAME with the boat classname (duh), and set a key for User Action 20 in your keybindings. Anytime a player hits that key, the script will run. ---------- Post added at 20:04 ---------- Previous post was at 19:51 ---------- I'd like to avoid ... waitUntils if possible. Not sure why, but if it's really that big of an issue, there is a workaround using "GetIn" & "GetOut" event handlers. player addEventHandler ["GetIn", { if ((_this select 1) == "driver" && {typeOf(_this select 0) == "BOAT_CLASSNAME"}) then { _hotKey = (_this select 2) addAction ["", { 0 = [] execVM "myScript.sqf"; }, 6, [], false, true, "User20", "(typeOf(vehicle(player))) == 'BOAT_CLASSNAME'"]; missionNamespace setVariable ["hotKeyAction", _hotKey]; }; }]; player addEventHandler ["GetOut", { if ((_this select 1) == "driver" && {typeOf(_this select 0) == "BOAT_CLASSNAME"}) then { if !(isNil {missionNamespace getVariable "hotKeyAction"}) then { (_this select 2) removeAction (missionNamespace getVariable "hotKeyAction"); missionNamespace setVariable ["hotKeyAction", nil]; }; 0 = [] execVM "myScript.sqf"; }; }]; (Since there are still a few broken things in Arma, and as I do not know the current operational state of the "GetIn" & "GetOut" event handlers, I will not be held liable for broken code/game crashes resultant from use of provided examples) Edited November 9, 2014 by DreadedEntity Share this post Link to post Share on other sites
killzone_kid 1331 Posted November 9, 2014 player addeventhandler ["getin/getout... Have you tried this yourself? Share this post Link to post Share on other sites
iceman77 18 Posted November 9, 2014 Was probably an honest mistake. I doubt he tried what he posted because it's pseudo code and doesn't even have real class names. Share this post Link to post Share on other sites
dreadedentity 278 Posted November 9, 2014 player addeventhandler ["getin/getout... Have you tried this yourself? I'll admit that I spent way too long looking at this post and figuring out why you thought this wouldn't work. I shouldn't get on the computer when I'm drinking Share this post Link to post Share on other sites