Jump to content

Recommended Posts

Posted

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. 

 

GeForce RTX 4090 Founders Edition - AMD Ryzen 7 5800X3D - 64Gb RAM - Win11 - HP Reverb G1 - Thrustmaster Warthog HOTAS (40cm extension) - VKB Sim T-Rudder MKIV Pedals

Posted

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.

GeForce RTX 4090 Founders Edition - AMD Ryzen 7 5800X3D - 64Gb RAM - Win11 - HP Reverb G1 - Thrustmaster Warthog HOTAS (40cm extension) - VKB Sim T-Rudder MKIV Pedals

Posted

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.

Posted
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! 

GeForce RTX 4090 Founders Edition - AMD Ryzen 7 5800X3D - 64Gb RAM - Win11 - HP Reverb G1 - Thrustmaster Warthog HOTAS (40cm extension) - VKB Sim T-Rudder MKIV Pedals

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...