Jump to content

Message to Client (Unit) after changing slot?


Go to solution Solved by virgo47,

Recommended Posts

Posted

Hello mission creators.

I have a simplistic mission with a couple of planes set as Client on the approach for the landing. I'd like to display a different message for each just after I take control of the plane. I tried a few combinations of triggers and conditions, I can send a message to a unit, but it's far from my ideal, as I can either send it just once (not working for another spawn to the same unit) or repeatedly (annoying), etc.

  • The message should be shown each time I choose the slot, as it is another attempt for the landing (or whatever I'm trying to do).
  • The message is set for a long time and stays there through the change to another slot, but Clearview checkbox is fine for that.

I can easily do it Once per plane, using Unit Alive as a condition - but not repeatedly. Switched condition/Mission start does not work at all with this condition and Repetitive action repeats the message each second... which is bearable with Clearview, but still annoying as it blinks. And it would be even more annoying if I also wanted to play a short beep before the message (which I'd like).

Is there any simple solution or do I need to use some flags for this?

✈️ L-39, F-4E, F-5E, F-14, F/A-18C, MiG-15, F-86F, AJS-37, C-101, FC2024 🛩️ Yak-52, P-47, Spitfire, CE2 🚁 UH-1H, Mi-8, Ka-50 III, SA342 🗺️ NTTR, PG, SY, Chnl, Norm2, Kola, DE 📦 Supercarrier, NS430, WWII, CA 🕹️ VKB STECS+Gladiator/Kosmosima+TPR ▶️ DCS Unscripted YouTube 🐛 "Favourite" bugs: 1) Object local camera fast/slow inverted, 2) Yak-52 toggles not toggling, 3) all Caucasus ATC bugs

Posted (edited)
1 hour ago, virgo47 said:

Is there any simple solution or do I need to use some flags for this?

Well, you could get out the big guns 🙂 

Enclosed please find a quick demo that uses two 'valet' zones to greet different player units when they spawn in, and use "smart text" for customized messages that appear. To use in your own mission, simply adapt the trigger zone text.  

Here's how the mission will greet your units when the spawn in (depending on the zone)

image.png

This is the text the two valets use, note the 'smart text' in angled brackets that access unit and player info (click on the zones to inspect what they do, note the attributes in Mission Editor's trigger zone editor)

  • <player>, welcome to your <type>. fly 180 for 4, then contact Senaki Approach
  • <player>, welcome to your <type>. You are cleared for long final on Senaki.

Mission attached below. Uses DML.

 

 

you are welcome.miz

Edited by cfrag
  • Like 1
  • Thanks 1
Posted
1 hour ago, cfrag said:

Well, you could get out the big guns 🙂 

...

Thanks a lot, this looks very usable! I'll try to modify it to add clearview option, shouldn't be a problem for a programmer.

Although not what I meant by "simple" originally, this is self-contained, working well, etc. Thanks a lot. I've noticed DML before, but I thought it is overkill for my needs. But if it helps make simple things really simple.

✈️ L-39, F-4E, F-5E, F-14, F/A-18C, MiG-15, F-86F, AJS-37, C-101, FC2024 🛩️ Yak-52, P-47, Spitfire, CE2 🚁 UH-1H, Mi-8, Ka-50 III, SA342 🗺️ NTTR, PG, SY, Chnl, Norm2, Kola, DE 📦 Supercarrier, NS430, WWII, CA 🕹️ VKB STECS+Gladiator/Kosmosima+TPR ▶️ DCS Unscripted YouTube 🐛 "Favourite" bugs: 1) Object local camera fast/slow inverted, 2) Yak-52 toggles not toggling, 3) all Caucasus ATC bugs

Posted (edited)
28 minutes ago, virgo47 said:

I'll try to modify it to add clearview option, shouldn't be a problem for a programmer.

Try line 175 of valet and change it from

		trigger.action.outTextForUnit(ID, msg, dur)

to 

		trigger.action.outTextForUnit(ID, msg, dur, true)

That should do it

Edited by cfrag
Posted (edited)

Yeah, I made it to a trigger parameter. Another adjustment is to make a specific message per plane, not per zone. I have to check whether a zone per plane would help or if I need another solution. In my case, I want to print plane specific landing checklist. But these are all minor things.

