diff --git a/SQF/dayz_code/actions/remoteVehicle/vehicleInfo.sqf b/SQF/dayz_code/actions/remoteVehicle/vehicleInfo.sqf index 8fc6a2390..a823ba32f 100644 --- a/SQF/dayz_code/actions/remoteVehicle/vehicleInfo.sqf +++ b/SQF/dayz_code/actions/remoteVehicle/vehicleInfo.sqf @@ -1,11 +1,4 @@ -private ["_backPackCount","_backPackCount_raw","_backPackSlots","_formattedText","_gearCount","_magazineCount","_magazineCount_raw","_magazineSlots","_name","_picture","_price","_text","_typeOf","_weaponSlots","_weaponsCount","_weaponsCount_raw","_control","_index"]; - -_gearCount = { - private ["_counter"]; - _counter = 0; - {_counter = _counter + _x;} count _this; - _counter -}; +private ["_backPackCount","_backPackCount_raw","_backPackSlots","_formattedText","_magazineCount","_magazineCount_raw","_magazineSlots","_name","_picture","_price","_text","_typeOf","_weaponSlots","_weaponsCount","_weaponsCount_raw","_control","_index"]; _control = (_this select 0) select 0; _index = (_this select 0) select 1; @@ -23,9 +16,9 @@ _backPackSlots = getNumber(configFile >> "CfgVehicles" >> _typeOf >> "transportm _name = getText(configFile >> "CfgVehicles" >> _typeOf >> "displayName"); _picture = getText(configFile >> 'CfgVehicles' >> _typeOf >> 'picture'); -_weaponsCount = (_weaponsCount_raw select 1) call _gearCount; -_magazineCount = (_magazineCount_raw select 1) call _gearCount; -_backPackCount = (_backPackCount_raw select 1) call _gearCount; +_weaponsCount = (_weaponsCount_raw select 1) call fnc_gearCount; +_magazineCount = (_magazineCount_raw select 1) call fnc_gearCount; +_backPackCount = (_backPackCount_raw select 1) call fnc_gearCount; _formattedText = format [ "
" + diff --git a/SQF/dayz_code/actions/virtualGarage/player_storeVehicle.sqf b/SQF/dayz_code/actions/virtualGarage/player_storeVehicle.sqf index 80c8286bb..2212fd012 100644 --- a/SQF/dayz_code/actions/virtualGarage/player_storeVehicle.sqf +++ b/SQF/dayz_code/actions/virtualGarage/player_storeVehicle.sqf @@ -1,7 +1,7 @@ // Developed by [GZA] David for German Zombie Apocalypse Servers (https://zombieapo.eu/) // Rewritten by salival (https://github.com/oiad) -private ["_amount","_backPackCount","_backPackGear","_cargoAmount","_charID","_control","_counter","_display","_enoughMoney","_gearCount","_hasKey","_isLimitArray","_itemText","_items","_keyName","_limit","_magazineCount","_matchedCount","_moneyInfo","_name","_overLimit","_storedVehicles","_success","_typeName","_typeOf","_vehicle","_wealth","_weaponsCount","_woGear","_playerNear","_ownerPUID","_plotCheck"]; +private ["_amount","_backPackCount","_backPackGear","_cargoAmount","_charID","_control","_counter","_display","_enoughMoney","_hasKey","_isLimitArray","_itemText","_items","_keyName","_limit","_magazineCount","_matchedCount","_moneyInfo","_name","_overLimit","_storedVehicles","_success","_typeName","_typeOf","_vehicle","_wealth","_weaponsCount","_woGear","_playerNear","_ownerPUID","_plotCheck"]; disableSerialization; @@ -25,13 +25,6 @@ if (_overLimit) exitWith {localize "STR_CL_VG_BLACKLISTED" call dayz_rollingMess }; } count vg_vehicleList; -_gearCount = { - private ["_counter"]; - _counter = 0; - {_counter = _counter + _x;} count _this; - _counter -}; - if (_isLimitArray) then { { _typeName = _x select 0; @@ -65,9 +58,9 @@ closeDialog 0; if (!vg_storeWithGear && !_woGear) exitWith {localize "STR_CL_VG_NOSTOREWITHGEAR" call dayz_rollingMessages;}; _charID = _vehicle getVariable ["CharacterID","0"]; -_weaponsCount = ((getWeaponCargo _vehicle) select 1) call _gearCount; -_magazineCount = ((getMagazineCargo _vehicle) select 1) call _gearCount; -_backPackCount = ((getBackpackCargo _vehicle) select 1) call _gearCount; +_weaponsCount = ((getWeaponCargo _vehicle) select 1) call fnc_gearCount; +_magazineCount = ((getMagazineCargo _vehicle) select 1) call fnc_gearCount; +_backPackCount = ((getBackpackCargo _vehicle) select 1) call fnc_gearCount; _cargoAmount = (_weaponsCount + _magazineCount + _backPackCount); if (_charID == "-1") exitWith {localize "STR_CL_VG_STORE_MISSION" call dayz_rollingMessages;}; diff --git a/SQF/dayz_code/actions/virtualGarage/vehicleInfo.sqf b/SQF/dayz_code/actions/virtualGarage/vehicleInfo.sqf index 9b752779e..bbebf0c1f 100644 --- a/SQF/dayz_code/actions/virtualGarage/vehicleInfo.sqf +++ b/SQF/dayz_code/actions/virtualGarage/vehicleInfo.sqf @@ -10,19 +10,13 @@ _index = (_this select 0) select 1; _localVehicle = typeName (vg_vehicleList select _index) == "OBJECT"; _DateMaintained = ""; _MaintainDays = -1; -_gearCount = { - private ["_counter"]; - _counter = 0; - {_counter = _counter + _x;} count _this; - _counter; -}; if (_localVehicle) then { _vehicle = vg_vehicleList select _index; _typeOf = typeOf _vehicle; - _weaponsCount = ((getWeaponCargo _vehicle) select 1) call _gearCount; - _magazineCount = ((getMagazineCargo _vehicle) select 1) call _gearCount; - _backPackCount = ((getBackpackCargo _vehicle) select 1) call _gearCount; + _weaponsCount = ((getWeaponCargo _vehicle) select 1) call fnc_gearCount; + _magazineCount = ((getMagazineCargo _vehicle) select 1) call fnc_gearCount; + _backPackCount = ((getBackpackCargo _vehicle) select 1) call fnc_gearCount; ctrlShow[2852,false]; // getVehicle ctrlShow[2850,true]; // storeVehicle ctrlShow[2851,true]; // storeVehicleWithGear diff --git a/SQF/dayz_code/actions/vkc/vehicleInfo.sqf b/SQF/dayz_code/actions/vkc/vehicleInfo.sqf index e430206b3..097ff1d68 100644 --- a/SQF/dayz_code/actions/vkc/vehicleInfo.sqf +++ b/SQF/dayz_code/actions/vkc/vehicleInfo.sqf @@ -1,11 +1,4 @@ -private ["_backPackCount","_backPackCount_raw","_backPackSlots","_formattedText","_gearCount","_magazineCount","_magazineCount_raw","_magazineSlots","_name","_picture","_price","_text","_typeOf","_weaponSlots","_weaponsCount","_weaponsCount_raw"]; - -_gearCount = { - private ["_counter"]; - _counter = 0; - {_counter = _counter + _x;} count _this; - _counter -}; +private ["_backPackCount","_backPackCount_raw","_backPackSlots","_formattedText","_magazineCount","_magazineCount_raw","_magazineSlots","_name","_picture","_price","_text","_typeOf","_weaponSlots","_weaponsCount","_weaponsCount_raw"]; if (vkc_action == "claim") then { ctrlShow[4850,true]; @@ -28,9 +21,9 @@ _backPackSlots = getNumber(configFile >> "CfgVehicles" >> _typeOf >> "transportm _name = getText(configFile >> "CfgVehicles" >> _typeOf >> "displayName"); _picture = getText(configFile >> 'CfgVehicles' >> _typeOf >> 'picture'); -_weaponsCount = (_weaponsCount_raw select 1) call _gearCount; -_magazineCount = (_magazineCount_raw select 1) call _gearCount; -_backPackCount = (_backPackCount_raw select 1) call _gearCount; +_weaponsCount = (_weaponsCount_raw select 1) call fnc_gearCount; +_magazineCount = (_magazineCount_raw select 1) call fnc_gearCount; +_backPackCount = (_backPackCount_raw select 1) call fnc_gearCount; if (!isNil "sk_dualCurrency") then {if (z_singleCurrency) then {_price = _price * 10};}; diff --git a/SQF/dayz_code/actions/zsc/zscFunctions.sqf b/SQF/dayz_code/actions/zsc/zscFunctions.sqf index 3eb8ae100..e759bf554 100644 --- a/SQF/dayz_code/actions/zsc/zscFunctions.sqf +++ b/SQF/dayz_code/actions/zsc/zscFunctions.sqf @@ -1,18 +1,3 @@ -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"]; @@ -39,7 +24,7 @@ GivePlayerDialogAmounts = { BankDialogWithdrawAmount = { private ["_amount","_bank","_wealth","_vehicleType","_displayName"]; - _amount = (_this select 0) call fnc_sanitizeInput; + _amount = [(_this select 0),0] call fnc_sanitizeInput; _bank = ZSC_CurrentStorage getVariable ["cashMoney",0]; _wealth = player getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0]; _vehicleType = typeOf ZSC_CurrentStorage; @@ -75,7 +60,7 @@ BankDialogDepositAmount = { _displayName = "Unknown"; }; - _amount = (_this select 0) call fnc_sanitizeInput; + _amount = [(_this select 0),0] call fnc_sanitizeInput; _bank = ZSC_CurrentStorage getVariable ["cashMoney",0]; _wealth = player getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0]; @@ -97,7 +82,7 @@ BankDialogDepositAmount = { GivePlayerAmount = { private ["_amount","_wealth","_twealth","_isBusy"]; - _amount = (_this select 0) call fnc_sanitizeInput; + _amount = [(_this select 0),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]; @@ -126,7 +111,7 @@ if (Z_globalBanking) then { ATMDialogWithdrawAmount = { private ["_amount","_bank","_wealth"]; - _amount = (_this select 0) call fnc_sanitizeInput; + _amount = [(_this select 0),0] call fnc_sanitizeInput; _bank = player getVariable ["bankMoney",0]; _wealth = player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0]; @@ -142,7 +127,7 @@ if (Z_globalBanking) then { ATMDialogDepositAmount = { private ["_amount","_bank","_wealth"]; - _amount = (_this select 0) call fnc_sanitizeInput; + _amount = [(_this select 0),0] call fnc_sanitizeInput; _bank = player getVariable ["bankMoney",0]; _wealth = player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0]; diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index e62897049..b930ba15e 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -964,6 +964,30 @@ fnc_lockCode = { _code }; +fnc_gearCount = { + local _counter = 0; + {_counter = _counter + _x;} count _this; + _counter +}; + +fnc_sanitizeInput = { + local _input = _this select 0; + local _type = _this select 1; // 0 = Number, 1 = String + + _input = toArray (_input); + local _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 = toString (_input); + + if (_type == 0) then {_input = parseNumber _input;}; + + _input +}; + // Enable this if your server got nuked on Chernarus or Chernarus Winter. /* if (toLower worldName in ["chernarus","chernarus_winter"]) then { //need to add building coordinates for other maps diff --git a/SQF/dayz_server/compile/garage/server_storeVehicle.sqf b/SQF/dayz_server/compile/garage/server_storeVehicle.sqf index 3e969e079..9da83cfd2 100644 --- a/SQF/dayz_server/compile/garage/server_storeVehicle.sqf +++ b/SQF/dayz_server/compile/garage/server_storeVehicle.sqf @@ -1,4 +1,4 @@ -private ["_damageVeh","_VGobjID","_array","_backPack","_backPackCount","_charID","_class","_clientID","_colour","_colour2","_damage","_displayName","_fnc_sanitizeInput","_fuel","_gearCount","_hit","_hitpoints","_index","_inventory","_inventoryCount","_key","_magazine","_magazineCount","_message","_name","_objectID","_objectUID","_player","_playerUID","_selection","_vehicle","_weapons","_weaponsCount","_woGear"]; +private ["_damageVeh","_VGobjID","_array","_backPack","_backPackCount","_charID","_class","_clientID","_colour","_colour2","_damage","_displayName","_fuel","_hit","_hitpoints","_index","_inventory","_inventoryCount","_key","_magazine","_magazineCount","_message","_name","_objectID","_objectUID","_player","_playerUID","_selection","_vehicle","_weapons","_weaponsCount","_woGear"]; _vehicle = _this select 0; _player = _this select 1; @@ -6,31 +6,9 @@ _woGear = _this select 2; _clientID = owner _player; _playerUID = if (count _this > 3) then {_this select 3} else {getPlayerUID _player}; -_gearCount = { - private ["_counter"]; - _counter = 0; - {_counter = _counter + _x;} count _this; - _counter; -}; - -_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 = toString (_input); - _input -}; - _class = typeOf _vehicle; -_displayName = (getText(configFile >> "cfgVehicles" >> _class >> "displayName")) call _fnc_sanitizeInput; -_name = if (alive _player) then {(name _player) call _fnc_sanitizeInput;} else {"unknown player";}; +_displayName = [(getText(configFile >> "cfgVehicles" >> _class >> "displayName")),1] call fnc_sanitizeInput; +_name = if (alive _player) then {[(name _player),1] call fnc_sanitizeInput;} else {"unknown player";}; _charID = _vehicle getVariable ["CharacterID","0"]; _objectID = _vehicle getVariable ["ObjectID","0"]; @@ -71,9 +49,9 @@ if (!_woGear) then { _weapons = getWeaponCargo _vehicle; _magazine = getMagazineCargo _vehicle; _backPack = getBackpackCargo _vehicle; - _weaponsCount = (_weapons select 1) call _gearCount; - _magazineCount = (_magazine select 1) call _gearCount; - _backPackCount = (_backPack select 1) call _gearCount; + _weaponsCount = (_weapons select 1) call fnc_gearCount; + _magazineCount = (_magazine select 1) call fnc_gearCount; + _backPackCount = (_backPack select 1) call fnc_gearCount; _inventory = [_weapons, _magazine, _backPack]; _inventoryCount = [_weaponsCount, _magazineCount, _backPackCount]; };