inGameUISetEventHandler: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "<code>([^<]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^<]*) *<\/code>" to "<code>$1$2$3</code>") |
Lou Montana (talk | contribs) m (Text replacement - "<sqf>([^↵][^<]*↵[^<]*)<\/sqf>" to "<sqf> $1 </sqf>") |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 31: | Line 31: | ||
{{Feature|arma3|Since {{arma3}} v1.50 the event handler receives an array of the selected/activated action's arguments in {{hl|_this}} variable: | {{Feature|arma3|Since {{arma3}} v1.50 the event handler receives an array of the selected/activated action's arguments in {{hl|_this}} variable: | ||
< | <sqf>params ["_target", "_caller", "_index", "_engineName", "_text", "_priority", "_showWindow", "_hideOnUse", "_shortcut", "_visibleMenu", "_eventName"];</sqf> | ||
* _target: [[Object]] - target object to which action is attached | * _target: [[Object]] - target object to which action is attached | ||
* _caller: [[Object]] - caller object, basically [[player]] | * _caller: [[Object]] - caller object, basically [[player]] | ||
Line 53: | Line 53: | ||
|r1= [[Nothing]] | |r1= [[Nothing]] | ||
|x1= < | |x1= <sqf> | ||
inGameUISetEventHandler ["Action", "hint 'Lights, Camera, Action!'; true"]; | |||
sleep 10; | sleep 10; | ||
inGameUISetEventHandler ["Action", ""]; // removes the "Action" EH</ | inGameUISetEventHandler ["Action", ""]; // removes the "Action" EH | ||
</sqf> | |||
|x2= < | |x2= <sqf> | ||
inGameUISetEventHandler ["PrevAction", "hint str _this; false"]; | |||
inGameUISetEventHandler ["NextAction", "hint str _this; false"]; | inGameUISetEventHandler ["NextAction", "hint str _this; false"]; | ||
inGameUISetEventHandler ["Action", "hint str _this; false"];</ | inGameUISetEventHandler ["Action", "hint str _this; false"]; | ||
</sqf> | |||
|x3= Deny any weapon disassembly: | |x3= Deny any weapon disassembly: | ||
< | <sqf> | ||
if (_this select 3 == 'DisAssemble') then | inGameUISetEventHandler ["Action", " | ||
if (_this select 3 == 'DisAssemble') then { | |||
hint 'You are not allowed to do this'; | hint 'You are not allowed to do this'; | ||
true | true | ||
} | } | ||
"];</ | "]; | ||
</sqf> | |||
|x4= Detect explosive/mine placement: | |x4= Detect explosive/mine placement: | ||
< | <sqf> | ||
private _onMagazineUse = ' | |||
params ["_target", "", "", "_action", "", "", "", "", "", "", "_event"]; | params ["_target", "", "", "_action", "", "", "", "", "", "", "_event"]; | ||
if (_action == "UseMagazine") then | if (_action == "UseMagazine") then { | ||
if (_event == "Action") then { | |||
if (_event == "Action") then | |||
_target spawn { | _target spawn { | ||
waitUntil {!(all_magazines isEqualTo magazines _this)}; | waitUntil {!(all_magazines isEqualTo magazines _this)}; | ||
Line 83: | Line 87: | ||
} count magazines _this; | } count magazines _this; | ||
hint format ["Magazine Used: %1", all_magazines select 0]; | hint format ["Magazine Used: %1", all_magazines select 0]; | ||
} | }; | ||
} | } else { | ||
all_magazines = magazines _target; | all_magazines = magazines _target; | ||
}; | }; | ||
Line 93: | Line 95: | ||
'; | '; | ||
inGameUISetEventHandler ["PrevAction", _onMagazineUse]; | inGameUISetEventHandler ["PrevAction", _onMagazineUse]; | ||
inGameUISetEventHandler ["NextAction", _onMagazineUse]; | |||
inGameUISetEventHandler ["Action", _onMagazineUse];</ | inGameUISetEventHandler ["Action", _onMagazineUse]; | ||
</sqf> | |||
|seealso= [[isActionMenuVisible]] [[addEventHandler]] [[ctrlAddEventHandler]] [[displayAddEventHandler]] [[actionIDs]] [[actionParams]] [[addAction]] [[setUserActionText]] [[showHUD]] [[inputAction]] [[removeAction]] [[removeAllActions]] [[action]] [[enableWeaponDisassembly]] | |seealso= [[isActionMenuVisible]] [[addEventHandler]] [[ctrlAddEventHandler]] [[displayAddEventHandler]] [[actionIDs]] [[actionParams]] [[addAction]] [[setUserActionText]] [[showHUD]] [[inputAction]] [[removeAction]] [[removeAllActions]] [[action]] [[enableWeaponDisassembly]] |
Latest revision as of 19:43, 3 September 2024
Description
- Description:
- Sets given event handler of in-game UI. If EH function returns true, performed action is overridden. Event handlers available are:
- "PrevAction" - mouse scroll up
- "Action" - action key press
- "NextAction" - mouse scroll down
- Groups:
- GUI Control - Event HandlersEvent HandlersInteraction
Syntax
- Syntax:
- inGameUISetEventHandler [handlerName, code]
- Parameters:
- handlerName: String
- code: String
- Return Value:
- Nothing
Examples
- Example 1:
- inGameUISetEventHandler ["Action", "hint 'Lights, Camera, Action!'; true"]; sleep 10; inGameUISetEventHandler ["Action", ""]; // removes the "Action" EH
- Example 2:
- inGameUISetEventHandler ["PrevAction", "hint str _this; false"]; inGameUISetEventHandler ["NextAction", "hint str _this; false"]; inGameUISetEventHandler ["Action", "hint str _this; false"];
- Example 3:
- Deny any weapon disassembly:
inGameUISetEventHandler ["Action", " if (_this select 3 == 'DisAssemble') then { hint 'You are not allowed to do this'; true } "];
- Example 4:
- Detect explosive/mine placement:
private _onMagazineUse = ' params ["_target", "", "", "_action", "", "", "", "", "", "", "_event"]; if (_action == "UseMagazine") then { if (_event == "Action") then { _target spawn { waitUntil {!(all_magazines isEqualTo magazines _this)}; { 0 = all_magazines deleteAt (all_magazines find _x); } count magazines _this; hint format ["Magazine Used: %1", all_magazines select 0]; }; } else { all_magazines = magazines _target; }; }; false '; inGameUISetEventHandler ["PrevAction", _onMagazineUse]; inGameUISetEventHandler ["NextAction", _onMagazineUse]; inGameUISetEventHandler ["Action", _onMagazineUse];
Additional Information
- See also:
- isActionMenuVisible addEventHandler ctrlAddEventHandler displayAddEventHandler actionIDs actionParams addAction setUserActionText showHUD inputAction removeAction removeAllActions action enableWeaponDisassembly
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
- Posted on May 12, 2016 - 20:51 (UTC)
- In case of the "Action" event, (_showWindow || _visibleMenu) also denotes if the action is performed or not. For example, if the action menu is closed or fading off, pressing Spacebar will bring it up and trigger an "Action" event; in that case, _visibleMenu is false. But if the action menu is open, and Spacebar is pressed to perform the selected action, then _visibleMenu will be true. If _showWindow is true, then it means the action was performed, regardless of _visibleMenu.
Categories:
- Scripting Commands
- Introduced with Armed Assault version 1.00
- ArmA: Armed Assault: New Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: GUI Control - Event Handlers
- Command Group: Event Handlers
- Command Group: Interaction
- Scripting Commands: Local Effect