Jump to content

Recommended Posts

Posted
Place this in a function when you're done with JTAC:

MenuTop_2:Remove()

 

However, keep in mind that you'll need to create the nested menu structure again from scratch, if you plan on using it later

 

No, not really, because if someone uses JTAC2, this menu will disappear for the rest. I want to put four JTACs in this menu and only after spawn all menus have to disappear.

Specialization A-10C

https://vbw304.pl/

Posted
Hello

How to remove the main menu after deleting all submenus

 

MenuTop_2 = MENU_COALITION:New( coalition.side.BLUE, "JTAC" )
JTAC_1 = MENU_COALITION_COMMAND:New( coalition.side.BLUE, "Jtac KN53", MenuTop_2, function()
ctld.JTACAutoLase('JTAC1', 1666, true,"all", 3)
JTAC_1:Remove( 1, nil ) end, nil)
JTAC_2 = MENU_COALITION_COMMAND:New( coalition.side.BLUE, "Jtac MM24", MenuTop_2, function()
ctld.JTACAutoLase('JTAC2', 1667, true,"all", 1)
JTAC_2:Remove( 1, nil ) end, nil)

 

It's about the remaining empty menu "MenuTop_2"

 

 

You asked how to remove the main menu, specifically, "MenuTop_2" AFTER removing all submenus... and I told you how to do it. ;)

 

You didn't mention anything about keeping the submenus, quite the opposite.

 

Also, I warned you:

However, keep in mind that you'll need to create the nested menu structure again from scratch, if you plan on using it later

 

Formulate your questions properly, please...otherwise we'll enter a "vicious circle" :)

 

 

 

So you want a main menu with 4 submenus in it, right?

 

Menu_Top_2 
        JTAC_1
        JTAC_2
        JTAC_3
        JTAC_4

 

Is this meant for SP or MP missions?

 

When do you want each of the submenus to be removed? Directly after execution?

 

If you delete them directly after execution, other clients won't have access to them until the whole nested menu structure is created again.

 

In that case, you might want to use group menus instead of coalition menus.

 

Describe what you want to do, EXACTLY, otherwise you won't get the answers to the specific problems you're having.

Posted

It is supposed to be so that if someone chooses, for example, JTAC_2, it will be removed.

Menu_Top_2

JTAC_1

JTAC_3

JTAC_4

The menu is still there anyway, I want it after removing all:

Menu_Top_2

 

And now only after removing all has the main menu disappear.

For example, it can only be 'JTA_1', the menu must be. The order of removal is accidental, depending on the needs of the players.

I'm sorry how I explained the case wrong.:doh:

Specialization A-10C

https://vbw304.pl/

Posted (edited)

My answer is still the same as before, then:

MenuTop_2:Remove()

 

BUT, you need to create a logic structure that will "detect" the presence of submenus and decide whether to remove MenuTop_2 or create it again, depending on the situation.

 

Something like this (check that the two extra JTAC menu functions have the correct autolase parameters. Use "Enable JTAC Menus" F10 menu to generate the JTAC menus):

 

 

MenuTop_2_Status = "Disabled"

JTAC_1_Status = "Disabled"

JTAC_2_Status = "Disabled"

JTAC_3_Status = "Disabled"

JTAC_4_Status = "Disabled"

 

 

 

function JTAC_1_Command()

 

ctld.JTACAutoLase('JTAC1', 1666, true,"all", 3)

JTAC_1:Remove( 1, nil )

JTAC_1_Status = "Disabled"

 

if JTAC_1_Status == "Disabled" and JTAC_2_Status == "Disabled" and JTAC_3_Status == "Disabled" and JTAC_4_Status == "Disabled" then

 

if MenuTop_2 then

MenuTop_2:Remove()

MenuTop_2_Status = "Disabled"

end

end

end

 

 

 

function JTAC_2_Command()

 

ctld.JTACAutoLase('JTAC2', 1667, true,"all", 1)

JTAC_2:Remove( 1, nil )

JTAC_2_Status = "Disabled"

 

if JTAC_1_Status == "Disabled" and JTAC_2_Status == "Disabled" and JTAC_3_Status == "Disabled" and JTAC_4_Status == "Disabled" then

 

if MenuTop_2 then

MenuTop_2:Remove()

MenuTop_2_Status = "Disabled"

end

end

end

 

 

 

function JTAC_3_Command()

 

ctld.JTACAutoLase('JTAC3', 1668, true,"all", 1) -- Make sure that the autolase parameters are correct for JTAC_3

JTAC_3:Remove( 1, nil )

JTAC_3_Status = "Disabled"

 

