Jump to content

Server background script


logion

Recommended Posts

Hi all,

 

I'm trying to run a script once every second on the server-side in order to export some data periodically out of DCS. The goal is to export the active units in DCS World over the network. For now, I'm only trying to dump coalition info to a file as a first step. However, I'm having issues with just running a script in the background on the server.

 

I decided to hook into net.on_process() as this function gets executed every frame. The problem is I don't quite know when the sim engine is done loading the mission and when I can start reading the units in the sim without crashing. I tried waiting until net.is_paused() returns false, but this leads to DCS crashing. I've inspected the net table, and the is_paused() function is actually present. So I'm guessing I should wait to call this function until condition X is fulfilled, but what is this condition X?

 

This is my server.on_process() function:

local func_old = {}
func_old.on_process = server.on_process

function server.on_process()
logFile:write('dumpUnitsToLog.lua: is sim paused?')
if net.is_paused() then -- wait until game is running
	logFile:write('dumpUnitsToLog.lua: sim is paused, waiting')
	return func_old.on_process()
end

return func_old.on_process()
end

 

The last piece of output I see in my log file is:

dumpUnitsToLog.lua: is sim paused?

 

After that DCS crashes to desktop. dcs.log mentions:

00019.431 INFO NET: Loading mission: "C:\Users\logion\Saved Games\DCS\Missions\test.miz"

00019.561 INFO DCS: try to write dump information

00019.620 INFO EDCORE: Minidump created.

00019.620 INFO DCS: try to write track file

 

Any suggestions? I feel like I'm missing something fundamental. Is on_process() even the right place for this kind of background script functionality?

When I look at how Slmod solves this, it seems to use net.dostring_in() so that the DCS engine can inform the script when it is ready to proceed? However, I don't quite understand the workings beind dostring_in, can someone elaborate?


Edited by logion
Link to comment
Share on other sites

  • Recently Browsing   0 members

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