SyB 0 Posted March 5, 2007 Hi Guys, I have successfully attached a script to an 'Action' and then to a Keyborad Key. Do get this to work you have to create a new 'Action' for the particular unit using the 'addAction' scripting command in it's 'new' full format. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ActionId = <unit> addAction[action, script, argument, priority, showWindow, hideOnUse, shortcut]; ActionId, <unit>, action, script are all as previously used with addAction command. argument = a variable for using to pass additional parameter(s) to your given script. priority = Not 100% sure, but I think this is what priority the engine gives to 'broadcasting' this 'action' out over the network. Higher values = greater importance. showWindow = Some of the default actions have a graphic associated with them and/or text. This True/False parameter designates if this is shown or not. hideOnUse = Think this just means... When this action is run hide the text or graphic immediately, either True/False. Now, this is the IMPORTANT one !! shortcut = One of the actions defind in the class 'CfgDefaultKeysMapping' which is in the bin.pbo. So, my objective is to disable the default action that happens when I press the <Space Bar> on my keyboard. Currently this key is mapped to 'ForceCommandingMode' by default in 'CfgDefaultKeysMapping' in the bin.pbo. If you have not previously altered this mapping under Options>Controls while playing the game then there will also be a mapping for this in your Playername.cfg file. REMOVE, the mapping for 'ForceCommandingMode' either while ingame in Options>Controls or by editing your Playername.cfg file. There are keys defined in ArmA for use when running in 'Buldozer' mode. (Which we can't use as yet.) Make sure your 'Buldozer Select' action under Options>Controls IS mapped to the <Space Bar>. Anyhoo, map your units 'new' action to the 'CfgDefaultKeysMapping' action called 'buldSelect'. eg. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">actionId = Sy addAction["Jump","scripts\Jump.sqf","",1,false,false,"buldSelect"]; If you had used 'ForceCommandingMode' in place of 'buldSelect' in the above addAction command, then when you hit <space bar> in the game it would do both both the 'Command Mode' function AND run your script... which is a bit yuck really. Please excuse any bad spelling or what not... Cheers, Sy Share this post Link to post Share on other sites
sickboy 13 Posted March 5, 2007 Very Very Nice Find! ... I guess we can add our own functions to the keymappings by adding them in the config etc? (Anyone tried?). BTW in Kegetys his new spectator there are also buttons connected to functions, haven't looked yet if these are done the same by addaction. Share this post Link to post Share on other sites
Donnervogel 0 Posted March 5, 2007 I tried to add new entries in the config but as expected they have no effect. The possible key bindings (in the controls menu) seem to be hardcoded. What Kegetys used is displaySetEventHandler but afaik they only work when there is no user input on the unit one is controling (like when there are dialogs). Share this post Link to post Share on other sites
KeyCat 131 Posted March 5, 2007 Nice one, thanks for sharing SyB! /KC Share this post Link to post Share on other sites