Raptor6872 Posted January 11, 2021 Share Posted January 11, 2021 Greetings All, I was making a script that will allow specific groups access to given options for the F10 Menu in multiplayer. In this example there are 4 groups, (e.g. XX-DRAGON-1-1-XX, ...) as seen in the code below. When the mission starts, I 'DO SCRIPT FILE' and run the following code to no avail. ------------------------------------------------------------------ -- CustomLUA F10 Menu for Specific Groups -- ------------------------------------------------------------------ ------------------------------------------------------------------ -- https://wiki.hoggitworld.com/view/DCS_func_addCommandForGroup -- https://wiki.hoggitworld.com/view/DCS_func_addSubMenu -- https://wiki.hoggitworld.com/view/DCS_func_addSubMenuForGroup ------------------------------------------------------------------ local function successSound() -- Run when called trigger.action.outSound("1-success.wav") -- Play sound end local function failureSound() trigger.action.outSound("2-failure.wav") end local tbl = {"XX-DRAGON-1-1-XX", "XX-DRAGON-1-2-XX", "XX-DRAGON-1-3-XX", "XX-DRAGON-1-4-XX"} -- List of group names to get menu access for i = 1, #tbl do if Group.getByName(tbl[i]) then local groupId = Group.getByName(tbl[i]):getID local adminM = missionCommands.addSubMenuForGroup(groupId, 'ADMIN MENU') local soundM = missionCommands.addSubMenuForGroup(groupId, 'Play Sounds', adminM) missionCommands.addCommandForGroup(groupId, 'Success', soundM , successSound, tbl[i]) missionCommands.addCommandForGroup(groupId, 'Failure', soundM , failureSound, tbl[i]) end end This code is based off of several links and I'm not quite sure why it does not work. When run in game, after joining the unit of said group, the menu never even shows up... Any ideas? DRAGON 1-3 | Raptor [i7-7700K OC 5 GHz CPU | 32 GB DDR4 RAM | RTX 2070S GPU w/ 4GB] Link to comment Share on other sites More sharing options...
scrapple Posted January 11, 2021 Share Posted January 11, 2021 If you're running the script with a MISSION START trigger, trying changing that to a ONCE trigger with say a TIME MORE(5) condition. Also, in this statement: local groupId = Group.getByName(tbl[i]):getID you may need a set of parentheses at the end, like so: local groupId = Group.getByName(tbl[i]):getID() Link to comment Share on other sites More sharing options...
Chump Posted January 12, 2021 Share Posted January 12, 2021 local groupId = Group.getByName(tbl[i]):getID() You missed the parentheses on the getID() function. At least, that was what stuck out to me at first glance. Check the DCS log for more information. Link to comment Share on other sites More sharing options...
Hardcard Posted January 12, 2021 Share Posted January 12, 2021 Aside from the missing parenthesis, the script might not be fully protected against nil errors caused by missing groups. I doubt that this line alone will cut it, since it might return true even if the groups aren't actually present (just having them listed in the mission database is enough, I think): if Group.getByName(tbl[i]) then To make sure, I'd use :isExist() instead (or in addition to it) if Group.getByName(tbl[i]) and Group.getByName(tbl[i]):isExist() then [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Recommended Posts