if JTAC_1_Status == "Disabled" and JTAC_2_Status == "Disabled" and JTAC_3_Status == "Disabled" and JTAC_4_Status == "Disabled" then

 

if MenuTop_2 then

MenuTop_2:Remove()

MenuTop_2_Status = "Disabled"

end

end

end

 

 

 

function JTAC_4_Command()

 

ctld.JTACAutoLase('JTAC4', 1668, true,"all", 1) -- Make sure that the autolase parameters are correct for JTAC_4

JTAC_4:Remove( 1, nil )

JTAC_4_Status = "Disabled"

 

if JTAC_1_Status == "Disabled" and JTAC_2_Status == "Disabled" and JTAC_3_Status == "Disabled" and JTAC_4_Status == "Disabled" then

 

if MenuTop_2 then

MenuTop_2:Remove()

MenuTop_2_Status = "Disabled"

end

end

end

 

 

 

 

function Create_MenuTop_2()

 

MenuTop_2 = MENU_COALITION:New( coalition.side.BLUE, "JTAC" )

JTAC_1 = MENU_COALITION_COMMAND:New( coalition.side.BLUE, "Jtac KN53", MenuTop_2, JTAC_1_Command)

JTAC_2 = MENU_COALITION_COMMAND:New( coalition.side.BLUE, "Jtac MM24", MenuTop_2, JTAC_2_Command)

JTAC_3 = MENU_COALITION_COMMAND:New( coalition.side.BLUE, "Jtac X", MenuTop_2, JTAC_3_Command) -- Give it any name you want

JTAC_4 = MENU_COALITION_COMMAND:New( coalition.side.BLUE, "Jtac Y", MenuTop_2, JTAC_4_Command) -- Give it any name you want

 

MenuTop_2_Status = "Enabled"

JTAC_1_Status = "Enabled"

JTAC_2_Status = "Enabled"

JTAC_3_Status = "Enabled"

JTAC_4_Status = "Enabled"

 

JTAC_Enabler_Root:Remove()

 

end

 

 

 

SCHEDULER:New( nil,

function()

 

if MenuTop_2_Status == "Disabled" and JTAC_1_Status == "Disabled" and JTAC_2_Status == "Disabled" and JTAC_3_Status == "Disabled" and JTAC_4_Status == "Disabled" then

 

JTAC_Enabler_Root = MENU_COALITION:New( coalition.side.BLUE, "Enable JTAC Menus" )

MenuTop_2_Create = MENU_COALITION_COMMAND:New( coalition.side.BLUE, "Create MenuTop_2", JTAC_Enabler_Root, Create_MenuTop_2)

 

end

end, {}, 1, 60

)

 

 

Edited by Hardcard
Posted (edited)

@Hardcard

 

Thank you, a great robot is just a solution.

 

I am working on a training ground for the forum in which I operate.

This will be very helpful, because I base many things on the menu and can not be overcrowded.

 

I wanted to use the script from this post: https://forums.eagle.ru/showthread.php?t=185436

 

to activate the slots after taking over the airport, but it does not work anymore.

Maybe there is another solution ?

Edited by hancerPL

Specialization A-10C

https://vbw304.pl/

Posted

It still works fine. There is not another script for this, it's a server hook, not a mission script.

 

@Hardcard

 

Thank you, a great robot is just a solution.

 

I am working on a training ground for the forum in which I operate.

This will be very helpful, because I base many things on the menu and can not be overcrowded.

 

I wanted to use the script from this post: https://forums.eagle.ru/showthread.php?t=185436

 

to activate the slots after taking over the airport, but it does not work anymore.

Maybe there is another solution ?

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Posted

I wrote a small script that activates radio units bombarding the selected target.

This works as "Alert 5", the group accepts the challenge and goes to intercept the target.

The whole is to be based on confirmation by the group of accepting the call as if the selection menu disappears.

The problem is that it should appear again after the contracted time (here 60 seconds for testing), but the message is only the menu no longer returns.

 

Bomb_1 = GROUP:FindByName("Bomber #001")
local Bomber_Atak_1 = SCHEDULER:New( nil, 
 function()if Bomb_1:IsAlive() then        
   SCHEDULER:Stop( Bomber_Atak_1 )
    else        
local Bomber_Atak_2 = SCHEDULER:New( nil, 
 function()
   Player_1 = GROUP:FindByName("Enfield")
local Player_Menu = SCHEDULER:New( nil, 
 function()
   if Player_1:IsAlive() then
             trigger.action.outTextForCoalition(coalition.side.BLUE, 'WARNING !!! \n  Hostile bombers flying towards our airport', 10)                 
    Player1 = MENU_GROUP_COMMAND:New( Player_1, "I confirm I am engaged in bombers", Player1, function()                  Bomb_1:Activate()
           Player1:Remove( 1, nil ) end)
               local Bomber_Atak_Timer = SCHEDULER:New( nil, function()
                   Player1:Remove( 1, nil ) end, {}, 20 )                    
                           end                       
                       end, {}, 1 )  
                   end, {}, 1 ) 
               end 
       end, {}, 1, 60 )

 

