Jump to content

Recommended Posts

Posted

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.

 

Posted
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

 

Posted (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 by toutenglisse
Posted
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

 

 

  • Recently Browsing   0 members

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