Run script with key press

To share and ask questions about Arma code, scripts, mods, and missions.

Moderator: VileAce

Post Reply
User avatar
VileAce
Site Admin
Posts: 1071
Joined: April 6th, 2017, 1:00 pm
Location: North Carolina

NAK Command

NAK Tac

NAK Elite

NAK Donor

August 5th, 2018, 8:40 am

I was ask to share information about how to run a script using a key press. The best way for me to explain it is to provide links to existing information available on the internet. After reviewing that information if you have specific questions we can discuss it here.

This first link is a BI forum post and has great examples and links to other relevant information. I would start here, specifically comments from stuguy: https://forums.bohemia.net/forums/topic ... e-scripts/

This is a link to the BI function to watch for the keypress and run code when activated:
https://community.bistudio.com/wiki/dis ... entHandler

This link is to CBA documentation related to their keybinding system. Most developers prefer using the CBA keybinding: https://github.com/CBATeam/CBA_A3/wiki/Keybinding

This last link is to CBA documentation related to keybinding, there is additional information on the left hand menu on this CBA site:
https://cbateam.github.io/CBA_A3/docs/f ... d-sqf.html

These links are not specific but are general keypress info:
https://community.bistudio.com/wiki/actionKeys
https://community.bistudio.com/wiki/DIK_KeyCodes
https://community.bistudio.com/wiki/inputAction/actions
https://community.bistudio.com/wiki/Arm ... eysMapping

User avatar
VileAce
Site Admin
Posts: 1071
Joined: April 6th, 2017, 1:00 pm
Location: North Carolina

NAK Command

NAK Tac

NAK Elite

NAK Donor

August 5th, 2018, 11:19 am

As an example the view distance script in all of the Zeus missions, CHVD, has both standard keybindings and CBA keybindings as well as a CBA custom menu.

onibuke
Posts: 3
Joined: May 18th, 2018, 4:34 pm

NAK Tac

August 5th, 2018, 1:06 pm

For the user who wanted the info, there's also the addAction command. https://community.bistudio.com/wiki/addAction

It's not quite a keypress, but adds to the action menu (like the menu where the "open door" action is)

For external scripts:

Code: Select all

_actionID = player addAction ["Exec the file", "scriptFile.sqf"];
Or code into the addAction command directly:

Code: Select all

_actionID = player addAction ["This is the name of the action", { hint "Hello World!"; player setDamage 1; }];

In-game name: Luke

User avatar
VileAce
Site Admin
Posts: 1071
Joined: April 6th, 2017, 1:00 pm
Location: North Carolina

NAK Command

NAK Tac

NAK Elite

NAK Donor

August 5th, 2018, 1:52 pm

TY for the info. The developer is a more advanced coder and is aware of add action, add action is not a practical option in this case.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users