Your mission example pushed me 99% of the way I guess. 😉

Edited by virgo47

✈️ L-39, F-4E, F-5E, F-14, F/A-18C, MiG-15, F-86F, AJS-37, C-101, FC2024 🛩️ Yak-52, P-47, Spitfire, CE2 🚁 UH-1H, Mi-8, Ka-50 III, SA342 🗺️ NTTR, PG, SY, Chnl, Norm2, Kola, DE 📦 Supercarrier, NS430, WWII, CA 🕹️ VKB STECS+Gladiator/Kosmosima+TPR ▶️ DCS Unscripted YouTube 🐛 "Favourite" bugs: 1) Object local camera fast/slow inverted, 2) Yak-52 toggles not toggling, 3) all Caucasus ATC bugs

Posted (edited)
4 minutes ago, virgo47 said:

Another adjustment is to make a specific message per plane, not per zone.

Well, of course you can make a zone per plane, I was just being lazy 🙂 - the problem with trigger-zone specific text like in DML is that the zone attribute editor is really, really inadequate for longer messages, so a script-approach would probably be the best: trap the 'birth' event,  check against the 'initiator' if its a player plane, and if so, provide the instructions by type. Should be a single short script to run at mission start, and if you want me to, I can hammer out a skeleton for you to fill thre rest in a few minutes - it's basic DCS stuff if you have done a million times, but an uncomfortable effort of trial and error if you are new to this rigmarole. 

Edited by cfrag
  • Like 1
Posted

You're very kind, @cfrag. I'll try on my own and if I get stuck, I'll write here. 🙂 I don't mind scripting per se, the problem is I'm totally lost in all those options. I'll try to use the pointers you gave me (e.g. the birth event) and we'll see how it goes. One would assume that player/client birth (or re-birth) would be some elementary event available from the editor, but many stuff I considered "basic" (e.g. setting up the plane instruments after the mission start) are quite complicated and virtually unavailable for casual editors. But I'll try to have a stab at it first and report on the result, hopefully soon.

✈️ L-39, F-4E, F-5E, F-14, F/A-18C, MiG-15, F-86F, AJS-37, C-101, FC2024 🛩️ Yak-52, P-47, Spitfire, CE2 🚁 UH-1H, Mi-8, Ka-50 III, SA342 🗺️ NTTR, PG, SY, Chnl, Norm2, Kola, DE 📦 Supercarrier, NS430, WWII, CA 🕹️ VKB STECS+Gladiator/Kosmosima+TPR ▶️ DCS Unscripted YouTube 🐛 "Favourite" bugs: 1) Object local camera fast/slow inverted, 2) Yak-52 toggles not toggling, 3) all Caucasus ATC bugs

Posted
Just now, virgo47 said:

One would assume that player/client birth (or re-birth) would be some elementary event available from the editor, but many stuff I considered "basic" (e.g. setting up the plane instruments after the mission start) are quite complicated and virtually unavailable for casual editors

Indeed. I think it will help to remember that DCS is a direct descendant from a 1990s game, and that the "mission" data structure and API were not designed; they happened to emerge whenever something was needed. So don't try to make sense of it. In case you don't have it already, here's the most important doc link. The information is valuable, and a great help. Being a third party labor of work, it's also a testament to this community. It's also correctish, but may require a healthy dose of experimenting. 

  • Thanks 1
  • Solution
Posted (edited)

The debugging was not very fast for a newbie in Lua (I used some online Lua demo for simple stuff, but some errors appear only during the mission load)... but I got what I want with the following script (Mission start trigger, obviously):

-- Let's call this "my library" of reusable stuff for the future.
dunlib = {}

-- duration in seconds
function dunlib.messageUnit(unitId, text, duration, clearView)
    trigger.action.outTextForUnit(unitId, text or "Undefined message!", duration or 10, clearView or false)
end

-- delay and duration in seconds
function dunlib.messageUnitDelayed(unitId, text, delay, duration, clearView)
    timer.scheduleFunction(function() dunlib.messageUnit(unitId, text, duration, clearView) end, {}, timer.getTime() + (delay or 2))
