exil Posted February 13 Share Posted February 13 Gents, i really feel stupid to ask again since i'm really a lua noob, but i don't seem to get on with what i'm triying to achieve. For now, I'm trying to send out a text message if a blue helicopter unit (will be a client) enters a zone. This is what i've got so far. But i doesn't work: local blueunits = mist.getUnitsInZones(mist.makeUnitTable({'[blue][helicopter]'}), {'ropezone1'}) -- return any blue helos inside "ropezone" for i = 1, #blueunits do if Unit.getByName(blueunits[i]) then local u = Unit.getByName(blueunits[i]) if u:getLife() > 1 then -- check if unit is alive trigger.action.outText( 'in der zone', 10 ) end end end I really don't know what i am doing wrong here. Link to post Share on other sites
exil Posted February 13 Author Share Posted February 13 Okay, so i found a way of doing it. I dumped the old script and looked after what MOOSE would be capable of (what a powerful tool!). It looks like this now: local MyZone = ZONE:New('ropezone1') local MySetGroup = SET_GROUP:New():FilterCoalitions('blue'):FilterCategoryGround():FilterStart() if MySetGroup:AnyInZone(MyZone) then MESSAGE:New("At least one GROUP has at least one UNIT in zone !", 10):ToAll() else MESSAGE:New("No UNIT of any GROUP is in zone !", 10):ToAll() end Does anyone know, if it's possible to run the script for more than one zone? I tried the following but without luck: local RopeZones = {'ropezone1', 'ropezone2'} local MyZone = ZONE:New(RopeZones) local MySetGroup = SET_GROUP:New():FilterCoalitions('blue'):FilterCategoryGround():FilterStart() if MySetGroup:AnyInZone(MyZone) then MESSAGE:New("At least one GROUP has at least one UNIT in zone !", 10):ToAll() else MESSAGE:New("No UNIT of any GROUP is in zone !", 10):ToAll() end I also tried local MyZone = ZONE:New({'ropezone1', 'ropezone2'}), but again, no joy. Link to post Share on other sites
toutenglisse Posted February 13 Share Posted February 13 With mist, example to get as much messages as there are units in ropezone1, naming units (it uses flag n°1 - change to one that is free, if n°1 is already used) : local blueunits = mist.makeUnitTable({'[blue][helicopter]'}) if #blueunits > 0 then for i = 1, #blueunits do mist.flagFunc.units_in_zones({ units = {'' .. blueunits[i]}, zones = {'ropezone1'}, flag = "1", toggle = true, }) if trigger.misc.getUserFlag("1") > 0 then trigger.action.outText('' .. blueunits[i] .. ' is in ropezone1', 10) end end end Example for 3 zones : local blueunits = mist.makeUnitTable({'[blue][helicopter]'}) if #blueunits > 0 then for i = 1, #blueunits do mist.flagFunc.units_in_zones({ units = {'' .. blueunits[i]}, zones = {'ropezone1', 'ropezone2', 'ropezone3'}, flag = "1", toggle = true, }) if trigger.misc.getUserFlag("1") > 0 then trigger.action.outText('' .. blueunits[i] .. ' is in ropezones', 10) end end end If you want messages to refer to specific zone you'll have to duplicate first exeample for each zone. Link to post Share on other sites
exil Posted February 14 Author Share Posted February 14 22 hours ago, toutenglisse said: With mist, example to get as much messages as there are units in ropezone1, naming units (it uses flag n°1 - change to one that is free, if n°1 is already used) : local blueunits = mist.makeUnitTable({'[blue][helicopter]'}) if #blueunits > 0 then for i = 1, #blueunits do mist.flagFunc.units_in_zones({ units = {'' .. blueunits[i]}, zones = {'ropezone1'}, flag = "1", toggle = true, }) if trigger.misc.getUserFlag("1") > 0 then trigger.action.outText('' .. blueunits[i] .. ' is in ropezone1', 10) end end end Example for 3 zones : local blueunits = mist.makeUnitTable({'[blue][helicopter]'}) if #blueunits > 0 then for i = 1, #blueunits do mist.flagFunc.units_in_zones({ units = {'' .. blueunits[i]}, zones = {'ropezone1', 'ropezone2', 'ropezone3'}, flag = "1", toggle = true, }) if trigger.misc.getUserFlag("1") > 0 then trigger.action.outText('' .. blueunits[i] .. ' is in ropezones', 10) end end end If you want messages to refer to specific zone you'll have to duplicate first exeample for each zone. That, sir, really helped me out a lot! Not only for my script I am tweaking at the moment but for so much more of my missions. Thank you very, very much! Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now