server/addons/save/functions/fnc_handleDisconnect.sqf
2025-01-04 19:25:56 -06:00

75 lines
2.8 KiB
Plaintext

#include "..\script_component.hpp"
/*
@file Title: ArmaDragonflyClient Framework by Creedcoder, J.Schmidt
@file Version: 0.1
@file Name: fnc_savePlayer.sqf
@file Author: Creedcoder, J.Schmidt
@file edit: 03.25.2024
Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
Do not edit without permission!
This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to Creative Commons,
444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
Save Player to DB:
*/
addMissionEventHandler ["HandleDisconnect", {
// params ["_unit", "_id", "_uid", "_name"];
private _unit = _this select 0;
private _uid = _this select 2;
private _default_armory_unlocks = [[],[],[],[]];
private _default_garage_unlocks = [[],[],[],[],[],[]];
private _data = [
_uid,
// "armory_unlocks", [_unit getVariable ["Armory_Unlocks", _default_armory_unlocks]],
// "garage_unlocks", [_unit getVariable ["Garage_Unlocks", _default_garage_unlocks]],
"armory_unlocks", [GETVAR(_unit,Armory_Unlocks,_default_armory_unlocks)],
"garage_unlocks", [GETVAR(_unit,Garage_Unlocks,_default_garage_unlocks)],
// "locker", [_unit getVariable ["FORGE_Locker", []]],
// "garage", [_unit getVariable ["FORGE_Garage", []]],
"locker", [GETVAR(_unit,FORGE_Locker,[])],
"garage", [GETVAR(_unit,FORGE_Garage,[])],
// "cash", [_unit getVariable ["FORGE_Cash", 0]],
// "bank", [_unit getVariable ["FORGE_Bank", 0]],
"cash", [GETVAR(_unit,FORGE_Cash,0)],
"bank", [GETVAR(_unit,FORGE_Bank,0)],
// "number", [_unit getVariable ["FORGE_Phone_Number", "unknown"]],
// "email", [_unit getVariable ["FORGE_Email", "unknown@spearnet.mil"]],
"number", [GETVAR(_unit,FORGE_Phone_Number,"unknown")],
"email", [GETVAR(_unit,FORGE_Email,"unknown@spearnet.mil")],
// "paygrade", [_unit getVariable ["Paygrade", "E1"]],
"paygrade", [GETVAR(_unit,Paygrade,"E1")],
"reputation", [rating _unit],
"loadout", [getUnitLoadout _unit],
// "holster", [_unit getVariable ["FORGE_Holster_Weapon", true]],
"holster", [GETVAR(_unit,FORGE_Holster_Weapon,true)],
"position", [getPosASLVisual _unit],
"direction", [getDirVisual _unit]
];
// if (vehicle _unit == _unit) then {
// _data pushBack "currentWeapon";
// _data pushBack [currentMuzzle _unit];
// _data pushBack "stance";
// _data pushBack [stance _unit];
// };
if (isNull objectParent _unit) then {
_data pushBack "currentWeapon";
_data pushBack [currentMuzzle _unit];
_data pushBack "stance";
_data pushBack [stance _unit];
};
diag_log format ["Saving Player: %1", _data];
// ["hsetidbulk", "", "", -1, _data, "", false] call dragonfly_db_fnc_addTask;
["hsetidbulk", "", "", -1, _data, "", false] remoteExecCall ["dragonfly_db_fnc_addTask", 2, false];
deleteVehicle _unit;
}];