Skip to content

Commit

Permalink
Gang bank (#557)
Browse files Browse the repository at this point in the history
* Rework the gang bank system to ensure requests are routed via the server.
  • Loading branch information
DomT602 authored and Jason2605 committed May 15, 2019
1 parent d473ab8 commit b7c1cbc
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 102 deletions.
1 change: 1 addition & 0 deletions Altis_Life.Altis/CfgRemoteExec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class CfgRemoteExec {
F(life_fnc_vehicleAnimate,CLIENT)
F(life_fnc_wantedList,CLIENT)
F(life_fnc_wireTransfer,CLIENT)
F(life_fnc_gangBankResponse,CLIENT)
F(SOCK_fnc_dataQuery,CLIENT)
F(SOCK_fnc_insertPlayerInfo,CLIENT)
F(SOCK_fnc_requestReceived,CLIENT)
Expand Down
4 changes: 2 additions & 2 deletions Altis_Life.Altis/Functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ class Life_Client_Core {
class bankTransfer {};
class bankWithdraw {};
class displayHandler {};
class gangDeposit {};
class gangWithdraw {};
class gangBankResponse {};
class garageLBChange {};
class impoundMenu {};
class progressBar {};
Expand All @@ -166,6 +165,7 @@ class Life_Client_Core {
class spawnPointCfg {};
class spawnPointSelected {};
class unimpound {};
class useGangBank {};
class vehicleGarage {};
class wireTransfer {};
};
Expand Down
4 changes: 2 additions & 2 deletions Altis_Life.Altis/config/Config_SpyGlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ class SpyGlass {
"life_fnc_copsiren_meta","life_fnc_copsplit","life_fnc_copsplit_meta","life_fnc_corpse","life_fnc_corpse_meta","life_fnc_creategang","life_fnc_creategang_meta","life_fnc_deathscreen","life_fnc_deathscreen_meta","life_fnc_defusekit","life_fnc_defusekit_meta","life_fnc_demochargetimer","life_fnc_demochargetimer_meta","life_fnc_devicemine","life_fnc_devicemine_meta",
"life_fnc_displayhandler","life_fnc_displayhandler_meta","life_fnc_dooranimate","life_fnc_dooranimate_meta","life_fnc_dpfinish","life_fnc_dpfinish_meta","life_fnc_dropfishingnet","life_fnc_dropfishingnet_meta","life_fnc_dropitems","life_fnc_dropitems_meta","life_fnc_escinterupt","life_fnc_escinterupt_meta","life_fnc_escortaction","life_fnc_escortaction_meta",
"life_fnc_fedcamdisplay","life_fnc_fedcamdisplay_meta","life_fnc_fetchcfgdetails","life_fnc_fetchcfgdetails_meta","life_fnc_fetchdeadgear","life_fnc_fetchdeadgear_meta","life_fnc_fetchvehinfo","life_fnc_fetchvehinfo_meta","life_fnc_flashbang","life_fnc_flashbang_meta","life_fnc_freezeplayer","life_fnc_freezeplayer_meta","life_fnc_fuellbchange","life_fnc_fuellbchange_meta",
"life_fnc_fuelrefuelcar","life_fnc_fuelrefuelcar_meta","life_fnc_fuelstatopen","life_fnc_fuelstatopen_meta","life_fnc_fuelstore","life_fnc_fuelstore_meta","life_fnc_fuelsupply","life_fnc_fuelsupply_meta","life_fnc_gangcreated","life_fnc_gangcreated_meta","life_fnc_gangdeposit","life_fnc_gangdeposit_meta","life_fnc_gangdisband","life_fnc_gangdisband_meta","life_fnc_gangdisbanded",
"life_fnc_fuelrefuelcar","life_fnc_fuelrefuelcar_meta","life_fnc_fuelstatopen","life_fnc_fuelstatopen_meta","life_fnc_fuelstore","life_fnc_fuelstore_meta","life_fnc_fuelsupply","life_fnc_fuelsupply_meta","life_fnc_gangcreated","life_fnc_gangcreated_meta","life_fnc_usegangbank","life_fnc_usegangbank_meta","life_fnc_gangdisband","life_fnc_gangdisband_meta","life_fnc_gangdisbanded",
"life_fnc_gangdisbanded_meta","life_fnc_ganginvite","life_fnc_ganginvite_meta","life_fnc_ganginviteplayer","life_fnc_ganginviteplayer_meta","life_fnc_gangkick","life_fnc_gangkick_meta","life_fnc_gangleave","life_fnc_gangleave_meta","life_fnc_gangmenu","life_fnc_gangmenu_meta","life_fnc_gangnewleader","life_fnc_gangnewleader_meta","life_fnc_gangupgrade","life_fnc_gangupgrade_meta",
"life_fnc_gangwithdraw","life_fnc_gangwithdraw_meta","life_fnc_garagelbchange","life_fnc_garagelbchange_meta","life_fnc_garagerefund","life_fnc_garagerefund_meta","life_fnc_gather","life_fnc_gather_meta","life_fnc_getbuildingpositions","life_fnc_getbuildingpositions_meta","life_fnc_getdpmission","life_fnc_getdpmission_meta","life_fnc_givediff","life_fnc_givediff_meta","life_fnc_giveitem",
"life_fnc_gangbankresponse","life_fnc_gangbankresponse_meta","life_fnc_garagelbchange","life_fnc_garagelbchange_meta","life_fnc_garagerefund","life_fnc_garagerefund_meta","life_fnc_gather","life_fnc_gather_meta","life_fnc_getbuildingpositions","life_fnc_getbuildingpositions_meta","life_fnc_getdpmission","life_fnc_getdpmission_meta","life_fnc_givediff","life_fnc_givediff_meta","life_fnc_giveitem",
"life_fnc_giveitem_meta","life_fnc_givemoney","life_fnc_givemoney_meta","life_fnc_gutanimal","life_fnc_gutanimal_meta","life_fnc_handledamage","life_fnc_handledamage_meta","life_fnc_handleinv","life_fnc_handleinv_meta","life_fnc_handleitem","life_fnc_handleitem_meta","life_fnc_healhospital","life_fnc_healhospital_meta","life_fnc_hideobj","life_fnc_hideobj_meta","life_fnc_houseconfig",
"life_fnc_houseconfig_meta","life_fnc_housemenu","life_fnc_housemenu_meta","life_fnc_hudsetup","life_fnc_hudsetup_meta","life_fnc_hudupdate","life_fnc_hudupdate_meta","life_fnc_impoundaction","life_fnc_impoundaction_meta","life_fnc_impoundmenu","life_fnc_impoundmenu_meta","life_fnc_initciv","life_fnc_initciv_meta","life_fnc_initcop","life_fnc_initcop_meta","life_fnc_initgang",
"life_fnc_initgang_meta","life_fnc_inithouses","life_fnc_inithouses_meta","life_fnc_initmedic","life_fnc_initmedic_meta","life_fnc_inventoryclosed","life_fnc_inventoryclosed_meta","life_fnc_inventoryopened","life_fnc_inventoryopened_meta","life_fnc_isdamaged","life_fnc_isdamaged_meta","life_fnc_isnumeric","life_fnc_isnumeric_meta","life_fnc_isuidactive","life_fnc_isuidactive_meta",
Expand Down
4 changes: 2 additions & 2 deletions Altis_Life.Altis/dialog/bank.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Life_atm_management {
idc = 2705;
text = "$STR_ATM_WithdrawGang";
colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};
onButtonClick = "[] call life_fnc_gangWithdraw";
onButtonClick = "[false] call life_fnc_useGangBank";
x = 0.365;
y = 0.7;
w = 0.275;
Expand All @@ -109,7 +109,7 @@ class Life_atm_management {
idc = 2706;
text = "$STR_ATM_DepositGang";
colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};
onButtonClick = "[] call life_fnc_gangDeposit";
onButtonClick = "[true] call life_fnc_useGangBank";
x = 0.365;
y = 0.752;
w = 0.275;
Expand Down
16 changes: 16 additions & 0 deletions Altis_Life.Altis/dialog/function/fn_gangBankResponse.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "..\..\script_macros.hpp"
/*
File: fn_gankBankResponse.sqf
Author: DomT602
Description:
Receives response from the server.
*/
params [
["_value",-1,[0]]
];
if (remoteExecutedOwner != ([2,HC_Life] select life_HC_isActive)) exitWith {};
if (_value isEqualTo -1) exitWith {};

hint format [localize "STR_ATM_WithdrawSuccessG",[_value] call life_fnc_numberText];
CASH = CASH + _value;
[] call life_fnc_atmMenu;
43 changes: 0 additions & 43 deletions Altis_Life.Altis/dialog/function/fn_gangDeposit.sqf

This file was deleted.

44 changes: 0 additions & 44 deletions Altis_Life.Altis/dialog/function/fn_gangWithdraw.sqf

This file was deleted.

36 changes: 36 additions & 0 deletions Altis_Life.Altis/dialog/function/fn_useGangBank.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "..\..\script_macros.hpp"
/*
File: fn_gangWithdraw.sqf
Author: Bryan "Tonic" Boardwine
Description:
Withdraws money from the gang bank.
*/
params [
["_deposit",false,[false]]
];

private _value = parseNumber(ctrlText 2702);
private _gFund = GANG_FUNDS;
if ((time - life_action_delay) < 0.5) exitWith {hint localize "STR_NOTF_ActionDelay"};

//Series of stupid checks
if (isNil {(group player) getVariable "gang_name"}) exitWith {hint localize "STR_ATM_NotInGang"}; // Checks if player isn't in a gang
if (_value > 999999) exitWith {hint localize "STR_ATM_WithdrawMax";};
if (_value < 1) exitWith {};
if (!([str(_value)] call TON_fnc_isnumber)) exitWith {hint localize "STR_ATM_notnumeric"};
if (_deposit && _value > CASH) exitWith {hint localize "STR_ATM_NotEnoughCash"};
if (!_deposit && _value > _gFund) exitWith {hint localize "STR_ATM_NotEnoughFundsG"};

if (_deposit) then {
CASH = CASH - _value;
[] call life_fnc_atmMenu;
};

if (life_HC_isActive) then {
[1,group player,_deposit,_value,player,CASH] remoteExecCall ["HC_fnc_updateGang",HC_Life]; //Update the database.
} else {
[1,group player,_deposit,_value,player,CASH] remoteExecCall ["TON_fnc_updateGang",RSERV]; //Update the database.
};

life_action_delay = time;
12 changes: 6 additions & 6 deletions Altis_Life.Altis/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1308,16 +1308,16 @@
<Chinesesimp>你已将 $%1 存入到你的银行账户</Chinesesimp>
</Key>
<Key ID="STR_ATM_DepositSuccessG">
<Original>You have deposited $%1 into your gang's bank account</Original>
<Czech>Máte uloženy $%1 na bankovní účet svého gangu</Czech>
<Spanish>Has depositado $%1 en la cuenta de tu pandilla</Spanish>
<Original>You have deposited $%1 into your gang's bank account.</Original>
<Czech>Máte uloženy $%1 na bankovní účet svého gangu.</Czech>
<Spanish>Has depositado $%1 en la cuenta de tu pandilla.</Spanish>
<Russian></Russian>
<German>Du hast $%1 auf das Gangkonto überwiesen.</German>
<French>Vous avez déposé $%1 sur le compte en banque de votre gang.</French>
<Italian>Hai despositato €%1 nei fondi della tua gang</Italian>
<Italian>Hai despositato €%1 nei fondi della tua gang.</Italian>
<Portuguese>Você depositou R$%1 na conta da sua gangue.</Portuguese>
<Polish>Zdeponowałeś na koncie gangu kwotę $%1 </Polish>
<Chinesesimp>你已将 $%1 存入到你的帮派账户</Chinesesimp>
<Polish>Zdeponowałeś na koncie gangu kwotę $%1.</Polish>
<Chinesesimp>你已将 $%1 存入到你的帮派账户.</Chinesesimp>
</Key>
<Key ID="STR_ATM_DepositInUseG">
<Original>Someone is already trying to deposit into your gang's bank account.</Original>
Expand Down
2 changes: 1 addition & 1 deletion BEFilters/remoteexec.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//regex
1 "" !="_this call fn_whoDoneIt"
5 "" !BIS_fnc_(effectKilled(AirDestruction|Secondaries)|execVM) !DB_fnc_(insertRequest|queryRequest|updatePartial|updateRequest) !HC_fnc_(addContainer|addHouse|chopShopSell|deleteDBContainer|getVehicles|insertGang|insertRequest|jailSys|queryRequest|receivekeyofServer) !HC_fnc_(removeGang|sellHouse(Container)?|spawnVehicle|spikeStrip) !HC_fnc_update(Gang|HouseContainers|HouseTrunk|Partial|Request) !HC_fnc_vehicle(Create|Delete|Store|Update) !HC_fnc_wanted(Add|Bounty|Crimes|Fetch|ProfUpdate|Remove) !life_fnc_(AAN|addVehicle2Chain|adminid|admininfo|animSync|bountyReceive|broadcast|colorVehicle|copLights) !life_fnc_(copSearch|CopSiren|corpse|demoChargeTimer|flashbang|freezePlayer|gangCreated|gangDisbanded|gangInvite) !life_fnc_(garageRefund|giveDiff|hideObj|impoundMenu|jail(Me|Sys)?) !life_fnc_(jumpFnc|knockedOut|licenseCheck|licensesRead|lightHouse|lockVehicle|medic(Lights|Request|Siren)) !life_fnc_(moveIn|pickupItem|pickupMoney|pulloutVeh|receiveItem|receiveMoney|removeLicenses|restrain|revived) !life_fnc_(robPerson|robReceive|say3D|searchClient|seizeClient|setFuel|simDisable|soundDevice|spikeStripEffect) !life_fnc_(tazeSound|ticketPaid|ticketPrompt|vehicleAnimate) !life_fnc_wanted(Add|Bounty|Crimes|Fetch|Info|List|ProfUpdate|Remove) !life_fnc_wireTransfer !SOCK_fnc_(dataQuery|insertPlayerInfo|updateRequest) !SPY_fnc_(cookieJar|notifyAdmins|observe) !TON_fnc_(addContainer|addHouse|chopShopSell|cleanupRequest|handleBlastingCharge) !TON_fnc_clientGang(Kick|Leader|Left) !TON_fnc_(clientGetKey|clientMessage) !TON_fnc_(deleteDBContainer|getID|getVehicles|insertGang|keyManagement|managesc|pickupAction|player_query|recupkeyforHC) !TON_fnc_(removeGang|sellHouse(Container)?|spawnVehicle|spikeStrip) !TON_fnc_update(Gang|HouseContainers|HouseTrunk) !TON_fnc_vehicle(Create|Delete|Store|Update) !="_this call fn_whoDoneIt"
5 "" !BIS_fnc_(effectKilled(AirDestruction|Secondaries)|execVM) !DB_fnc_(insertRequest|queryRequest|updatePartial|updateRequest) !HC_fnc_(addContainer|addHouse|chopShopSell|deleteDBContainer|getVehicles|insertGang|insertRequest|jailSys|queryRequest|receivekeyofServer) !HC_fnc_(removeGang|sellHouse(Container)?|spawnVehicle|spikeStrip) !HC_fnc_update(Gang|HouseContainers|HouseTrunk|Partial|Request) !HC_fnc_vehicle(Create|Delete|Store|Update) !HC_fnc_wanted(Add|Bounty|Crimes|Fetch|ProfUpdate|Remove) !life_fnc_(AAN|addVehicle2Chain|adminid|admininfo|animSync|bountyReceive|broadcast|colorVehicle|copLights) !life_fnc_(copSearch|CopSiren|corpse|demoChargeTimer|flashbang|freezePlayer|gangCreated|gangDisbanded|gangInvite) !life_fnc_(garageRefund|giveDiff|hideObj|impoundMenu|jail(Me|Sys)?) !life_fnc_(jumpFnc|knockedOut|licenseCheck|licensesRead|lightHouse|lockVehicle|medic(Lights|Request|Siren)) !life_fnc_(moveIn|pickupItem|pickupMoney|pulloutVeh|receiveItem|receiveMoney|removeLicenses|restrain|revived) !life_fnc_(robPerson|robReceive|say3D|searchClient|seizeClient|setFuel|simDisable|soundDevice|spikeStripEffect) !life_fnc_(tazeSound|ticketPaid|ticketPrompt|vehicleAnimate|gangBankResponse) !life_fnc_wanted(Add|Bounty|Crimes|Fetch|Info|List|ProfUpdate|Remove) !life_fnc_wireTransfer !SOCK_fnc_(dataQuery|insertPlayerInfo|updateRequest) !SPY_fnc_(cookieJar|notifyAdmins|observe) !TON_fnc_(addContainer|addHouse|chopShopSell|cleanupRequest|handleBlastingCharge) !TON_fnc_clientGang(Kick|Leader|Left) !TON_fnc_(clientGetKey|clientMessage) !TON_fnc_(deleteDBContainer|getID|getVehicles|insertGang|keyManagement|managesc|pickupAction|player_query|recupkeyforHC) !TON_fnc_(removeGang|sellHouse(Container)?|spawnVehicle|spikeStrip) !TON_fnc_update(Gang|HouseContainers|HouseTrunk) !TON_fnc_vehicle(Create|Delete|Store|Update) !="_this call fn_whoDoneIt"
36 changes: 35 additions & 1 deletion life_hc/MySQL/Gangs/fn_updateGang.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_updateGang.sqf
Author: Bryan "Tonic" Boardwine
Expand Down Expand Up @@ -30,7 +31,40 @@ switch (_mode) do {
};

case 1: {
_query = format ["UPDATE gangs SET bank='%1' WHERE id='%2'",([(_group getVariable ["gang_bank",0])] call HC_fnc_numberSafe),_groupID];
params [
"",
"",
["_deposit",false,[false]],
["_value",0,[0]],
["_unit",objNull,[objNull]],
["_cash",0,[0]]
];

private _funds = _group getVariable ["gang_bank",0];
if (_deposit) then {
_funds = _funds + _value;
_group setVariable ["gang_bank",_funds,true];
[1,"STR_ATM_DepositSuccessG",true,[_value]] remoteExecCall ["life_fnc_broadcast",remoteExecutedOwner];
_cash = _cash - _value;
} else {
if (_value > _funds) exitWith {
[1,"STR_ATM_NotEnoughFundsG",true] remoteExecCall ["life_fnc_broadcast",remoteExecutedOwner];
breakOut "";
};
_funds = _funds - _value;
_group setVariable ["gang_bank",_funds,true];
[_value] remoteExecCall ["life_fnc_gangBankResponse",remoteExecutedOwner];
_cash = _cash + _value;
};
if (LIFE_SETTINGS(getNumber,"player_moneyLog") isEqualTo 1) then {
if (LIFE_SETTINGS(getNumber,"battlEye_friendlyLogging") isEqualTo 1) then {
diag_log (format [localize "STR_DL_ML_withdrewGang_BEF",_value,[_funds] call life_fnc_numberText,[0] call life_fnc_numberText,[_cash] call life_fnc_numberText]);
} else {
diag_log (format [localize "STR_DL_ML_withdrewGang",name _unit,(getPlayerUID _unit),_value,[_funds] call life_fnc_numberText,[0] call life_fnc_numberText,[_cash] call life_fnc_numberText]);
};
};
_query = format ["UPDATE gangs SET bank='%1' WHERE id='%2'",([_funds] call HC_fnc_numberSafe),_groupID];
[getPlayerUID _unit,side _unit,_cash,0] call HC_fnc_updatePartial;
};

case 2: {
Expand Down
Loading

0 comments on commit b7c1cbc

Please sign in to comment.