disableUserInput: Difference between revisions

From Bohemia Interactive Community
m (Text replacement - " +" to " ")
m (Some wiki formatting)
 
(28 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| ofp
|game1= ofp
|version1= 1.00


|1.00
|game2= ofpe
|version2= 1.00
 
|game3= arma1
|version3= 1.00
 
|game4= arma2
|version4= 1.00
 
|game5= arma2oa
|version5= 1.50
 
|game6= tkoh
|version6= 1.00
 
|game7= arma3
|version7= 0.50


|gr1= Interaction
|gr1= Interaction
Line 9: Line 26:
|eff= local
|eff= local


| Disables or enables the keyboard and mouse input. Usually used during cutscenes.{{Feature | Warning | Be careful and responsible with the usage of this command. Once the user input is disabled, the only option left is to restart the game. Make sure you provide scripted mechanics to resolve this, should you need to disable user input for any reason.}}
|descr= Disables or enables the keyboard and mouse input. Usually used during cutscenes.{{Feature|warning|Be careful and responsible with the usage of this command. Once the user input is disabled, the only option left is to restart the game. Make sure you provide scripted mechanics to resolve this, should you need to disable user input for any reason.}}


| '''disableUserInput''' state
|s1= [[disableUserInput]] state


|p1= state: [[Boolean]] - [[true]] to disable, [[false]] to enable
|p1= state: [[Boolean]] - [[true]] to disable, [[false]] to enable


|r1=[[Nothing]]
|r1= [[Nothing]]


|x1= <code>[[disableUserInput]] [[true]];
|x1= <sqf>
disableUserInput true;
// cutscene
// cutscene
[[disableUserInput]] [[false]];</code>
disableUserInput false;
</sqf>


|seealso= [[userInputDisabled]], [[enableSimulation]], [[enableSimulationGlobal]]
|x2= Reset user input if a key was pressed:
}}
<sqf>
disableUserInput true; // here e.g W was pressed
sleep 2; // the user releases keys
disableUserInput false; // the game considers W is still pressed as it did not listen to a "KeyUp" event


<dl class="command_description">
disableUserInput true;
<dt></dt>
disableUserInput false; // this resets released keys making the issue invisible
<dd class="notedate">Posted on 14 March 2014</dd>
<dt class="note>'''[[User:Killzone_Kid|Killzone_Kid]]'''
<dd class="note">
Sometimes, when [[disableUserInput]] [[true]] command is invoked while the user is holding a button, when [[disableUserInput]] [[false]] is called and the user is no longer holding the button, the input will resume as if the user is still holding the button. To reset this behaviour, disable and enable user input again in the same frame:
<code>[[disableUserInput]] [[true]];
//do something
[[disableUserInput]] [[false]];
[[disableUserInput]] [[true]];
[[disableUserInput]] [[false]];</code>
Unfortunately, if the user is moving mouse when [[disableUserInput]] [[true]] command is invoked, the mouse input will get stuck for the whole duration of disabled user input but will reset as soon as [[disableUserInput]] [[false]] is called. I was unable to find workaround for this one.
<br><br>
UPDATE: There is now [[userInputDisabled]] command, which allows one to check if user input is still disabled after enabling it, so that one can retry until enabling is successful.
</dl>


// this workaround does not fix the mouse input that may get stuck on [[disableUserInput]] call
</sqf>


{{GameCategory|arma1|Scripting Commands}}
|seealso= [[userInputDisabled]] [[enableSimulation]] [[enableSimulationGlobal]]
{{GameCategory|arma2|Scripting Commands}}
}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}

Latest revision as of 16:35, 13 April 2025

Hover & click on the images for description

Description

Description:
Disables or enables the keyboard and mouse input. Usually used during cutscenes.
Be careful and responsible with the usage of this command. Once the user input is disabled, the only option left is to restart the game. Make sure you provide scripted mechanics to resolve this, should you need to disable user input for any reason.
Groups:
Interaction

Syntax

Syntax:
disableUserInput state
Parameters:
state: Boolean - true to disable, false to enable
Return Value:
Nothing

Examples

Example 1:
Copy
disableUserInput true; // cutscene disableUserInput false;
Example 2:
Reset user input if a key was pressed:
Copy
disableUserInput true; // here e.g W was pressed sleep 2; // the user releases keys disableUserInput false; // the game considers W is still pressed as it did not listen to a "KeyUp" event disableUserInput true; disableUserInput false; // this resets released keys making the issue invisible // this workaround does not fix the mouse input that may get stuck on disableUserInput call

Additional Information

See also:
userInputDisabled enableSimulation enableSimulationGlobal

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note