:helpsmilie:

Specialization A-10C

https://vbw304.pl/

Posted
I wrote a small script that activates radio units bombarding the selected target.

 

By "radio units" you mean late activated AI units?

 

This works as "Alert 5", the group accepts the challenge and goes to intercept the target.

 

What's "Alert 5"?

Also, when you say "the group", is it supposed to be Player_1 group?

 

 

The whole is to be based on confirmation by the group of accepting the call as if the selection menu disappears.

 

Sorry, what? :huh:

 

 

The problem is that it should appear again after the contracted time (here 60 seconds for testing), but the message is only the menu no longer returns.

 

Again, sorry, what? :huh:

 

 

Can you write the post in Polish and add the text in a spoiler or something?

I think I'll be able to understand you better that way. :thumbup:

Posted
I think there's a push function that you need to use, no?

 

 

You were absolutely correct! You need to use: GROUP:Route(route, delay) to push the changes to the waypoints, where 'route' is a table of ALL the waypoints. But I was getting DCS crashes or the GROUP just sitting on the tarmac and never starting up it's engines...

 

Took me a few days of stepping away from the problem to finally figure it out...

 

 

I was only passing the single changed waypoint to the Route() function. As soon as I passed the entire route, it worked flawlessly.:doh:

 

 

Thanks for the response and the help. You definitely pointed me in the right direction.

Wayz Out

 

 

Intel Core i9 9900K | ASUS ROG Strix Z390E Gaming MB | G.Skill Ripjaws V 32gb DDR4-3200 | GeForce RTX 2080 Ti | Samsung 970 EVO Plus NVMe

HTC Vive Pro VR | Logitech G x56 HOTAS | Logitech G PRO Pedals

Posted

Ok.

1. Losowo ustawiam atak bombowy, aktywowany z menu

2. Wybrana grupa dostaję powiadomienie o ataku.

3. Jeżeli może (ma dość paliwa i amunicji) przyjmuję zlecenie i aktywuje atak.

4. Jednostka bombowa wyłącza skrypt do czasu jej zniszczenia lub lądowania.

5. Jeżeli nie menu jest kasowane.

6. Skrypt się jakby resetuję i powraca za po pewnym czasie.

That's the plan, it's hard to do it.

Specialization A-10C

https://vbw304.pl/

Posted (edited)

That's the plan, it's hard to do it

 

Nah, it's not hard, just takes a bit of work and planning.

 

 

Just to make sure we're on the same page here:

 

 

1. Randomly set a bomb attack, activated from the menu
1. Losowo ustawiam atak bombowy, aktywowany z menu

 

So, you want clients to have access to an F10 menu command, which generates AI bombing strikes randomly, is that it?

 

Should this F10 menu command be available for all clients in the coalition or just for a specific set of clients?

 

 

2. The selected group gets a notification of the attack.
2. Wybrana grupa dostaję powiadomienie o ataku.

 

You mean the specific client group that activated the F10 menu command, right?

 

 

3. If it can (it has enough fuel and ammunition) accept the order and activate the attack.
3. Jeżeli może (ma dość paliwa i amunicji) przyjmuję zlecenie i aktywuje atak.

 

Do you need actual fuel and ammo checks in the script or would you rather let the player decide whether to accept the intercept mission?

 

Letting the player decide would make things much simpler, that way we would only need to create a basic F10 menu structure.

 

 

4. The bomb unit disables the script until it is destroyed or landed.
4. Jednostka bombowa wyłącza skrypt do czasu jej zniszczenia lub lądowania.

 

By "wyłącza skrypt" you mean that all the relevant menus must be removed and nothing else must happen until the bombers are either destroyed or land, right?

 

 

5. If no menu is deleted.
5. Jeżeli nie menu jest kasowane.

 

If no menu is deleted... then what? We jump to 6?

I'm not sure I understand what you meant here.

 

 

6. The script seems to be reset and returns after some time.
6. Skrypt się jakby resetuję i powraca za po pewnym czasie.

 

Let's see if I understood... you want the whole thing to be reset after a given amount of time, in the event that the bomber group isn't activated?

 

 

Edited by Hardcard
Posted (edited)

