Add global fnc_gearCount and fnc_sanitizeInput function

This commit is contained in:
A Man
2022-03-25 15:09:34 +01:00
parent bae61cc31e
commit cf6ca366d3
7 changed files with 50 additions and 90 deletions

View File

@@ -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"]; private ["_backPackCount","_backPackCount_raw","_backPackSlots","_formattedText","_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
};
_control = (_this select 0) select 0; _control = (_this select 0) select 0;
_index = (_this select 0) select 1; _index = (_this select 0) select 1;
@@ -23,9 +16,9 @@ _backPackSlots = getNumber(configFile >> "CfgVehicles" >> _typeOf >> "transportm
_name = getText(configFile >> "CfgVehicles" >> _typeOf >> "displayName"); _name = getText(configFile >> "CfgVehicles" >> _typeOf >> "displayName");
_picture = getText(configFile >> 'CfgVehicles' >> _typeOf >> 'picture'); _picture = getText(configFile >> 'CfgVehicles' >> _typeOf >> 'picture');
_weaponsCount = (_weaponsCount_raw select 1) call _gearCount; _weaponsCount = (_weaponsCount_raw select 1) call fnc_gearCount;
_magazineCount = (_magazineCount_raw select 1) call _gearCount; _magazineCount = (_magazineCount_raw select 1) call fnc_gearCount;
_backPackCount = (_backPackCount_raw select 1) call _gearCount; _backPackCount = (_backPackCount_raw select 1) call fnc_gearCount;
_formattedText = format [ _formattedText = format [
"<img image='%1' size='3' align='center'/><br />" + "<img image='%1' size='3' align='center'/><br />" +

View File

@@ -1,7 +1,7 @@
// Developed by [GZA] David for German Zombie Apocalypse Servers (https://zombieapo.eu/) // Developed by [GZA] David for German Zombie Apocalypse Servers (https://zombieapo.eu/)
// Rewritten by salival (https://github.com/oiad) // 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; disableSerialization;
@@ -25,13 +25,6 @@ if (_overLimit) exitWith {localize "STR_CL_VG_BLACKLISTED" call dayz_rollingMess
}; };
} count vg_vehicleList; } count vg_vehicleList;
_gearCount = {
private ["_counter"];
_counter = 0;
{_counter = _counter + _x;} count _this;
_counter
};
if (_isLimitArray) then { if (_isLimitArray) then {
{ {
_typeName = _x select 0; _typeName = _x select 0;
@@ -65,9 +58,9 @@ closeDialog 0;
if (!vg_storeWithGear && !_woGear) exitWith {localize "STR_CL_VG_NOSTOREWITHGEAR" call dayz_rollingMessages;}; if (!vg_storeWithGear && !_woGear) exitWith {localize "STR_CL_VG_NOSTOREWITHGEAR" call dayz_rollingMessages;};
_charID = _vehicle getVariable ["CharacterID","0"]; _charID = _vehicle getVariable ["CharacterID","0"];
_weaponsCount = ((getWeaponCargo _vehicle) select 1) call _gearCount; _weaponsCount = ((getWeaponCargo _vehicle) select 1) call fnc_gearCount;
_magazineCount = ((getMagazineCargo _vehicle) select 1) call _gearCount; _magazineCount = ((getMagazineCargo _vehicle) select 1) call fnc_gearCount;
_backPackCount = ((getBackpackCargo _vehicle) select 1) call _gearCount; _backPackCount = ((getBackpackCargo _vehicle) select 1) call fnc_gearCount;
_cargoAmount = (_weaponsCount + _magazineCount + _backPackCount); _cargoAmount = (_weaponsCount + _magazineCount + _backPackCount);
if (_charID == "-1") exitWith {localize "STR_CL_VG_STORE_MISSION" call dayz_rollingMessages;}; if (_charID == "-1") exitWith {localize "STR_CL_VG_STORE_MISSION" call dayz_rollingMessages;};

View File

@@ -10,19 +10,13 @@ _index = (_this select 0) select 1;
_localVehicle = typeName (vg_vehicleList select _index) == "OBJECT"; _localVehicle = typeName (vg_vehicleList select _index) == "OBJECT";
_DateMaintained = ""; _DateMaintained = "";
_MaintainDays = -1; _MaintainDays = -1;
_gearCount = {
private ["_counter"];
_counter = 0;
{_counter = _counter + _x;} count _this;
_counter;
};
if (_localVehicle) then { if (_localVehicle) then {
_vehicle = vg_vehicleList select _index; _vehicle = vg_vehicleList select _index;
_typeOf = typeOf _vehicle; _typeOf = typeOf _vehicle;
_weaponsCount = ((getWeaponCargo _vehicle) select 1) call _gearCount; _weaponsCount = ((getWeaponCargo _vehicle) select 1) call fnc_gearCount;
_magazineCount = ((getMagazineCargo _vehicle) select 1) call _gearCount; _magazineCount = ((getMagazineCargo _vehicle) select 1) call fnc_gearCount;
_backPackCount = ((getBackpackCargo _vehicle) select 1) call _gearCount; _backPackCount = ((getBackpackCargo _vehicle) select 1) call fnc_gearCount;
ctrlShow[2852,false]; // getVehicle ctrlShow[2852,false]; // getVehicle
ctrlShow[2850,true]; // storeVehicle ctrlShow[2850,true]; // storeVehicle
ctrlShow[2851,true]; // storeVehicleWithGear ctrlShow[2851,true]; // storeVehicleWithGear

View File

@@ -1,11 +1,4 @@
private ["_backPackCount","_backPackCount_raw","_backPackSlots","_formattedText","_gearCount","_magazineCount","_magazineCount_raw","_magazineSlots","_name","_picture","_price","_text","_typeOf","_weaponSlots","_weaponsCount","_weaponsCount_raw"]; private ["_backPackCount","_backPackCount_raw","_backPackSlots","_formattedText","_magazineCount","_magazineCount_raw","_magazineSlots","_name","_picture","_price","_text","_typeOf","_weaponSlots","_weaponsCount","_weaponsCount_raw"];
_gearCount = {
private ["_counter"];
_counter = 0;
{_counter = _counter + _x;} count _this;
_counter
};
if (vkc_action == "claim") then { if (vkc_action == "claim") then {
ctrlShow[4850,true]; ctrlShow[4850,true];
@@ -28,9 +21,9 @@ _backPackSlots = getNumber(configFile >> "CfgVehicles" >> _typeOf >> "transportm
_name = getText(configFile >> "CfgVehicles" >> _typeOf >> "displayName"); _name = getText(configFile >> "CfgVehicles" >> _typeOf >> "displayName");
_picture = getText(configFile >> 'CfgVehicles' >> _typeOf >> 'picture'); _picture = getText(configFile >> 'CfgVehicles' >> _typeOf >> 'picture');
_weaponsCount = (_weaponsCount_raw select 1) call _gearCount; _weaponsCount = (_weaponsCount_raw select 1) call fnc_gearCount;
_magazineCount = (_magazineCount_raw select 1) call _gearCount; _magazineCount = (_magazineCount_raw select 1) call fnc_gearCount;
_backPackCount = (_backPackCount_raw select 1) call _gearCount; _backPackCount = (_backPackCount_raw select 1) call fnc_gearCount;
if (!isNil "sk_dualCurrency") then {if (z_singleCurrency) then {_price = _price * 10};}; if (!isNil "sk_dualCurrency") then {if (z_singleCurrency) then {_price = _price * 10};};

View File

@@ -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 = { BankDialogUpdateAmounts = {
private ["_vehicleType","_displayName","_sizeOfMoney"]; private ["_vehicleType","_displayName","_sizeOfMoney"];
@@ -39,7 +24,7 @@ GivePlayerDialogAmounts = {
BankDialogWithdrawAmount = { BankDialogWithdrawAmount = {
private ["_amount","_bank","_wealth","_vehicleType","_displayName"]; 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]; _bank = ZSC_CurrentStorage getVariable ["cashMoney",0];
_wealth = player getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0]; _wealth = player getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0];
_vehicleType = typeOf ZSC_CurrentStorage; _vehicleType = typeOf ZSC_CurrentStorage;
@@ -75,7 +60,7 @@ BankDialogDepositAmount = {
_displayName = "Unknown"; _displayName = "Unknown";
}; };
_amount = (_this select 0) call fnc_sanitizeInput; _amount = [(_this select 0),0] call fnc_sanitizeInput;
_bank = ZSC_CurrentStorage getVariable ["cashMoney",0]; _bank = ZSC_CurrentStorage getVariable ["cashMoney",0];
_wealth = player getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0]; _wealth = player getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0];
@@ -97,7 +82,7 @@ BankDialogDepositAmount = {
GivePlayerAmount = { GivePlayerAmount = {
private ["_amount","_wealth","_twealth","_isBusy"]; 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]; _wealth = player getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0];
_twealth = ZSC_GiveMoneyTarget getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0]; _twealth = ZSC_GiveMoneyTarget getVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),0];
_isBusy = ZSC_GiveMoneyTarget getVariable ["isBusy",false]; _isBusy = ZSC_GiveMoneyTarget getVariable ["isBusy",false];
@@ -126,7 +111,7 @@ if (Z_globalBanking) then {
ATMDialogWithdrawAmount = { ATMDialogWithdrawAmount = {
private ["_amount","_bank","_wealth"]; private ["_amount","_bank","_wealth"];
_amount = (_this select 0) call fnc_sanitizeInput; _amount = [(_this select 0),0] call fnc_sanitizeInput;
_bank = player getVariable ["bankMoney",0]; _bank = player getVariable ["bankMoney",0];
_wealth = player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0]; _wealth = player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0];
@@ -142,7 +127,7 @@ if (Z_globalBanking) then {
ATMDialogDepositAmount = { ATMDialogDepositAmount = {
private ["_amount","_bank","_wealth"]; private ["_amount","_bank","_wealth"];
_amount = (_this select 0) call fnc_sanitizeInput; _amount = [(_this select 0),0] call fnc_sanitizeInput;
_bank = player getVariable ["bankMoney",0]; _bank = player getVariable ["bankMoney",0];
_wealth = player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0]; _wealth = player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0];

View File

@@ -964,6 +964,30 @@ fnc_lockCode = {
_code _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. // 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 if (toLower worldName in ["chernarus","chernarus_winter"]) then { //need to add building coordinates for other maps

View File

@@ -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; _vehicle = _this select 0;
_player = _this select 1; _player = _this select 1;
@@ -6,31 +6,9 @@ _woGear = _this select 2;
_clientID = owner _player; _clientID = owner _player;
_playerUID = if (count _this > 3) then {_this select 3} else {getPlayerUID _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; _class = typeOf _vehicle;
_displayName = (getText(configFile >> "cfgVehicles" >> _class >> "displayName")) call _fnc_sanitizeInput; _displayName = [(getText(configFile >> "cfgVehicles" >> _class >> "displayName")),1] call fnc_sanitizeInput;
_name = if (alive _player) then {(name _player) call _fnc_sanitizeInput;} else {"unknown player";}; _name = if (alive _player) then {[(name _player),1] call fnc_sanitizeInput;} else {"unknown player";};
_charID = _vehicle getVariable ["CharacterID","0"]; _charID = _vehicle getVariable ["CharacterID","0"];
_objectID = _vehicle getVariable ["ObjectID","0"]; _objectID = _vehicle getVariable ["ObjectID","0"];
@@ -71,9 +49,9 @@ if (!_woGear) then {
_weapons = getWeaponCargo _vehicle; _weapons = getWeaponCargo _vehicle;
_magazine = getMagazineCargo _vehicle; _magazine = getMagazineCargo _vehicle;
_backPack = getBackpackCargo _vehicle; _backPack = getBackpackCargo _vehicle;
_weaponsCount = (_weapons select 1) call _gearCount; _weaponsCount = (_weapons select 1) call fnc_gearCount;
_magazineCount = (_magazine select 1) call _gearCount; _magazineCount = (_magazine select 1) call fnc_gearCount;
_backPackCount = (_backPack select 1) call _gearCount; _backPackCount = (_backPack select 1) call fnc_gearCount;
_inventory = [_weapons, _magazine, _backPack]; _inventory = [_weapons, _magazine, _backPack];
_inventoryCount = [_weaponsCount, _magazineCount, _backPackCount]; _inventoryCount = [_weaponsCount, _magazineCount, _backPackCount];
}; };