#include "..\script_component.hpp"

/*
 * Function: forge_client_init_fnc_playerDBSave
 * Author: Creedcoder, J.Schmidt
 * Edit: 07.15.2024
 * Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
 *
 * Do not edit without permission!
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivative 4.0 International License.
 * To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to Creative Commons,
 * PO Box 1866, Mountain View, CA 94042
 *
 * [Description]
 * Save player to DB.
 *
 * Arguments:
 * N/A
 *
 * Return Value:
 * N/A
 *
 * Examples:
 * [] call forge_client_init_fnc_playerDBSave (Server or Singleplayer Only)
 * [] remoteExecCall ["forge_client_init_fnc_playerDBSave", 2, false] (Multiplayer Only)
 *
 * Public: Yes
 */

private _default_armory_unlocks = [[],[],[],[]];
private _default_garage_unlocks = [[],[],[],[],[],[]];

private _data = [
getPlayerUID player,
// "armory_unlocks", [player getVariable ["Armory_Unlocks", [[],[],[],[]]]],
// "garage_unlocks", [player getVariable ["Garage_Unlocks", [[],[],[],[],[],[]]]],
"armory_unlocks", [GETVAR(player,Armory_Unlocks,_default_armory_unlocks)],
"garage_unlocks", [GETVAR(player,Garage_Unlocks,_default_garage_unlocks)],
// "locker", [player getVariable ["FORGE_Locker", []]],
// "garage", [player getVariable ["FORGE_Garage", []]],
"locker", [GETVAR(player,FORGE_Locker,[])],
"garage", [GETVAR(player,FORGE_Garage,[])],
// "cash", [player getVariable ["FORGE_Cash", 0]],
// "bank", [player getVariable ["FORGE_Bank", 0]],
"cash", [GETVAR(player,FORGE_Cash,0)],
"bank", [GETVAR(player,FORGE_Bank,0)],
// "number", [player getVariable ["FORGE_Phone_Number", "unknown"]],
// "email", [player getVariable ["FORGE_Email", "unknown@spearnet.mil"]],
"number", [GETVAR(player,FORGE_Phone_Number,"unknown")],
"email", [GETVAR(player,FORGE_Email,"unknown@spearnet.mil")],
// "paygrade", [player getVariable ["Paygrade", "E1"]],
"paygrade", [GETVAR(player,Paygrade,"E1")],
"reputation", [rating player],
"loadout", [getUnitLoadout player],
// "holster", [player getVariable ["FORGE_Holster_Weapon", true]],
"holster", [GETVAR(player,FORGE_Holster_Weapon,true)],
"position", [getPosASLVisual player],
"direction", [getDirVisual player]
];

if (isNull objectParent player) then {
    _data pushBack "currentWeapon";
    _data pushBack [currentMuzzle player];
    _data pushBack "stance";
    _data pushBack [stance player];
};

// ["hsetBulk", "", "", -1, _data, "", false] spawn dragonfly_db_fnc_addTask;
["hsetidbulk", "", "", -1, _data, "", false, netId player] remoteExec ["dragonfly_db_fnc_addTask", 2, false];