// fnc_initPhotoHandler.sqf
// This function is a bypass for gm_moduleSavePictures, because it didn't want to behave.
// The screenshots taken by the camera will be located in User\Documents\Arma 3\Screenshots\gm_photocamera
// You're welcome, Cammie

[missionNamespace, "gm_photocamera_takePicture", {
    private _time = date; // [year, month, day, hour, minute]
    private _year = _time select 0;
    private _month = _time select 1;
    private _day = _time select 2;
    private _hour = _time select 3;
    private _minute = _time select 4;
    private _second = floor (diag_tickTime % 60);

    if (_month < 10) then {_month = "0" + str _month;} else {_month = str _month;};
    if (_day < 10) then {_day = "0" + str _day;} else {_day = str _day;};
    if (_hour < 10) then {_hour = "0" + str _hour;} else {_hour = str _hour;};
    if (_minute < 10) then {_minute = "0" + str _minute;} else {_minute = str _minute;};
    if (_second < 10) then {_second = "0" + str _second;} else {_second = str _second;};

    private _timestamp = format ["%1-%2-%3_%4-%5-%6", _year, _month, _day, _hour, _minute, _second];
    private _filename = format ["gm_photocamera/photo_%1.png", _timestamp];

    screenshot _filename;
    systemChat format ["Saved photo: %1", _filename];
}] call BIS_fnc_addScriptedEventHandler;