I think that we will understand each other, sorry for my poor English language.

1. This is to be random attacks in the range of 30 to 240 hours.

Only for F / A-18C, F-14, M-200C aircraft, located in the air (eg above 5000ft).

2. Menu F-10 notifications for aircraft from point 2.

3. We do not check the amount of fuel, etc. The player decides by F10 to accept the order and

activates the attacking unit.

4. Yes, the script did not work until the 'Attack' unit was destroyed or discharged.

After unloading it must be removed.

5. The F10 menu for these selected airplanes is only active for a certain period of time. If none of

the players accepts the menu order disappears and the script resets.

6. Point 5 describes that if no player takes the order, the script resets and returns to point 1.

 

By the way, I was looking but I can not find:

if any unit, eg blue, is in the zone ...

same as: if Group:IsCompletelyInZone( ZoneA ) then.....

but for the blue coalition.

Greetings

 

P.S Mission will be set up 24/7 and reset every 6 hours, which is why I care about the effect of surprise while not burdening the server.

If you want, it will send you the whole script from the mission on priv

Edited by hancerPL

Specialization A-10C

https://vbw304.pl/

Posted (edited)
sorry for my poor English language.

 

No need to apologize, Polish and English are very different languages.

 

As for the rest:

 

1. This is to be random attacks in the range of 30 to 240 hours.

 

You meant 30 to 240 minutes, right?

 

2. Menu F-10 notifications for aircraft from point 2.

 

This means F/A-18C, F-14 and M-2000C flying above 5000ft ... right?

 

4. Yes, the script did not work until the 'Attack' unit was destroyed or discharged.

After unloading it must be removed.

 

So we do nothing until the bomber is destroyed or... discharged / unloaded?

 

What do you mean by discharged / unloaded? Remaining bombs = 0 ?

 

Also, do we need to remove the menu or the bomber? (Or both?)

 

 

By the way, I was looking but I can not find:

if any unit, eg blue, is in the zone ...

same as: if Group:IsCompletelyInZone( ZoneA ) then.....

but for the blue coalition.

 

You can either create a SET_GROUP with a coalition filter in it and then check it using an iterator...

BlueSET = SET_GROUP:New():FilterCoalitions("blue"):FilterStart()

CheckZone = ZONE:New("[color="red"]Name of the Zone in ME[/color]")

BlueSET:ForEachGroupAlive(
function(Bluegroup) 

if Bluegroup:IsCompletelyInZone(CheckZone) then
   
   [color="Blue"]-- Do stuff[/color]

end
end
)

 

 

...or simply use a multiple condition check

 

CheckGroup = GROUP:FindByName("[color="Red"]Name of the group in ME[/color]")
CheckZone = ZONE:New("[color="red"]Name of the Zone in ME[/color]")

if CheckGroup:IsCompletelyInZone(CheckZone) and CheckGroup:GetCoalition() == coalition.side.BLUE then

[color="Blue"]-- Do stuff[/color]

end

 

 

 

Sure, feel free to send me the mission file and any scripts that you're using, see if I can make sense of it :thumbup:

Edited by Hardcard
Posted (edited)

@hancerPL

 

Ok, I've put this together, it should meet your requirements (haven't tested it, though, modifications might be required)

 

You need to create a late-activated strike group in ME and give it a bombing task there. The number of units in that strike group must be specified in the script

Btw, the script can be modified to work with several randomly selected strike groups, but I decided to keep things simple.

As it's written, it will only work with a single late-activated strike group (it has 100 spawns available, so the whole thing can be repeated).

 

Also, I assumed that the F/A-18C, F-14 and M-2000C clients would be in the Blue coalition, so the script will only work with Blue.

If those clients are included in the Red coalition, you'll need to change all instances of coalition.side.BLUE to coalition.side.RED

 

Clients will have 5 minutes to accept the bomber interception, if they don't , their menu will be removed.

 

The bomber interception task will be made available to the clients periodically... I've randomized the scheduler repeat time (any number of seconds between 1800 and 14400, ie between 30 and 240 minutes)

 

You only need to introduce the group name of the late-activated strike group in ME and the number of units it contains (the required fields are marked in red, coalition enumerators marked in magenta):

 

Interception = "Clear"

