나는 실패했을 때 프로그램의 상태를 백업하기 위해 모든 프로그램에 자주 쓰는 backup.lua라는 파일을 가지고있다. 문제는 프로그램이 backup.lua 파일을 처음부터 완벽하게 기록하지만 파일을 쓰지 못하게하는 경우입니다.닫힌 파일을 여는 중 :
프로그램이 열린 상태에서 파일을 제거하려고 시도했지만 프로그램에서 'CrysisWarsDedicatedServer.exe'파일이 사용 중이라고 나와 있습니다. 나는 호스트 Lua 함수에게 backup.lua 파일을 닫으라고 말했 읍니다. 그래서 닫혀진 후 파일을 수정할 수있게 해주지 않는 이유는 무엇입니까?
인터넷에서 아무것도 찾을 수 없습니다 (Google은 실제로 내 검색을 수정하려고 시도했습니다). 프로젝트의 보조 프로그래머도 알지 못합니다. 여러분 중 누군가 우리가 여기서 잘못하고있는 것을 알고 있는지 궁금합니다.
호스트 기능 코드 :
function ServerBackup(todo)
local write, read;
if todo=="write" then
write = true;
else
read = true;
end
if (write) then
local source = io.open(Root().."Mods/Infinity/System/Read/backup.lua", "w");
System.Log(TeamInstantAction:GetTeamScore(2).." for 2, and for 1: "..TeamInstantAction:GetTeamScore(1))
System.LogAlways("[System] Backing up serverdata to file 'backup.lua'");
source:write("--[[ The server is dependent on this file; editing it will lead to serious problems.If there is a problem with this file, please re-write it by accessing the backup system ingame.--]]");
source:write("Backup = {};Backup.Time = '"..os.date("%H:%M").."';Backup.Date = '"..os.date("%d/%m/%Y").."';");
source:write(XFormat("TeamInstantAction:SetTeamScore(2, %d);TeamInstantAction:SetTeamScore(1, %d);TeamInstantAction:UpdateScores();",TeamInstantAction:GetTeamScore(2), TeamInstantAction:GetTeamScore(1)));
source:close();
for i,player in pairs(g_gameRules.game:GetPlayers() or {}) do
if (IsModerator(player)) then
CMPlayer(player, "[!backup] Completed server backup.");
end
end
end
--local source = io.open(Root().."Mods/Infinity/System/Read/backup.lua", "r"); Can the file be open here and by the Lua scriptloader too?
if (read) then
System.LogAlways("[System] Restoring serverdata from file 'backup.lua'");
--source:close();
Backup = {};
Script.LoadScript(Root().."Mods/Infinity/System/Read/backup.lua");
if not Backup or #Backup < 1 then
System.LogAlways("[System] Error restoring serverdata from file 'backup.lua'");
end
end
end
모두 감사합니다 :).
는편집 : 파일이 현재 디스크 벌금에 기록됩니다
있지만, 시스템이 덤프 파일을 읽는 데 실패합니다. 나는 심령니까
, 난 당신이 Crysis 플러그인을 작성하고 있으며, 시도하는 것을 점쳐왔다 :
나는 Script.LoadScript가 글로벌 루아 기능이라고 생각했지만, 잘못된 것으로 입증되었습니다. :). 이것은 효과가 있습니다. 왜냐하면 24 시간을 기다려야하기 때문에 현상금을 수여 할 수는 없지만 제가 할 수있을 때 수여 할 것입니다. :). – cybermonkey