server/addons/bank/XEH_preInit_server.sqf
Jacob Schmidt 461a678f8b
All checks were successful
Build / Build (push) Successful in 25s
feat: Implement timesheet submission and rating system in bank addon
This commit introduces the ability for players to submit timesheets and receive payment based on their rating. It also includes updates to player data handling to incorporate the new rating system.

Key changes include:

- Added `getPlayer` PREP.
- Implemented `BANK::SUBMIT::TIMESHEET` case in `XEH_preInit_server.sqf` to handle timesheet submissions.
- Modified `fnc_initBankStore.sqf` to include rating in player data and update account information.
- Added `submitTimesheet` function to `fnc_initBankStore.sqf` to process timesheet submissions and pay players based on rating.
- Updated `handlePlayerLoad` and `updateAccount` functions in `fnc_initBankStore.sqf` to include rating.
- Added `getRating` function to `fnc_initBankStore.sqf` to retrieve player rating.
- Updated `BANK::HANDLE::PLAYER::LOAD` case in `XEH_preInit_server.sqf` to include rating value.
- Added database saving for reputation.

These changes introduce a new gameplay mechanic and provide a way for players to earn money based on their performance.
2025-05-11 01:19:58 -05:00

78 lines
3.6 KiB
Plaintext

#include "script_component.hpp"
call FUNC(initBank);
call FUNC(initBankStore);
[QGVAR(handleEvents), {
params ["_event", "_data"];
diag_log text format ["[FORGE::Server::Bank::XEH_preInit] Received event: '%1' with data: '%2'", _event, _data];
switch (_event) do {
case "BANK::DEPOSIT": {
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!"; };
_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!"; };
_bankStore call ["transfer", [_fromUid, _toUid, _amount]];
};
case "BANK::WITHDRAW": {
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::handleWithdraw] Invalid UID and amount!"; };
_bankStore call ["withdraw", [_uid, _amount]];
};
case "BANK::GET::BALANCE": {
private _bankStore = call FUNC(verifyBankStore);
_data params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE::Server::Bank::XEH_preInit::handleGetBalance] Invalid UID, UID cannot be empty!"; };
_bankStore call ["getBalance", [_uid]];
};
case "BANK::GET::CASH": {
private _bankStore = call FUNC(verifyBankStore);
_data params [["_uid", "", [""]]];
if (_uid isEqualTo "") exitWith { diag_log "[FORGE::Server::Bank::XEH_preInit::handleGetCash] Invalid UID, UID cannot be empty!"; };
_bankStore call ["getCash", [_uid]];
};
case "BANK::HANDLE::PLAYER::LOAD": {
private _bankStore = call FUNC(verifyBankStore);
_data params [["_uid", "", [""]], ["_bankValue", 0, [0]], ["_cashValue", 0, [0]], ["_ratingValue", 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]];
};
case "BANK::GET::TRANSACTION::HISTORY": {
private _bankStore = call FUNC(verifyBankStore);
_data params [["_uid", "", [""]], ["_limit", 10, [0]]];
_bankStore call ["getTransactionHistory", [_uid, _limit]];
};
default {
diag_log format ["[FORGE::Server::Bank::XEH_preInit] Unknown event: %1 with data: %2", _event, _data];
};
};
}] call CFUNC(addEventHandler);