cpt_milkeye Posted August 22, 2023 Share Posted August 22, 2023 I can't figure it out and maybe somebody can help - I have two planes (either 1 player one AI or both players), set for immortal and unlimited guns. I am trying to display hits, or count them - keep score - but it seems that once a hit happens, it doesn't count the second. It should be simple enough but it's beyond me. Thanks. Link to comment Share on other sites More sharing options...
Solution Tom Kazansky Posted August 22, 2023 Solution Share Posted August 22, 2023 (edited) @cpt_milkeye LATE EDIT: the attached mission is not the correct mission bc of an upload mistake of mine. I added the correct one with my post on Friday 25th (v 05.04.05) I've been using exactly what you described for a number of years. There is only 1 thing the mission (not the script) adds: As soon as the "health" of a plane reaches zero, it gets vulnerable and you can kill it. For "unlimited" training just set the health to 1000 or more. I like to see a burning bandit at the end of the day, so I like this feature. I did not create the hitcounter script. Just found in in the WWW 2017 and AFAIR I did not change more than variable names, if any. So I don't take credits for the script. I never shared it btw. until totaday. (end of disclaimer ) So here it is: customEventHandler = {}; function customEventHandler:onEvent(event) if (world.event.S_EVENT_HIT == event.id) then local target = "unknown"; if event.target:getCategory() == Object.Category.UNIT then if event.target:getPlayerName() then target = event.target:getPlayerName(); elseif event.target:getName() then target = event.target:getName(); end; end; if (target == "Pilot Red" and trigger.misc.getUserFlag("1") >0) then local hits = trigger.misc.getUserFlag("1") -1; trigger.action.setUserFlag("1", hits); elseif (target == "ice" and trigger.misc.getUserFlag("2") >0) then local hits = trigger.misc.getUserFlag("2") -1; trigger.action.setUserFlag("2", hits); end; end; end; world.addEventHandler(customEventHandler); Here is my mission where I added the output and other little things. To adjust the "Health-Points" of the enemy plane and your own, simply edit the 2nd and 3rd trigger values in the ME. I'm German, so they are called "F1 Gegner-Leben" (="Enemy-Lifes") and "F2 Player-Leben" ("Player-Lifes"). default is: F1 = 30, F2 =10 Because I do my weapons trainings 99% of the time on the Nevada Map (NTTR) I only have the mission for that map. And I use the F/A-18C for both planes in this version of the miz. (see attachment) EDIT: the names of the pilots/units are important for the script. So mine is "ice" and the enemy is called "Pilot Red". EDIT2: I use the stable version of DCS 2.8.7.42718 which (today) is 1 version behind. Hope that doesn't matter. ice 05.04.04 AA Training FA-18 vs. X (LUA-hit-counter works).miz Edited August 25, 2023 by Tom Kazansky 1 Link to comment Share on other sites More sharing options...
Tom Kazansky Posted August 22, 2023 Share Posted August 22, 2023 I've found the source of the code right here in the forums and, after all those years, I want to thank you @Bushmanni for a lot of fun with this method of A2A-training! Link to comment Share on other sites More sharing options...
cpt_milkeye Posted August 23, 2023 Author Share Posted August 23, 2023 Tom, Danke Schöen I will check it out shortly but this already answers my question greatly. Thank you so very much! Peter Link to comment Share on other sites More sharing options...
Tom Kazansky Posted August 23, 2023 Share Posted August 23, 2023 Bitteschön Link to comment Share on other sites More sharing options...
cpt_milkeye Posted August 24, 2023 Author Share Posted August 24, 2023 miz file did have Blue player instead of ice. Once I changed that, it worked like a charm. And I think I understand the scripts. I modified mine to reset lives to start instead of turning immortal OFF. And added unlimited fuel and removed the missiles off my plane. But the next goal - and I don't know the difference yet - is to make it work on a dedicated server, including 1v1 PVP and 2v2 PVP and 2v PVE. or for that matter 3v3 as there are 6 in VFA-195 squad that are actively playing. Server is set to start with clients, but might need to start it paused. Also, name of multiplayer players might need to be changed (or the scripts to match our multiplayer names). Mission starts as "failed" so Blue group must be "dead" before blue player logs on ... 1 Link to comment Share on other sites More sharing options...
Tom Kazansky Posted August 24, 2023 Share Posted August 24, 2023 1 hour ago, cpt_milkeye said: miz file did have Blue player instead of ice. Once I changed that, it worked like a charm. And I think I understand the scripts. I modified mine to reset lives to start instead of turning immortal OFF. And added unlimited fuel and removed the missiles off my plane. But the next goal - and I don't know the difference yet - is to make it work on a dedicated server, including 1v1 PVP and 2v2 PVP and 2v PVE. or for that matter 3v3 as there are 6 in VFA-195 squad that are actively playing. Server is set to start with clients, but might need to start it paused. Also, name of multiplayer players might need to be changed (or the scripts to match our multiplayer names). Mission starts as "failed" so Blue group must be "dead" before blue player logs on ... Good to read. Yeah, those AA missiles weren't meant to be there. A relic of a test, that I didn't remove before uploading. I hope you get your server project running. Link to comment Share on other sites More sharing options...
Tom Kazansky Posted August 25, 2023 Share Posted August 25, 2023 (edited) After your reports about the names and the missiles I checked the version of my file again, and have to say, I klicked on the wrong line for uploading. The correct mission is this one P.S.: 1.) It makes sense to set fuel to unlimited for longer training flights with high "health points" at the start, as you mentioned. (With limited fuel I've learned about the afterburner usage of different planes.) 2.) What is odd: I tried my first uploaded mission (05.04.04...) again and although the pilots names were different from the script, the hit counter still worked correctly. Maybe someone with better knowledg of scripting could tell me why. ice 05.04.05 AA Training FA-18 vs. X (LUA-hit-counter works).miz Edited August 25, 2023 by Tom Kazansky Link to comment Share on other sites More sharing options...
cpt_milkeye Posted August 27, 2023 Author Share Posted August 27, 2023 If there is a way to "pull" player names 1-8, or use player slots, that would fix my first multiplayer challenge - I haven't been able to play with it, but my coding knowledge is quite limited to understanding simple code, most of the time. Link to comment Share on other sites More sharing options...
Recommended Posts