Open Ravenger2709 opened 2 years ago
This should do it:
// in initServer.sqf
[] spawn {
while {true} do {
sleep 10;
[true, 10] call grad_persistence_fnc_saveMission;
};
};
or if you want to get more fancy:
// in initServer.sqf
[{
[true, 10] call grad_persistence_fnc_saveMission;
} , 10, []] call CBA_fnc_addPerFrameHandler;
I've been doing a few experiments and have found the following approach to work well. It saves whenever a player disconnects and when an admin uses #missions
or #restart
. It unfortunately does not save on server shutdown but the save-on-disconnect is a half-assed workaround.
init.sqf
if (hasInterface) then {
[] spawn {
waitUntil {!isNull findDisplay 46};
(findDisplay 46) displayAddEventHandler ["Unload", {
if (!isServer) exitWith {};
[false, 0] call grad_persistence_fnc_saveMission;
}];
};
} else {
addMissionEventHandler ["HandleDisconnect", {
if !(allPlayers isEqualTo []) exitWith {false};
params ["_unit"];
deleteVehicle _unit;
[false, 0] call grad_persistence_fnc_saveMission;
}];
};
initServer.sqf
if (isServer || isDedicated) exitWith {
addMissionEventHandler ["MPEnded", {
[false, 0] call grad_persistence_fnc_saveMission;
}];
};
Hi! I used your script in my mission. On #save command with admin privelegies it`s work fine, but i want to autpsave my mission.
Added this to init.sqf :
but it`s only save player state, not vehicles, storages and ect.
Can anybody help my to write right script?