local Bomber_Spawn = SPAWN:New("[color="red"]Name of the late-activated strike group in ME[/color]")
:InitLimit([color="Red"]number of units[/color] ,100)
:OnSpawnGroup(
function(BomberGroup) 

   BomberGroup:HandleEvent(EVENTS.Dead)
  
   function BomberGroup:OnEventDead(EventData)
     
      if BomberGroup:IsAlive() == nil then
     
         local ClientSET_Ded = SET_CLIENT:New():FilterActive(Active):FilterOnce()
    
         for i , Client in pairs( ClientSET_Ded:GetSetObjects() ) do 
     
            local TypeName_Ded = Client:GetTypeName()
            local Coalition_Ded = Client:GetCoalition()
            local Group_Ded = Client:GetGroup()
  
            if TypeName_Ded == "F-14B" or TypeName_Ded == "FA-18C_hornet" or TypeName_Ded == "M-2000C" then
      
               if Coalition_Ded == [color="Magenta"]coalition.side.BLUE[/color] then
      
                  MESSAGE:New("Bombers have been destroyed, stand down",10):ToGroup(Group_Ded)
                  
                  Interception = "Clear"
            
               end
            end
         end  
      end
   end
  
  
  BomberGroup:HandleEvent(EVENTS.EngineShutdown)
  
  function BomberGroup:OnEventEngineShutdown(EventData)
  
    local InitiatorUnit = EventData.IniUnit
    local InitiatorGroup = EventData.IniGroup
    local InitiatorVelocity = InitiatorUnit:GetVelocityKMH()
     
     if InitiatorGroup == BomberGroup and InitiatorVelocity == 0 then
          
        InitiatorUnit:Destroy(true)
          
     end
  end
end
)


local function InterceptionStart(Group)

     Interception = "Accepted"

     Bomber_Spawn:Spawn()
     
     BomberStrike_Root:Remove()
     
     MESSAGE:New(Group:GetName().." is intercepting the bombers!",10):ToCoalition([color="Magenta"]coalition.side.BLUE[/color])

end


local function BomberStrikeRemove()

  if Interception ~= "Accepted" then
     BomberStrike_Root:Remove()
  end 
end


SCHEDULER:New( nil, 
function()

local ClientSET = SET_CLIENT:New():FilterActive(Active):FilterOnce()

for i , Client in pairs( ClientSET:GetSetObjects() ) do 
   
   local TypeName = Client:GetTypeName()
   local Altitude = Client:GetAltitude()
   local Coalition = Client:GetCoalition()
   local Group = Client:GetGroup()
  
   if TypeName == "F-14B" or TypeName == "FA-18C_hornet" or TypeName == "M-2000C" then
      
      if Altitude > 1500 and Coalition == [color="magenta"]coalition.side.BLUE[/color] and Interception == "Clear" then
   
         MESSAGE:New("WARNING !!!\nHostile bombers flying towards our airport\n\n***Bomber Interception menu created***",10):ToGroup(Group)
         
         BomberStrike_Root = MENU_GROUP:New( Group, "Bomber Interception" )
         BomberStrike_Accept = MENU_GROUP_COMMAND:New( Group, "Confirm!", BomberStrike_Root, InterceptionStart, Group)
      
         timer.scheduleFunction(BomberStrikeRemove, nil , timer.getTime() + 300)
      end
   end
end

end, {}, 1, math.random(1800, 14400)
)

 

Let me know how it goes :thumbup:

Edited by Hardcard
Posted
Does anyone use AirBoss ?

 

It doesn't work for me, other Moose script functions work.

 

Did you download the development branch of Moose?

9800X3D,  MSI 5080 , G.SKILL 64GB DDR5-6000, Win 11, MSI X870, 2/4TB nVME, Quest 3, OpenHornet Pit 

Posted
@hancerPL

 

Ok, I've put this together, it should meet your requirements (haven't tested it, though, modifications might be required)

 

You need to create a late-activated strike group in ME and give it a bombing task there. The number of units in that strike group must be specified in the script

Btw, the script can be modified to work with several randomly selected strike groups, but I decided to keep things simple.

As it's written, it will only work with a single late-activated strike group (it has 100 spawns available, so the whole thing can be repeated).

 

Also, I assumed that the F/A-18C, F-14 and M-2000C clients would be in the Blue coalition, so the script will only work with Blue.

If those clients are included in the Red coalition, you'll need to change all instances of coalition.side.BLUE to coalition.side.RED

 

Clients will have 5 minutes to accept the bomber interception, if they don't , their menu will be removed.

 

The bomber interception task will be made available to the clients periodically... I've randomized the scheduler repeat time (any number of seconds between 1800 and 14400, ie between 30 and 240 minutes)

 

You only need to introduce the group name of the late-activated strike group in ME and the number of units it contains (the required fields are marked in red, coalition enumerators marked in magenta):

 

Interception = "Clear"

