Compare commits
No commits in common. "master" and "1.0.0.10" have entirely different histories.
@ -13,23 +13,15 @@ call FUNC(initBankStore);
|
||||
private _bankStore = call FUNC(verifyBankStore);
|
||||
_data params [["_uid", "", [""]], ["_amount", 0, [0]]];
|
||||
|
||||
if (_uid isEqualTo "" || _amount isEqualTo 0) exitWith { diag_log "[FORGE::Server::Bank::XEH_preInit::handleDeposit] Invalid UID and amount, UID cannot be empty and amount must be greater than 0!"; };
|
||||
if (_uid isEqualTo "" || _amount isEqualTo 0) exitWith { diag_log "[FORGE::Server::Bank::XEH_preInit::handleDeposit] Invalid UID and amount!"; };
|
||||
|
||||
_bankStore call ["deposit", [_uid, _amount]];
|
||||
};
|
||||
case "BANK::SUBMIT::TIMESHEET": {
|
||||
private _bankStore = call FUNC(verifyBankStore);
|
||||
_data params [["_uid", "", [""]], ["_rating", 0, [0]]];
|
||||
|
||||
if (_uid isEqualTo "" || _rating <= 0) exitWith { diag_log "[FORGE::Server::Bank::XEH_preInit::handleSubmitTimesheet] Invalid UID, UID cannot be empty!"; };
|
||||
|
||||
_bankStore call ["submitTimesheet", [_uid, _rating]];
|
||||
};
|
||||
case "BANK::TRANSFER": {
|
||||
private _bankStore = call FUNC(verifyBankStore);
|
||||
_data params [["_fromUid", "", [""]], ["_toUid", "", [""]], ["_amount", 0, [0]]];
|
||||
|
||||
if (_fromUid isEqualTo "" || _toUid isEqualTo "" || _amount isEqualTo 0) exitWith { diag_log "[FORGE::Server::Bank::XEH_preInit::handleTransfer] Invalid UIDs and amount, UID cannot be empty and amount must be greater than 0!"; };
|
||||
if (_fromUid isEqualTo "" || _toUid isEqualTo "" || _amount isEqualTo 0) exitWith { diag_log "[FORGE::Server::Bank::XEH_preInit::handleTransfer] Invalid UIDs and amount!"; };
|
||||
|
||||
_bankStore call ["transfer", [_fromUid, _toUid, _amount]];
|
||||
};
|
||||
@ -59,11 +51,11 @@ call FUNC(initBankStore);
|
||||
};
|
||||
case "BANK::HANDLE::PLAYER::LOAD": {
|
||||
private _bankStore = call FUNC(verifyBankStore);
|
||||
_data params [["_uid", "", [""]], ["_bankValue", 0, [0]], ["_cashValue", 0, [0]], ["_ratingValue", 0, [0]]];
|
||||
_data params [["_uid", "", [""]], ["_bankValue", 0, [0]], ["_cashValue", 0, [0]]];
|
||||
|
||||
if (_uid isEqualTo "") exitWith { diag_log "[FORGE::Server::Bank::XEH_preInit::handlePlayerLoad] Invalid UID, UID cannot be empty!"; };
|
||||
|
||||
_bankStore call ["handlePlayerLoad", [_uid, _bankValue, _cashValue, _ratingValue]];
|
||||
_bankStore call ["handlePlayerLoad", [_uid, _bankValue, _cashValue]];
|
||||
};
|
||||
case "BANK::GET::TRANSACTION::HISTORY": {
|
||||
private _bankStore = call FUNC(verifyBankStore);
|
||||
|
@ -28,46 +28,36 @@ private _bankStore = createHashMapObject [[
|
||||
true
|
||||
}],
|
||||
["handlePlayerLoad", {
|
||||
params [["_uid", "", [""]], ["_bankValue", 0, [0]], ["_cashValue", 0, [0]], ["_ratingValue", 0, [0]]];
|
||||
params [["_uid", "", [""]], ["_bankValue", 0, [0]], ["_cashValue", 0, [0]]];
|
||||
|
||||
if (_uid isEqualTo "") exitWith { false };
|
||||
|
||||
_self call ["updateAccount", [_uid, _bankValue, _cashValue, _ratingValue]];
|
||||
_self call ["updateAccount", [_uid, _bankValue, _cashValue]];
|
||||
|
||||
diag_log text format ["[FORGE::Server::Bank::Store::handlePlayerLoad] Loaded player data for '%1' - Bank: '%2', Cash: '%3', Rating: '%4'", _uid, _bankValue, _cashValue, _ratingValue];
|
||||
diag_log text format ["[FORGE::Server::Bank::Store::handlePlayerLoad] Loaded player data for '%1' - Bank: '%2', Cash: '%3'", _uid, _bankValue, _cashValue];
|
||||
|
||||
true
|
||||
}],
|
||||
["updateAccount", {
|
||||
params [["_uid", "", [""]], ["_bankValue", 0, [0]], ["_cashValue", 0, [0]], ["_ratingValue", 0, [0]], ["_isSave", false, [false]]];
|
||||
params [["_uid", "", [""]], ["_bankValue", 0, [0]], ["_cashValue", 0, [0]], ["_isSave", false, [false]]];
|
||||
|
||||
if (_uid isEqualTo "") exitWith { false };
|
||||
|
||||
private _accounts = _self get "accounts";
|
||||
private _account = _accounts getOrDefault [_uid, createHashMap];
|
||||
private _player = [_uid] call EFUNC(misc,getPlayer);
|
||||
|
||||
_account set ["bank", _bankValue];
|
||||
_account set ["cash", _cashValue];
|
||||
_account set ["rating", _ratingValue];
|
||||
|
||||
_accounts set [_uid, _account];
|
||||
_self set ["accounts", _accounts];
|
||||
|
||||
private _balance = _account getOrDefault ["bank", 0];
|
||||
private _cash = _account getOrDefault ["cash", 0];
|
||||
|
||||
SETPVAR(_player,FORGE_Bank,_balance);
|
||||
SETPVAR(_player,FORGE_Cash,_cash);
|
||||
SETPVAR(_player,FORGE_Rating,_ratingValue);
|
||||
|
||||
if (_isSave) then {
|
||||
["hsetid", _uid, "bank", -1, [_bankValue]] call dragonfly_db_fnc_addTask;
|
||||
["hsetid", _uid, "cash", -1, [_cashValue]] call dragonfly_db_fnc_addTask;
|
||||
["hsetid", _uid, "reputation", -1, [_ratingValue]] call dragonfly_db_fnc_addTask;
|
||||
};
|
||||
|
||||
diag_log text format ["[FORGE::Server::Bank::Store::updateAccount] Updated player data for '%1' - Bank: '%2', Cash: '%3', Rating: '%4'", _uid, _bankValue, _cashValue, _ratingValue];
|
||||
diag_log text format ["[FORGE::Server::Bank::Store::updateAccount] Updated player data for '%1' - Bank: '%2', Cash: '%3'", _uid, _bankValue, _cashValue];
|
||||
|
||||
true
|
||||
}],
|
||||
@ -91,16 +81,6 @@ private _bankStore = createHashMapObject [[
|
||||
|
||||
_account getOrDefault ["cash", 0]
|
||||
}],
|
||||
["getRating", {
|
||||
params [["_uid", "", [""]]];
|
||||
|
||||
if (_uid isEqualTo "") exitWith { 0 };
|
||||
|
||||
private _accounts = _self get "accounts";
|
||||
private _account = _accounts getOrDefault [_uid, createHashMap];
|
||||
|
||||
_account getOrDefault ["rating", 0]
|
||||
}],
|
||||
["deposit", {
|
||||
params [["_uid", "", [""]], ["_amount", 0, [0]]];
|
||||
|
||||
@ -110,14 +90,13 @@ private _bankStore = createHashMapObject [[
|
||||
private _account = _accounts getOrDefault [_uid, createHashMap];
|
||||
private _currentCash = _account getOrDefault ["cash", 0];
|
||||
private _currentBalance = _account getOrDefault ["bank", 0];
|
||||
private _currentRating = _account getOrDefault ["rating", 0];
|
||||
|
||||
if (_currentCash < _amount) exitWith { false };
|
||||
|
||||
private _newBalance = _currentBalance + _amount;
|
||||
private _newCash = _currentCash - _amount;
|
||||
|
||||
_self call ["updateAccount", [_uid, _newBalance, _newCash, _currentRating, true]];
|
||||
_self call ["updateAccount", [_uid, _newBalance, _newCash, true]];
|
||||
|
||||
private _transactions = _self get "transactions";
|
||||
|
||||
@ -126,25 +105,26 @@ private _bankStore = createHashMapObject [[
|
||||
|
||||
true
|
||||
}],
|
||||
["submitTimesheet", {
|
||||
params [["_uid", "", [""]], ["_rating", 0, [0]]];
|
||||
["withdraw", {
|
||||
params [["_uid", "", [""]], ["_amount", 0, [0]]];
|
||||
|
||||
if (_uid isEqualTo "" || _rating <= 0) exitWith { false };
|
||||
if (_uid isEqualTo "" || _amount <= 0) exitWith { false };
|
||||
|
||||
private _accounts = _self get "accounts";
|
||||
private _account = _accounts getOrDefault [_uid, createHashMap];
|
||||
private _currentBalance = _account getOrDefault ["bank", 0];
|
||||
private _currentCash = _account getOrDefault ["cash", 0];
|
||||
|
||||
private _payMultiplyer = "MULTIPLYR" call BFUNC(getParamValue);
|
||||
private _multiplyer = _rating * _payMultiplyer;
|
||||
private _newBalance = _currentBalance + _multiplyer;
|
||||
if (_currentBalance < _amount) exitWith { false };
|
||||
|
||||
_self call ["updateAccount", [_uid, _newBalance, _currentCash, 0, true]];
|
||||
private _newBalance = _currentBalance - _amount;
|
||||
private _newCash = _currentCash + _amount;
|
||||
|
||||
_self call ["updateAccount", [_uid, _newBalance, _newCash, true]];
|
||||
|
||||
private _transactions = _self get "transactions";
|
||||
|
||||
_transactions pushBack [_uid, "timesheet", _multiplyer, time];
|
||||
_transactions pushBack [_uid, "withdraw", _amount, time];
|
||||
_self set ["transactions", _transactions];
|
||||
|
||||
true
|
||||
@ -159,15 +139,11 @@ private _bankStore = createHashMapObject [[
|
||||
private _toAccount = _accounts getOrDefault [_toUid, createHashMap];
|
||||
private _fromBalance = _fromAccount getOrDefault ["bank", 0];
|
||||
private _toBalance = _toAccount getOrDefault ["bank", 0];
|
||||
private _fromCash = _fromAccount getOrDefault ["cash", 0];
|
||||
private _toCash = _toAccount getOrDefault ["cash", 0];
|
||||
private _fromRating = _fromAccount getOrDefault ["rating", 0];
|
||||
private _toRating = _toAccount getOrDefault ["rating", 0];
|
||||
|
||||
if (_fromBalance < _amount) exitWith { false };
|
||||
|
||||
_self call ["updateAccount", [_fromUid, _fromBalance - _amount, _fromCash, _fromRating, true]];
|
||||
_self call ["updateAccount", [_toUid, _toBalance + _amount, _toCash, _toRating, true]];
|
||||
_self call ["updateAccount", [_fromUid, _fromBalance - _amount, 0, true]];
|
||||
_self call ["updateAccount", [_toUid, _toBalance + _amount, 0, true]];
|
||||
|
||||
private _transactions = _self get "transactions";
|
||||
|
||||
@ -177,31 +153,6 @@ private _bankStore = createHashMapObject [[
|
||||
|
||||
true
|
||||
}],
|
||||
["withdraw", {
|
||||
params [["_uid", "", [""]], ["_amount", 0, [0]]];
|
||||
|
||||
if (_uid isEqualTo "" || _amount <= 0) exitWith { false };
|
||||
|
||||
private _accounts = _self get "accounts";
|
||||
private _account = _accounts getOrDefault [_uid, createHashMap];
|
||||
private _currentBalance = _account getOrDefault ["bank", 0];
|
||||
private _currentCash = _account getOrDefault ["cash", 0];
|
||||
private _currentRating = _account getOrDefault ["rating", 0];
|
||||
|
||||
if (_currentBalance < _amount) exitWith { false };
|
||||
|
||||
private _newBalance = _currentBalance - _amount;
|
||||
private _newCash = _currentCash + _amount;
|
||||
|
||||
_self call ["updateAccount", [_uid, _newBalance, _newCash, _currentRating, true]];
|
||||
|
||||
private _transactions = _self get "transactions";
|
||||
|
||||
_transactions pushBack [_uid, "withdraw", _amount, time];
|
||||
_self set ["transactions", _transactions];
|
||||
|
||||
true
|
||||
}],
|
||||
["getTransactionHistory", {
|
||||
params [["_uid", "", [""]], ["_limit", 10, [0]]];
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#define MAJOR 1
|
||||
#define MINOR 0
|
||||
#define PATCH 0
|
||||
#define BUILD 11
|
||||
#define BUILD 10
|
||||
|
@ -1,5 +1,4 @@
|
||||
PREP(cargoToPairs);
|
||||
PREP(getPlayer);
|
||||
PREP(playSound);
|
||||
PREP(playerGroup2Server);
|
||||
PREP(redirectClient2Server);
|
||||
|
@ -1,27 +0,0 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
/*
|
||||
* Author: IDSolutions
|
||||
* Gets a player object by UID.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Player UID <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Player object or objNull if not found <OBJECT>
|
||||
*
|
||||
* Example:
|
||||
* ["76561198012345678"] call forge_crate_common_fnc_getPlayer
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
params ["_uid"];
|
||||
|
||||
private _player = objNull;
|
||||
|
||||
{
|
||||
if ((getPlayerUID _x) isEqualTo _uid) exitWith { _player = _x; };
|
||||
} forEach allPlayers;
|
||||
|
||||
_player
|
Loading…
x
Reference in New Issue
Block a user