Page MenuHomeFeedback Tracker

impossible to write to file DayZServer_x64.ADM
Assigned, UrgentPublic

Description

Hi! I wrote a function to add logs to the DayZServer_x64.ADM file, but this file cannot be opened for writing. The option to use another file is not suitable, since a discord bot is used that reads from this particular file. Tell me, is it possible to write to this file? Maybe you will expand the native write function in DayZServer_x64?

void PrintAdmLog(string logline)
	{
		int hour, minute, second;
		GetHourMinuteSecond(hour, minute, second);
		string time = hour.ToStringLen(2) + ":" + minute.ToStringLen(2) + ":" + second.ToStringLen(2);
		
		string FILENAME = "$profile:DayZServer_x64.ADM";
		string text  = time + " | " + logline;
		FileHandle file;
		if (!FileExist(FILENAME))
		{
			file = OpenFile(FILENAME, FileMode.WRITE);
		}
		else
		{
			file = OpenFile(FILENAME, FileMode.APPEND);
		}
		if (file != 0)
		{
			FPrintln(file, text);
			CloseFile(file);
		}
		else
		{
			Print("Error! File not open: " + FILENAME);
		}
	}

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General

Event Timeline

mate26 created this task.Mar 7 2021, 1:47 PM
mate26 updated the task description. (Show Details)Mar 7 2021, 1:49 PM
mate26 updated the task description. (Show Details)
Geez changed the task status from New to Assigned.Mar 8 2021, 4:30 PM

@mate26 You can't open that file because it has already been opened for writing by the DayZ process.

Have you tried using the CGame::AdminLog method to write to the log, instead? This is even documented in the DayZ Wiki.