Stuka Posted August 24, 2014 Posted August 24, 2014 Does somebody now how I achieve to send a message to all groups (all client groups) that are present in a certain zone? That without having to make lot of simultaneous triggers that would do that. So something along the lines of: get_all_groups_in_zone_1 foreach sendmsg Windows 11 | i9 12900KF | 64GB DDR4 | RTX 3090 | TM Warthog HOTAS | Saitek Combat Rudder Pedals | TM MFDs + Lilliput 8" | TIR5 Pro
Bushmanni Posted August 25, 2014 Posted August 25, 2014 Here's a function that does the job. Example usage: msgToGrpsInZone({'client1','client2'}, {"TheZone"}, "This is the message!") Note, 'client1' is the pilot name of the client plane. The function uses mist unit name table shortcuts and you can use multiple zones in the zone table. msgDelay = 60; function msgToGrpsInZone(unitNames, zoneNameTable, msg) unitNameTable = mist.makeUnitTable(unitNames); local unitTable = {}; unitTable = mist.getUnitsInZones(unitNameTable, zoneNameTable); for index, unit in pairs(unitTable) do local grpId = unit:getGroup():getID(); trigger.action.outTextForGroup(grpId, msg, msgDelay) end; end; 1 DCS Finland: Suomalainen DCS yhteisö -- Finnish DCS community -------------------------------------------------- SF Squadron
Stuka Posted August 25, 2014 Author Posted August 25, 2014 Thanks! I'll give it a try later on. Can I fill the unittable also with all clients from a certain coalition? (Instead of naming hem all) Windows 11 | i9 12900KF | 64GB DDR4 | RTX 3090 | TM Warthog HOTAS | Saitek Combat Rudder Pedals | TM MFDs + Lilliput 8" | TIR5 Pro
Bushmanni Posted August 25, 2014 Posted August 25, 2014 Unit name table shortcuts don't have that kind of feature unfortunately. On the other hand it's relatively simple to make a function that builds a table of unitnames that contain certain string like "client". strNameTable('client') would return unitnames/pilotnames of all units that contain word 'client'. Used with the previous function it would look like msgToGrpsInZone(strNameTable('client'), {"TheZone"}, "This is the message!"). There could be a direct way of finding out if the unit is a client or AI but I'm unfamiliar with that. function strNameTable(targetStr) local unitNameTable = {}; for key, unit in pairs(mist.DBs.unitsByName) do if string.find(unit.unitName, targetStr) then unitNameTable[#unitNameTable + 1] = unit.unitName; end; end; return unitNameTable; end; DCS Finland: Suomalainen DCS yhteisö -- Finnish DCS community -------------------------------------------------- SF Squadron
Recommended Posts