From 9a03587efb6ff7770fa6ad32b7230845d567ea35 Mon Sep 17 00:00:00 2001 From: worldwidesorrow Date: Wed, 29 Jul 2020 15:23:51 -0500 Subject: [PATCH] Add files via upload --- SQF/dayz_code/actions/zsc/atmDialog.sqf | 20 +++ SQF/dayz_code/actions/zsc/bankDialog.sqf | 38 +++++ SQF/dayz_code/actions/zsc/checkWallet.sqf | 29 ++++ SQF/dayz_code/actions/zsc/givePlayer.sqf | 30 ++++ SQF/dayz_code/actions/zsc/vehDialog.sqf | 38 +++++ SQF/dayz_code/actions/zsc/zscFunctions.sqf | 160 +++++++++++++++++++++ 6 files changed, 315 insertions(+) create mode 100644 SQF/dayz_code/actions/zsc/atmDialog.sqf create mode 100644 SQF/dayz_code/actions/zsc/bankDialog.sqf create mode 100644 SQF/dayz_code/actions/zsc/checkWallet.sqf create mode 100644 SQF/dayz_code/actions/zsc/givePlayer.sqf create mode 100644 SQF/dayz_code/actions/zsc/vehDialog.sqf create mode 100644 SQF/dayz_code/actions/zsc/zscFunctions.sqf diff --git a/SQF/dayz_code/actions/zsc/atmDialog.sqf b/SQF/dayz_code/actions/zsc/atmDialog.sqf new file mode 100644 index 000000000..dddc1dee8 --- /dev/null +++ b/SQF/dayz_code/actions/zsc/atmDialog.sqf @@ -0,0 +1,20 @@ +if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; +dayz_actionInProgress = true; + +private ["_typeOf"]; + +player setVariable["isBusy",true,true]; +_typeOf = typeOf (_this select 3); + +if !(_typeOf in ZSC_bankObjects || _typeOf in ZSC_bankTraders) exitWith { + dayz_actionInProgress = false; + player setVariable["isBusy",false,true]; + format[localize "STR_CL_ZSC_BANKING_NOT_AVAIL",_typeOf] call dayz_rollingMessages; +}; + +createDialog "atmDialog"; +call AtmDialogUpdateAmounts; + +waitUntil {!dialog}; + +dayz_actionInProgress = false; diff --git a/SQF/dayz_code/actions/zsc/bankDialog.sqf b/SQF/dayz_code/actions/zsc/bankDialog.sqf new file mode 100644 index 000000000..f58ccfe73 --- /dev/null +++ b/SQF/dayz_code/actions/zsc/bankDialog.sqf @@ -0,0 +1,38 @@ +if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; +dayz_actionInProgress = true; + +private ["_playerNear","_isBusy","_typeOf"]; + +player setVariable["isBusy",true,true]; +_isBusy = true; +ZSC_CurrentStorage = _this select 3; +_typeOf = typeOf ZSC_CurrentStorage; + + +if !(_typeOf in DZE_MoneyStorageClasses) exitWith { + dayz_actionInProgress = false; + player setVariable["isBusy",false,true]; + format[localize "STR_CL_ZSC_BANKING_NOT_AVAIL",_typeOf] call dayz_rollingMessages; +}; + +_playerNear = {isPlayer _x} count ((getPosATL cursortarget) nearEntities ["CAManBase", 10]) > 1; +if (_playerNear) exitWith { + dayz_actionInProgress = false; + player setVariable["isBusy",false,true]; + localize "str_pickup_limit_5" call dayz_rollingMessages; +}; + +_isBusy = ZSC_CurrentStorage getVariable["isBusy",false]; +if (_isBusy) exitwith { + dayz_actionInProgress = false; + player setVariable["isBusy",false,true]; + format[localize "STR_CL_ZSC_BANKING_IN_USE",_typeOf] call dayz_rollingMessages; +}; + +ZSC_CurrentStorage setVariable["isBusy",true,true]; +createDialog "BankDialog"; +call BankDialogUpdateAmounts; + +waitUntil {!dialog}; + +dayz_actionInProgress = false; diff --git a/SQF/dayz_code/actions/zsc/checkWallet.sqf b/SQF/dayz_code/actions/zsc/checkWallet.sqf new file mode 100644 index 000000000..151e7fa32 --- /dev/null +++ b/SQF/dayz_code/actions/zsc/checkWallet.sqf @@ -0,0 +1,29 @@ +private ["_body","_playerNear","_name","_hisMoney","_myMoney"]; + +if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; +dayz_actionInProgress = true; + +_body = _this select 3; + +if (isNull _body) exitWith {dayz_actionInProgress = false; systemChat "cursorTarget isNull!";}; + +_playerNear = {isPlayer _x} count ((getPosATL _body) nearEntities ["CAManBase", 10]) > 1; +if (_playerNear) exitWith {dayz_actionInProgress = false;localize "str_pickup_limit_5" call dayz_rollingMessages;}; + +_name = _body getVariable ["bodyName","unknown"]; +_hisMoney = _body getVariable ["cashMoney",0]; + +if (isNil "_hisMoney") then {_hisMoney = 0;}; +if (!(typeName _hisMoney == "SCALAR") || {_hisMoney < 1}) exitWith {dayz_actionInProgress = false; format[localize "STR_CL_ZSC_NO_COINS",_name,CurrencyName] call dayz_rollingMessages}; + +_myMoney = player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0]; +_myMoney = _myMoney + _hisMoney; + +_body setVariable ["cashMoney",0,true]; +player setVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),_myMoney,true]; + +systemChat format[localize "STR_CL_ZSC_TAKE_COINS",[_hisMoney] call BIS_fnc_numberText,CurrencyName,_name]; + +player playActionNow "PutDown"; + +dayz_actionInProgress = false; diff --git a/SQF/dayz_code/actions/zsc/givePlayer.sqf b/SQF/dayz_code/actions/zsc/givePlayer.sqf new file mode 100644 index 000000000..a4bd096e1 --- /dev/null +++ b/SQF/dayz_code/actions/zsc/givePlayer.sqf @@ -0,0 +1,30 @@ +if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; +dayz_actionInProgress = true; + +disableSerialization; +private ["_display","_isBusy"]; + +_isBusy = true; +player setVariable["isBusy",true,true]; + +if (isPlayer cursorTarget) then { + ZSC_GiveMoneyTarget = cursorTarget; + _isBusy = ZSC_GiveMoneyTarget getVariable["isBusy",false]; + if (_isBusy) exitWith { + player setVariable ["isBusy",false,true]; + format[localize "STR_CL_ZSC_ALREADY_TRADING",name ZSC_GiveMoneyTarget] call dayz_rollingMessages; + }; + if (!_isBusy) then { + player setVariable["isBusy",true,true]; + createDialog "GivePlayerDialog"; + _display = uiNamespace getVariable["zsc_dialogs", displayNull]; + _display displayCtrl 14002 ctrlSetText(format[localize "STR_CL_ZSC_TRANSFER_COINS",CurrencyName]); + call GivePlayerDialogAmounts; + }; +} else { + localize "STR_CL_ZSC_NOT_PLAYER" call dayz_rollingMessages; +}; + +waitUntil {!dialog}; + +dayz_actionInProgress = false; diff --git a/SQF/dayz_code/actions/zsc/vehDialog.sqf b/SQF/dayz_code/actions/zsc/vehDialog.sqf new file mode 100644 index 000000000..764ddb558 --- /dev/null +++ b/SQF/dayz_code/actions/zsc/vehDialog.sqf @@ -0,0 +1,38 @@ +if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; +dayz_actionInProgress = true; + +private ["_playerNear","_isBusy","_typeOf"]; + +player setVariable["isBusy",true,true]; +_isBusy = true; +ZSC_CurrentStorage = _this select 3; +_typeOf = typeOf ZSC_CurrentStorage; + + +if !(ZSC_CurrentStorage isKindOf "AllVehicles") exitWith { + dayz_actionInProgress = false; + player setVariable["isBusy",false,true]; + format[localize "STR_CL_ZSC_BANKING_NOT_AVAIL",_typeOf] call dayz_rollingMessages; +}; + +_playerNear = {isPlayer _x} count ((getPosATL cursortarget) nearEntities ["CAManBase", 10]) > 1; +if (_playerNear) exitWith { + dayz_actionInProgress = false; + player setVariable["isBusy",false,true]; + localize "str_pickup_limit_5" call dayz_rollingMessages; +}; + +_isBusy = ZSC_CurrentStorage getVariable["isBusy",false]; +if (_isBusy) exitwith { + dayz_actionInProgress = false; + player setVariable["isBusy",false,true]; + format[localize "STR_CL_ZSC_BANKING_IN_USE",_typeOf] call dayz_rollingMessages; +}; + +ZSC_CurrentStorage setVariable["isBusy",true,true]; +createDialog "BankDialog"; +call BankDialogUpdateAmounts; + +waitUntil {!dialog}; + +dayz_actionInProgress = false; diff --git a/SQF/dayz_code/actions/zsc/zscFunctions.sqf b/SQF/dayz_code/actions/zsc/zscFunctions.sqf new file mode 100644 index 000000000..3eb8ae100 --- /dev/null +++ b/SQF/dayz_code/actions/zsc/zscFunctions.sqf @@ -0,0 +1,160 @@ +fnc_sanitizeInput = { + private ["_input","_badChars"]; + + _input = _this; + _input = toArray (_input); + _badChars = [60,62,38,123,125,91,93,59,58,39,96,126,44,46,47,63,124,92,34]; + + { + _input = _input - [_x]; + } forEach _badChars; + + _input = parseNumber (toString (_input)); + _input +}; + +BankDialogUpdateAmounts = { + private ["_vehicleType","_displayName","_sizeOfMoney"]; + + _vehicleType = typeOf ZSC_CurrentStorage; + if (isClass(configFile >> "CfgVehicles" >> _vehicleType)) then { + _vehicleMagazines = getNumber (configFile >> "CfgVehicles" >> _vehicleType >> "transportMaxMagazines"); + if (_vehicleMagazines == 0) then {_vehicleMagazines = ZSC_defaultStorageMultiplier}; + _displayName = getText (configFile >> "CfgVehicles" >> _vehicleType >> "displayName"); + _sizeOfMoney = _vehicleMagazines * ZSC_MaxMoneyInStorageMultiplier; + ctrlSetText [2701, format ["%1",_displayName]]; + ctrlSetText [13001,format ["%1 %2",[player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0]] call BIS_fnc_numberText,CurrencyName]]; + ctrlSetText [13002,format ["%1 / %3 %2",[ZSC_CurrentStorage getVariable ["cashMoney",0]] call BIS_fnc_numberText,CurrencyName,[_sizeOfMoney] call BIS_fnc_numberText]]; + } else { + ctrlSetText [13001,localize "STR_CL_ZSC_VEHICLE_CAPACITY"]; + ctrlSetText [13002,localize "STR_CL_ZSC_VEHICLE_CAPACITY"]; + }; +}; + +GivePlayerDialogAmounts = { + ctrlSetText [14001,format ["%1 %2",[player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0]] call BIS_fnc_numberText,CurrencyName]]; + ctrlSetText [14003,format ["%1",name ZSC_GiveMoneyTarget]]; +}; + +BankDialogWithdrawAmount = { + private ["_amount","_bank","_wealth","_vehicleType","_displayName"]; + + _amount = (_this select 0) call fnc_sanitizeInput; + _bank = ZSC_CurrentStorage getVariable ["cashMoney",0]; + _wealth = player getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0]; + _vehicleType = typeOf ZSC_CurrentStorage; + _displayName = getText (configFile >> "CfgVehicles" >> _vehicleType >> "displayName"); + + if (!isNull ZSC_CurrentStorage) then { + if ((_amount < 1) or {_amount > _bank}) exitWith {format[localize "STR_CL_ZSC_WITHDRAW_FAIL",CurrencyName,_displayName] call dayz_rollingMessages;}; + + player setVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),(_wealth + _amount),true]; + ZSC_CurrentStorage setVariable["cashMoney",(_bank - _amount),true]; + call player_forceSave; + + PVDZ_veh_Save = [ZSC_CurrentStorage,"coins"]; + publicVariableServer "PVDZ_veh_Save"; + + format[localize "STR_CL_ZSC_WITHDRAW_OK",[_amount] call BIS_fnc_numberText,CurrencyName,_displayName] call dayz_rollingMessages; + } else { + localize "STR_CL_ZSC_UNABLE" call dayz_rollingMessages; + }; +}; + +BankDialogDepositAmount = { + private ["_amount","_bank","_wealth","_maxCap","_vehicleType","_displayName","_vehicleMagazines"]; + + _vehicleType = typeOf ZSC_CurrentStorage; + _maxCap = 0; + _displayName = "Storage"; + if (isClass(configFile >> "CfgVehicles" >> _vehicleType)) then { + _displayName = getText (configFile >> "CfgVehicles" >> _vehicleType >> "displayName"); + _vehicleMagazines = getNumber (configFile >> "CfgVehicles" >> _vehicleType >> "transportMaxMagazines"); + _maxCap = _vehicleMagazines * ZSC_MaxMoneyInStorageMultiplier; + } else { + _displayName = "Unknown"; + }; + + _amount = (_this select 0) call fnc_sanitizeInput; + _bank = ZSC_CurrentStorage getVariable ["cashMoney",0]; + _wealth = player getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0]; + + if ((_amount < 1) or {_amount > _wealth}) exitWith {format[localize "STR_CL_ZSC_DEPOSIT_FAIL",CurrencyName] call dayz_rollingMessages;}; + + if ((_bank + _amount) > _maxCap) then { + format[localize "STR_CL_ZSC_STORE_FAIL",[_maxCap] call BIS_fnc_numberText,CurrencyName,_displayName] call dayz_rollingMessages; + } else { + player setVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),(_wealth - _amount),true]; + ZSC_CurrentStorage setVariable["cashMoney",(_bank + _amount),true]; + format[localize "STR_CL_ZSC_DEPOSIT_OK",[_amount] call BIS_fnc_numberText,CurrencyName,_displayName] call dayz_rollingMessages; + }; + + call player_forceSave; + PVDZ_veh_Save = [ZSC_CurrentStorage,"coins"]; + publicVariableServer "PVDZ_veh_Save"; +}; + +GivePlayerAmount = { + private ["_amount","_wealth","_twealth","_isBusy"]; + + _amount = (_this select 0) call fnc_sanitizeInput; + _wealth = player getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0]; + _twealth = ZSC_GiveMoneyTarget getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0]; + _isBusy = ZSC_GiveMoneyTarget getVariable ["isBusy",false]; + _vehicleType = typeOf ZSC_GiveMoneyTarget; + + if ((_amount < 1) or {_amount > _wealth}) exitWith {format[localize "STR_CL_ZSC_GIVE_FAIL",CurrencyName] call dayz_rollingMessages;}; + + if (!(isPlayer ZSC_GiveMoneyTarget)) exitWith {format[localize "STR_CL_ZSC_GIVE_PLAYER",CurrencyName] call dayz_rollingMessages;}; + + if (_isBusy) exitWith {format[localize "STR_CL_ZSC_ALREADY_TRADING",name ZSC_GiveMoneyTarget] call dayz_rollingMessages;}; + + player setVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),_wealth - _amount,true]; + ZSC_GiveMoneyTarget setVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),_twealth + _amount,true]; + + call player_forceSave; + + format[localize "STR_CL_ZSC_GIVE_OK",name ZSC_GiveMoneyTarget,[_amount] call BIS_fnc_numberText,CurrencyName] call dayz_rollingMessages; +}; + +if (Z_globalBanking) then { + ATMDialogUpdateAmounts = { + ctrlSetText [23001,format["%1 %2",player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0] call BIS_fnc_numberText,CurrencyName]]; + ctrlSetText [23002,format["%1 %2",player getVariable ["bankMoney",0] call BIS_fnc_numberText,CurrencyName]]; + }; + + ATMDialogWithdrawAmount = { + private ["_amount","_bank","_wealth"]; + + _amount = (_this select 0) call fnc_sanitizeInput; + _bank = player getVariable ["bankMoney",0]; + _wealth = player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0]; + + if ((_amount < 1) or {_amount > _bank}) exitWith {format[localize "STR_CL_ZSC_WITHDRAW_FAIL",CurrencyName,toLower (localize "STR_CL_ZSC_GLOBAL_BANK")] call dayz_rollingMessages;}; + + player setVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),(_wealth + _amount),true]; + player setVariable ["bankMoney",(_bank - _amount),true]; + call player_forceSave; + + format[localize "STR_CL_ZSC_GLOBAL_WITHDRAW",[_amount] call BIS_fnc_numberText,CurrencyName] call dayz_rollingMessages; + }; + + ATMDialogDepositAmount = { + private ["_amount","_bank","_wealth"]; + + _amount = (_this select 0) call fnc_sanitizeInput; + _bank = player getVariable ["bankMoney",0]; + _wealth = player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0]; + + if ((_amount < 1) or {_amount > _wealth}) exitWith {format[localize "STR_CL_ZSC_DEPOSIT_FAIL",CurrencyName] call dayz_rollingMessages;}; + + if (ZSC_limitOnBank && {(_bank + _amount) > ZSC_maxBankMoney}) then { + format[localize "STR_CL_ZSC_GLOBAL_DEPOSIT_FAIL", [ZSC_maxBankMoney] call BIS_fnc_numberText,CurrencyName] call dayz_rollingMessages; + } else { + player setVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),(_wealth - _amount),true]; + player setVariable ["bankMoney",(_bank + _amount),true]; + format[localize "STR_CL_ZSC_GLOBAL_DEPOSIT_OK",[_amount] call BIS_fnc_numberText,CurrencyName] call dayz_rollingMessages; + call player_forceSave; + }; + }; +};