end

-- cm = current mission
cm = {}

-- Just a small demo of messages for a few planes.
cm.messageTable = {}
cm.messageTable["L-39C"] = [[
Hi kursant... get it down without any damage, will you?
]]
cm.messageTable["L-39ZA"] = cm.messageTable["L-39C"]
cm.messageTable["F-15C"] = [[
Fly, Eagle, Fly! ... Oh, I mean land, actually...]]

function cm.defaultIntroMessage(event)
    return "Sorry, no instructions for " .. event.initiator:getTypeName() .. ".\n" ..
        "Get it down somehow..."
end

function cm:onEvent(event)
    if event.id ~= 20 then
        -- We only want a "player enter unit" event:
        -- https://wiki.hoggitworld.com/view/DCS_event_player_enter_unit
        return
    end

    dunlib.messageUnitDelayed(event.initiator:getID(),
        cm.messageTable[event.initiator:getTypeName()] or cm.defaultIntroMessage(event),
        3, 600, true) -- 3s delay, show for 10 mins, true for clearing previous messages
end

world.addEventHandler(cm)

I didn't use DML for this after all, but I'd not get there this quickly without your pointers. Thank you very much for the directions.

Edited by virgo47

✈️ L-39, F-4E, F-5E, F-14, F/A-18C, MiG-15, F-86F, AJS-37, C-101, FC2024 🛩️ Yak-52, P-47, Spitfire, CE2 🚁 UH-1H, Mi-8, Ka-50 III, SA342 🗺️ NTTR, PG, SY, Chnl, Norm2, Kola, DE 📦 Supercarrier, NS430, WWII, CA 🕹️ VKB STECS+Gladiator/Kosmosima+TPR ▶️ DCS Unscripted YouTube 🐛 "Favourite" bugs: 1) Object local camera fast/slow inverted, 2) Yak-52 toggles not toggling, 3) all Caucasus ATC bugs

Posted
11 hours ago, virgo47 said:

In my case, I want to print plane specific landing checklist.

 

For that case, you might want to put the checklists on a Kneeboard inside the MIZ file, as it can have sections that only show for a specific aircraft type, for example have a miz file with the following directories inside:

 KNEEBOARD\IMAGES
 KNEEBOARD\FA-18C_hornet\IMAGES
 KNEEBOARD\F-16C_50\IMAGES

 

The images on IMAGE will show on the kneeboard of every client aircraft, for example the Server Rules. The images on F-16C_50 will show only on F-16 clients, etc.

 

  • Thanks 1

 

For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra

For Gaming: 34" Monitor - Ryzen 3600 - 32 GB DDR4 2400 - nVidia RTX2080 - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar

Mobile: iPad Pro 12.9" of 256 GB

Posted
7 hours ago, Rudel_chw said:

For that case, you might want to put the checklists on a Kneeboard inside the MIZ file, as it can have sections that only show for a specific aircraft type, for example have a miz file with the following directories inside:

 KNEEBOARD\IMAGES
 KNEEBOARD\FA-18C_hornet\IMAGES
 KNEEBOARD\F-16C_50\IMAGES

Thanks @Rudel_chw for mentioning this. I know about plane-specific kneeboards and use them, but I wanted it as a message. I haven't used mission(+plane)-specific kneeboards yet, perhaps I'll consider it in the future. In this case, I like that message is condensed compared to a kneeboard.

  • Like 1

✈️ L-39, F-4E, F-5E, F-14, F/A-18C, MiG-15, F-86F, AJS-37, C-101, FC2024 🛩️ Yak-52, P-47, Spitfire, CE2 🚁 UH-1H, Mi-8, Ka-50 III, SA342 🗺️ NTTR, PG, SY, Chnl, Norm2, Kola, DE 📦 Supercarrier, NS430, WWII, CA 🕹️ VKB STECS+Gladiator/Kosmosima+TPR ▶️ DCS Unscripted YouTube 🐛 "Favourite" bugs: 1) Object local camera fast/slow inverted, 2) Yak-52 toggles not toggling, 3) all Caucasus ATC bugs

  • Recently Browsing   0 members

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