local Bomber_Spawn = SPAWN:New("[color="red"]Name of the late-activated strike group in ME[/color]")
:InitLimit([color="Red"]number of units[/color] ,100)
:OnSpawnGroup(
function(BomberGroup) 

   BomberGroup:HandleEvent(EVENTS.Dead)
  
   function BomberGroup:OnEventDead(EventData)
     
      if BomberGroup:IsAlive() == nil then
     
         local ClientSET_Ded = SET_CLIENT:New():FilterActive(Active):FilterOnce()
    
         for i , Client in pairs( ClientSET_Ded:GetSetObjects() ) do 
     
            local TypeName_Ded = Client:GetTypeName()
            local Coalition_Ded = Client:GetCoalition()
            local Group_Ded = Client:GetGroup()
  
            if TypeName_Ded == "F-14B" or TypeName_Ded == "FA-18C_hornet" or TypeName_Ded == "M-2000C" then
      
               if Coalition_Ded == [color="Magenta"]coalition.side.BLUE[/color] then
      
                  MESSAGE:New("Bombers have been destroyed, stand down",10):ToGroup(Group_Ded)
                  
                  Interception = "Clear"
            
               end
            end
         end  
      end
   end
  
  
  BomberGroup:HandleEvent(EVENTS.EngineShutdown)
  
  function BomberGroup:OnEventEngineShutdown(EventData)
  
    local InitiatorUnit = EventData.IniUnit
    local InitiatorGroup = EventData.IniGroup
    local InitiatorVelocity = InitiatorUnit:GetVelocityKMH()
     
     if InitiatorGroup == BomberGroup and InitiatorVelocity == 0 then
          
        InitiatorUnit:Destroy(true)
          
     end
  end
end
)


local function InterceptionStart(Group)

     Interception = "Accepted"

     Bomber_Spawn:Spawn()
     
     BomberStrike_Root:Remove()
     
     MESSAGE:New(Group:GetName().." is intercepting the bombers!",10):ToCoalition([color="Magenta"]coalition.side.BLUE[/color])

end


local function BomberStrikeRemove()

  if Interception ~= "Accepted" then
     BomberStrike_Root:Remove()
  end 
end


SCHEDULER:New( nil, 
function()

local ClientSET = SET_CLIENT:New():FilterActive(Active):FilterOnce()

for i , Client in pairs( ClientSET:GetSetObjects() ) do 
   
   local TypeName = Client:GetTypeName()
   local Altitude = Client:GetAltitude()
   local Coalition = Client:GetCoalition()
   local Group = Client:GetGroup()
  
   if TypeName == "F-14B" or TypeName == "FA-18C_hornet" or TypeName == "M-2000C" then
      
      if Altitude > 1500 and Coalition == [color="magenta"]coalition.side.BLUE[/color] and Interception == "Clear" then
   
         MESSAGE:New("WARNING !!!\nHostile bombers flying towards our airport\n\n***Bomber Interception menu created***",10):ToGroup(Group)
         
         BomberStrike_Root = MENU_GROUP:New( Group, "Bomber Interception" )
         BomberStrike_Accept = MENU_GROUP_COMMAND:New( Group, "Confirm!", BomberStrike_Root, InterceptionStart, Group)
      
         timer.scheduleFunction(BomberStrikeRemove, nil , timer.getTime() + 300)
      end
   end
end

end, {}, 1, math.random(1800, 14400)
)

 

Let me know how it goes :thumbup:

 

Thank you, tested works. However, as you wrote, you can give to several groups. It would be nice to bet with three bombers from different directions, so that players do not fall into the routine. It will be useful to modify the script for three groups of bombers. Of course, only one group would start at this random time. Great script you helped me a lot.

Specialization A-10C

https://vbw304.pl/

Posted (edited)

@hancerPL

 

I'm glad the script runs fine.

 

As for making it work with 3 randomly selected bomber groups, it's quite simple to set up.

 

Just need to copy-paste the Bomber_Spawn declaration a couple of times, change the bomber group names and declare the number of planes in each of them.

 

Then create a table containing the 3 bomber group declarations / variables and use a randomizer to select them for spawning when the clients give the command.

 

Like this (required values marked in red):


