Last active
August 29, 2015 14:26
-
-
Save AgentRev/f7cbd08b6a3d08d68c1d to your computer and use it in GitHub Desktop.
loadAccount.sqf - GearLevel for Mokey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ****************************************************************************************** | |
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com * | |
// ****************************************************************************************** | |
// @file Name: loadAccount.sqf | |
// @file Author: Torndeco, AgentRev | |
if (!isServer) exitWith {}; | |
private ["_UID", "_bank", "_moneySaving", "_result", "_gearLevel", "_data", "_columns", "_dataTemp", "_ghostingTimer", "_secs"]; | |
_UID = _this; | |
_bank = 0; | |
_moneySaving = ["A3W_moneySaving"] call isConfigOn; | |
if (_moneySaving) then | |
{ | |
_result = ["getPlayerBankMoney:" + _UID, 2] call extDB_Database_async; | |
if (count _result > 0) then | |
{ | |
_bank = _result select 0; | |
}; | |
}; | |
_gearLevel = (["getPlayerGearLevel:" + _UID, 2] call extDB_Database_async) param [0,0,[0]]; | |
_result = ([format ["checkPlayerSave:%1:%2", _UID, call A3W_extDB_MapID], 2] call extDB_Database_async) select 0; | |
if (!_result) then | |
{ | |
_data = | |
[ | |
["PlayerSaveValid", false], | |
["BankMoney", _bank], | |
["GearLevel", _gearLevel] | |
]; | |
} | |
else | |
{ | |
// The order of these values is EXTREMELY IMPORTANT! | |
_data = | |
[ | |
"Damage", | |
"HitPoints", | |
"LoadedMagazines", | |
"PrimaryWeapon", | |
"SecondaryWeapon", | |
"HandgunWeapon", | |
"PrimaryWeaponItems", | |
"SecondaryWeaponItems", | |
"HandgunItems", | |
"AssignedItems", | |
"CurrentWeapon", | |
"Stance", | |
"Uniform", | |
"Vest", | |
"Backpack", | |
"Goggles", | |
"Headgear", | |
"UniformWeapons", | |
"UniformItems", | |
"UniformMagazines", | |
"VestWeapons", | |
"VestItems", | |
"VestMagazines", | |
"BackpackWeapons", | |
"BackpackItems", | |
"BackpackMagazines", | |
"WastelandItems", | |
"Hunger", | |
"Thirst", | |
"Position", | |
"Direction" | |
]; | |
if (_moneySaving) then | |
{ | |
_data pushBack "Money"; | |
}; | |
_columns = ""; | |
{ | |
_columns = _columns + ((if (_columns != "") then { "," } else { "" }) + _x); | |
} forEach _data; | |
_result = [format ["getPlayerSave:%1:%2:%3", _UID, call A3W_extDB_MapID, _columns], 2] call extDB_Database_async; | |
{ | |
_data set [_forEachIndex, [_data select _forEachIndex, _x]]; | |
} forEach _result; | |
_dataTemp = _data; | |
_data = [["PlayerSaveValid", true], ["GearLevel", _gearLevel]]; | |
_ghostingTimer = ["A3W_extDB_GhostingTimer", 5*60] call getPublicVar; | |
if (_ghostingTimer > 0) then | |
{ | |
_result = [format ["getTimeSinceServerSwitch:%1:%2:%3", _UID, call A3W_extDB_MapID, call A3W_extDB_ServerID], 2] call extDB_Database_async; | |
if (count _result > 0) then | |
{ | |
_secs = _result select 0; | |
if (_secs < _ghostingTimer) then | |
{ | |
_data pushBack ["GhostingTimer", _ghostingTimer - _secs]; | |
}; | |
}; | |
}; | |
_data append _dataTemp; | |
_data pushBack ["BankMoney", _bank]; | |
}; | |
_data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment