HungryCoyote Posted February 22, 2022 Posted February 22, 2022 Not sure if this is an editor or server question. Is there any way to store data, maybe as a txt file to keep track of which players have destroyed certain targets?
cfrag Posted February 22, 2022 Posted February 22, 2022 It's not a default option, but you can write a Lua script that does that for you. There are significant caveats, though: Lua scripts can't write to your file system unless you specifically disable the sanitize module function (trust me, it's a good thing that Lua scripts can't write nilly-willy to your drive That score-keeping script must EITHER be included into all missions that you want to record kills OR it is run on the server to record kills. In that case, only missions that you run as server will record kills. You may be able to use the export data module for this purpose, but I have never done this.
HungryCoyote Posted February 22, 2022 Author Posted February 22, 2022 I will look into that. May be over my head but thanks.
Paganus Posted February 22, 2022 Posted February 22, 2022 debrief.log contains events from the most recent mission. As with most things, it isn't 100% reliable, but it's better than nothing.
toutenglisse Posted February 22, 2022 Posted February 22, 2022 3 hours ago, HungryCoyote said: Not sure if this is an editor or server question. Is there any way to store data, maybe as a txt file to keep track of which players have destroyed certain targets? as an example, this code will create a .txt file in your Logs when writePlayerKillTable() function is called. Uses MIST and you need to "comment" two lines (--sanitizeModule('io') and --sanitizeModule('lfs')) in DCS\Scripts\MissionScripting.lua (Table lists Kills made by Players upon any unit with : PlayerNames, TargetNames and time) : Spoiler PlayerKillTable = {} function KillEvent(event) if event.id == world.event.S_EVENT_KILL then if event.initiator ~= nil and event.target ~= nil and event.initiator:getPlayerName() ~= nil and event.target:getCategory() == 1 then local NewKillEntry = {initiator = event.initiator:getPlayerName(), target = event.target:getName(), Killtime = event.time} table.insert(PlayerKillTable, NewKillEntry) end end end mist.addEventHandler(KillEvent) function writePlayerKillTable() if #PlayerKillTable > 0 then mist.debug.writeData(mist.utils.serialize,{'PlayerKillTable', PlayerKillTable}, 'testKills.txt') end end
HungryCoyote Posted February 23, 2022 Author Posted February 23, 2022 This looks like exactly what I need. I am embarrassed to say I am not sure how to set it up. I commented the two lines and set up a trigger. What else am I missing?
toutenglisse Posted February 23, 2022 Posted February 23, 2022 (edited) 50 minutes ago, HungryCoyote said: This looks like exactly what I need. I am embarrassed to say I am not sure how to set it up. I commented the two lines and set up a trigger. What else am I missing?... You have to use writePlayerKillTable() when you want it. example trigger once -> Time > X seconds -> Do script text : writePlayerKillTable() (at time = X seconds the file is created containing all Players' kills and you get a message on screen that confirms it - if at least 1 kill has happened) Edited February 23, 2022 by toutenglisse
HungryCoyote Posted February 23, 2022 Author Posted February 23, 2022 Simple test mission. Shoot down enemy plane, wait five minutes. Nothing happens. log test.miz
toutenglisse Posted February 23, 2022 Posted February 23, 2022 36 minutes ago, HungryCoyote said: Simple test mission. Shoot down enemy plane, wait five minutes. Nothing happens... If you are not at ease with scripts, an example is better sorry. I attached your example corrected and tried that it works. log test.miz
HungryCoyote Posted February 23, 2022 Author Posted February 23, 2022 Thank you very much for your help and patience.
HungryCoyote Posted February 25, 2022 Author Posted February 25, 2022 This is working really well. One quick question, Is there a way to get it to log static buildings killed?
toutenglisse Posted February 25, 2022 Posted February 25, 2022 3 hours ago, HungryCoyote said: This is working really well. One quick question, Is there a way to get it to log static buildings killed? I've not tested, but this should work (it should create 2 files with the same previous function : 1 for Players kills on units and 1 for Players kills on scenrey objects, with typeNames) : Spoiler PlayerKillTable = {} DestroyedScenaryTable = {} function KillEvent(event) if event.id == world.event.S_EVENT_KILL then if event.initiator ~= nil and event.target ~= nil and event.initiator:getPlayerName() ~= nil and event.target:getCategory() == 1 then local NewKillEntry = {initiator = event.initiator:getPlayerName(), target = event.target:getName(), Killtime = event.time} table.insert(PlayerKillTable, NewKillEntry) elseif event.initiator ~= nil and event.target ~= nil and event.initiator:getPlayerName() ~= nil and event.target:getCategory() == 5 then local NewSceneryEntry = {initiator = event.initiator:getPlayerName(), target = event.target:getTypeName(), Killtime = event.time} table.insert(DestroyedScenaryTable, NewSceneryEntry) end end end mist.addEventHandler(KillEvent) function writePlayerKillTable() mist.debug.writeData(mist.utils.serialize,{'PlayerKillTable', PlayerKillTable}, 'testKills.txt') mist.debug.writeData(mist.utils.serialize,{'DestroyedScenaryTable', DestroyedScenaryTable}, 'testScenDest.txt') end
HungryCoyote Posted February 27, 2022 Author Posted February 27, 2022 This works great for my needs. Just an fyi for anyone else using this, It works for everything except statics. Again, thank you very much.
toutenglisse Posted February 27, 2022 Posted February 27, 2022 2 hours ago, HungryCoyote said: This works great for my needs. Just an fyi for anyone else using this, It works for everything except statics. Again, thank you very much. Here on this page you have the list of numbers for all categories (Statics are 3) : DCS Class Object - DCS World Wiki - Hoggitworld.com You can add the category you want the same way than the 2 others.
Recommended Posts