local Bomber_1_Spawn = SPAWN:New("[color="Red"]Name of the first bomber group in ME[/color]")
:InitLimit([color="red"]number of planes in the first group[/color] , 100)
:OnSpawnGroup(
function(BomberGroup) 

   BomberGroup:HandleEvent(EVENTS.Dead)
  
   function BomberGroup:OnEventDead(EventData)
     
      if BomberGroup:IsAlive() == nil then
     
         local ClientSET_Ded = SET_CLIENT:New():FilterActive(Active):FilterOnce()
    
         for i , Client in pairs( ClientSET_Ded:GetSetObjects() ) do 
     
             local TypeName_Ded = Client:GetTypeName()
             local Coalition_Ded = Client:GetCoalition()
             local Group_Ded = Client:GetGroup()
  
             if TypeName_Ded == "F-14B" or TypeName_Ded == "FA-18C_hornet" or TypeName_Ded == "M-2000C" then
      
                if Coalition_Ded == coalition.side.BLUE then
      
                   MESSAGE:New("Bombers have been destroyed, stand down",10):ToGroup(Group_Ded)
            
                end
             end
          end  
       end
   end
   
   BomberGroup:HandleEvent(EVENTS.EngineShutdown)
  
  function BomberGroup:OnEventEngineShutdown(EventData)
  
    local InitiatorUnit = EventData.IniUnit
    local InitiatorGroup = EventData.IniGroup
    local InitiatorVelocity = InitiatorUnit:GetVelocityKMH()
     
     if InitiatorGroup == BomberGroup and InitiatorVelocity == 0 then
          
        InitiatorUnit:Destroy(true)
          
     end
  end
end
)



local Bomber_2_Spawn = SPAWN:New("[color="red"]Name of the second bomber group in ME[/color]")
:InitLimit([color="red"]number of planes in the second group[/color] , 100)
:OnSpawnGroup(
function(BomberGroup) 

   BomberGroup:HandleEvent(EVENTS.Dead)
  
   function BomberGroup:OnEventDead(EventData)
     
      if BomberGroup:IsAlive() == nil then
     
         local ClientSET_Ded = SET_CLIENT:New():FilterActive(Active):FilterOnce()
    
         for i , Client in pairs( ClientSET_Ded:GetSetObjects() ) do 
     
             local TypeName_Ded = Client:GetTypeName()
             local Coalition_Ded = Client:GetCoalition()
             local Group_Ded = Client:GetGroup()
  
             if TypeName_Ded == "F-14B" or TypeName_Ded == "FA-18C_hornet" or TypeName_Ded == "M-2000C" then
      
                if Coalition_Ded == coalition.side.BLUE then
      
                   MESSAGE:New("Bombers have been destroyed, stand down",10):ToGroup(Group_Ded)
            
                end
             end
          end  
       end
   end
  
  
  BomberGroup:HandleEvent(EVENTS.EngineShutdown)
  
  function BomberGroup:OnEventEngineShutdown(EventData)
  
    local InitiatorUnit = EventData.IniUnit
    local InitiatorGroup = EventData.IniGroup
    local InitiatorVelocity = InitiatorUnit:GetVelocityKMH()
     
     if InitiatorGroup == BomberGroup and InitiatorVelocity == 0 then
          
        InitiatorUnit:Destroy(true)
          
     end
  end
end
)


local Bomber_3_Spawn = SPAWN:New("[color="red"]Name of the third bomber group in ME[/color]")
:InitLimit([color="red"]number of planes in the third group[/color] , 100)
:OnSpawnGroup(
function(BomberGroup) 

   BomberGroup:HandleEvent(EVENTS.Dead)
  
   function BomberGroup:OnEventDead(EventData)
     
      if BomberGroup:IsAlive() == nil then
     
         local ClientSET_Ded = SET_CLIENT:New():FilterActive(Active):FilterOnce()
    
         for i , Client in pairs( ClientSET_Ded:GetSetObjects() ) do 
     
             local TypeName_Ded = Client:GetTypeName()
             local Coalition_Ded = Client:GetCoalition()
             local Group_Ded = Client:GetGroup()
  
             if TypeName_Ded == "F-14B" or TypeName_Ded == "FA-18C_hornet" or TypeName_Ded == "M-2000C" then
      
                if Coalition_Ded == coalition.side.BLUE then
      
                   MESSAGE:New("Bombers have been destroyed, stand down",10):ToGroup(Group_Ded)
            
                end
             end
          end  
       end
   end
  
  
  BomberGroup:HandleEvent(EVENTS.EngineShutdown)
  
  function BomberGroup:OnEventEngineShutdown(EventData)
  
    local InitiatorUnit = EventData.IniUnit
    local InitiatorGroup = EventData.IniGroup
    local InitiatorVelocity = InitiatorUnit:GetVelocityKMH()
     
     if InitiatorGroup == BomberGroup and InitiatorVelocity == 0 then
          
        InitiatorUnit:Destroy(true)
          
     end
  end
end
)


local Bomber_Spawn_Table = { Bomber_1_Spawn , Bomber_2_Spawn , Bomber_3_Spawn } [color="blue"]-- This table contains the three bomber group declarations / variables that we've written above[/color]


