Difference between revisions of "DCS func addCommandForGroup"

From DCS World Wiki - Hoggitworld.com
m (1 revision imported)
 
 
(2 intermediate revisions by the same user not shown)
Line 47: Line 47:
 
|optType2=
 
|optType2=
  
|examples=  
+
|examples= The following iterates the table, finds their groupIds, and passes the groupName to the imLost function whenever someone from the group selects the F10 choice.
 +
  local function imLost(gName)
 +
  -- whatever
 +
  end
 +
  local tbl = {'group1', 'group2', 'group3', 'group4' ,'group5'}
 +
  for i = 1, #tbl do
 +
    if Group.getByName(tbl[i]) then
 +
      local groupId = Group.getByName(tbl[i]):getID()
 +
      missionCommands.addCommandForGroup(groupId, 'Halp', nil , imLost, tbl[i])
 +
    end
 +
  end
 
|related=  
 
|related=  
 
[[DCS_singleton_missionCommands|'''missionCommands Functions:''']] {{listOfMissionCommandFuncs}}
 
[[DCS_singleton_missionCommands|'''missionCommands Functions:''']] {{listOfMissionCommandFuncs}}
Line 53: Line 63:
 
}}
 
}}
 
[[Category:Singleton Functions|addCommandForGroup]]
 
[[Category:Singleton Functions|addCommandForGroup]]
 +
[[Category:Game Patch 1.2.4|addCommandForGroup]]

Latest revision as of 23:02, 5 September 2024

Scripting Root

Envrioment: Mission Scripting
Function: addCommandForGroup Added with: 1.2.4
Member Of: missionCommands
Syntax: table missionCommands.addCommandForGroup(number groupId , string name , table/nil path , function functionToRun , any anyArguement)
Description: Adds a command to the "F10 Other" radio menu allowing players to run specified scripting functions. Command is added for the specified groupId. The string name is the text that will be displayed in the F10 Other menu and is also used in the function to remove the command from the menu.

Path is an optional value that defines whether or not the command will be in a named submenu.

FunctionToCall is the name of the function, with the optional argument value designating any passed values.


Return Value: table
Return Example: none
Examples: The following iterates the table, finds their groupIds, and passes the groupName to the imLost function whenever someone from the group selects the F10 choice.
 local function imLost(gName)
  -- whatever
 end
 local tbl = {'group1', 'group2', 'group3', 'group4' ,'group5'}
 for i = 1, #tbl do
   if Group.getByName(tbl[i]) then
      local groupId = Group.getByName(tbl[i]):getID()
      missionCommands.addCommandForGroup(groupId, 'Halp', nil , imLost, tbl[i])
   end
 end
Related Functions: missionCommands Functions: addCommand, addSubMenu, removeItem, addCommandForCoalition, addSubMenuForCoalition, removeItemForCoalition, addCommandForGroup, addSubMenuForGroup, removeItemForGroup
Notes: See page on missionCommands.addCommand on information for the path and more examples.