OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Ext3rmin4tor on 23 Mar 2013, 19:39:00

Title: Disable direct vehicle command
Post by: Ext3rmin4tor on 23 Mar 2013, 19:39:00
I have a humvee whose driver is not in the player team. The player unit is the humvee gunner. I want to prevent the driver to assign direct commands like FORWARD, LEFT, etc. Do you know how to do that?

EDIT:
I managed to do that with actionKeys and display event handlers. You just return true with a custom display event handler script in the main display (code 46). Here's the script:

Code: [Select]
disableInput =
{
_r = false;
{

if ((_this select 1) in _x) exitWith
{
_r = true;
};
} forEach disabled_keys;
_r;
};

disabled_keys = [];
while {true} do
{
_up_keys = actionKeys "CommandForward";
_down_keys = actionKeys "CommandBack";
_left_keys = actionKeys "CommandLeft";
_right_keys = actionKeys "CommandRight";
_ff_keys = actionKeys "CommandFast";
_sf_keys = actionKeys "CommandSlow";
disabled_keys = [_up_keys,_down_keys,_left_keys,_right_keys,_ff_keys,_sf_keys];
if (movement_disabled) then
{
hint format ["%1", disabled_keys];
(findDisplay 46) displaySetEventHandler["keydown","_this call disableInput"];
(findDisplay 46) displaySetEventHandler["keyup","_this call disableInput"];
waitUntil{!movement_disabled};
}
else
{
(findDisplay 46) displaySetEventHandler["keydown",""];
(findDisplay 46) displaySetEventHandler["keyup",""];
disabled_keys = [];
waitUntil{movement_disabled};
};
sleep 0.01;
};