local function InterceptionStart(Group)

     Interception = "Accepted"

     Bomber_Spawn_Table[math.random(1,3)]:Spawn() [color="Blue"]-- This will randomly select one of the bomber group variables from the table above and spawn the defined bomber group within it[/color]
     
     BomberStrike_Root:Remove()

end


local function BomberStrikeRemove()

  if Interception ~= "Accepted" then
     BomberStrike_Root:Remove()
  end 
end


SCHEDULER:New( nil, 
function()

local ClientSET = SET_CLIENT:New():FilterActive(Active):FilterOnce()

for i , Client in pairs( ClientSET:GetSetObjects() ) do 
   
   local TypeName = Client:GetTypeName()
   local Altitude = Client:GetAltitude()
   local Coalition = Client:GetCoalition()
   local Group = Client:GetGroup()
  
   if TypeName == "F-14B" or TypeName == "FA-18C_hornet" or TypeName == "M-2000C" then
      
      if Altitude > 1500 and Coalition == coalition.side.BLUE then
   
          --  if MenuTop_2_Status == "Disabled" and JTAC_1_Status == "Disabled" and JTAC_2_Status == "Disabled" and JTAC_3_Status == "Disabled" and JTAC_4_Status == "Disabled" then
         MESSAGE:New("WARNING !!!\nHostile bombers flying towards our airport\n\n***Bomber Interception menu created***",10):ToGroup(Group)
         
         BomberStrike_Root = MENU_GROUP:New( Group, "Bomber Interception" )
         BomberStrike_Accept = MENU_GROUP_COMMAND:New( Group, "Confirm!", BomberStrike_Root, InterceptionStart, Group)
      
         timer.scheduleFunction(BomberStrikeRemove, nil , timer.getTime() + 300)
      end
   end
end

end, {}, 1, math.random(1800, 14400)
)

Edited by Hardcard
Posted

Hi, I'm trying to add score to a mission I'm creating.

I have the main mission LUA script in a separate file and I'm loading the scores a few seconds later in a separate file.

 

 

However, the F10 scoring menu does not appear unless I do not relog with a different slot.

Is there any workaround for this or am I (probably) doing something wrong?

 

This is the scoring file and it is loaded 5 seconds after the main mission LUA script.

SukhumiZone = ZONE:FindByName( "SUKHUMI ZONE" )
GudautaZone = ZONE:FindByName( "GUDAUTA ZONE" )

-- SCORING
CaucasusPendulumScore = SCORING:New( "Caucasus Pendulum" )
CaucasusPendulumScore:SetScaleDestroyScore( 100 )
CaucasusPendulumScore:SetScaleDestroyPenalty( 200 )
CaucasusPendulumScore:AddZoneScore(SukhumiZone, 20)
CaucasusPendulumScore:AddZoneScore(GudautaZone, 20)
CaucasusPendulumScore:SetMessagesHit()
CaucasusPendulumScore:SetMessagesDestroy()
CaucasusPendulumScore:SetMessagesToAll()

SCORING_MENU_SCHEDULER = SCHEDULER:New(nil,
 function()
   for PlayerName, PlayerUnit in pairs( _DATABASE:GetPlayerUnits() ) do 
       CaucasusPendulumScore:_AddPlayerFromUnit( PlayerUnit )
       CaucasusPendulumScore:SetScoringMenu( PlayerUnit:GetGroup() )
   end
 end, {}, 5, 10, 0.2 )

env.info("Caucasus Pendulum Scores loaded ...")
trigger.action.outText("Caucasus Pendulum Scores loaded ...", 10)

 

 

thanks in advance for any help ;)

Posted (edited)

However, the F10 scoring menu does not appear unless I do not relog with a different slot.

 

If SCORING relies on birth events (which I think is the case), that would explain the issue.

 

This isn't a MOOSE problem but a DCS one... for some reason, birth events don't trigger the very first time a player joins a mission.

 

In order to work around this issue you need to join Spectators the very first time you enter the mission... you're free to choose any coalition / slot you want after that, birth events will trigger fine from that point on

Edited by Hardcard
Posted
If SCORING relies on birth events (which I think is the case), that would explain the issue.

 

This isn't a MOOSE problem but a DCS one... for some reason, birth events don't trigger the very first time a player joins a slot.

 

In order to work around this issue you need to join Spectators the very first time you enter the mission... you're free to choose any coalition / slot you want after that, birth events will trigger fine from that point on

 

 

Thank you for the explanation :thumbup:

Guess that I will have to update the documentation in the mission I'm making.

  • Recently Browsing   0 members

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