diff --git a/SQF/dayz_code/actions/player_combineMags.sqf b/SQF/dayz_code/actions/player_combineMags.sqf index eabad8cb4..62accb228 100644 --- a/SQF/dayz_code/actions/player_combineMags.sqf +++ b/SQF/dayz_code/actions/player_combineMags.sqf @@ -1,84 +1,87 @@ if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; }; dayz_actionInProgress = true; -private ["_config","_create","_name","_create_magsize","_type","_magCount","_slotstart","_slotend","_dialog","_qty_total_ammo","_control","_mag","_qtynew_create_mags_full","_qtynew_create_ammo_rest","_magFull","_magFullSingular","_magAmmunition","_i"]; disableSerialization; call gear_ui_init; closeDialog 0; -_create = _this; +local _create = _this; -if (!(_create in magazines player)) exitWith {dayz_actionInProgress = false;}; +if !(_create in magazines player) exitWith {dayz_actionInProgress = false;}; -player playActionNow "PutDown"; +//player playActionNow "PutDown"; -_config = configFile >> "CfgMagazines" >> _create; -_create_magsize = getNumber(_config >> "count"); -_type = getNumber(_config >> "type"); -_name = getText(_config >> "displayName"); -_magCount = {_x == _create} count magazines player; +local _config = configFile >> "CfgMagazines" >> _create; +local _magSize = getNumber(_config >> "count"); +local _type = getNumber(_config >> "type"); +local _name = getText(_config >> "displayName"); +local _magCount = {_x == _create} count magazines player; if (_magCount == 1) exitWith { - [format[localize "str_cannotCombine", _name],1] call dayz_rollingMessages; + [format [localize "str_cannotCombine", _name], 1] call dayz_rollingMessages; dayz_actionInProgress = false; }; -//primary/secondary mags? -_slotstart = 0; -_slotend = 0; -if ((_type == 256) || {_type == 256*2}) then { - _slotstart = 109; - _slotend = 120; -}; -if (_type == 16) then { - _slotstart = 122; - _slotend = 129; +//primary/secondary mags +local _slotStart = 0; +local _slotEnd = 0; + +call { + if ((_type == 256) || {_type == 512}) exitWith { + _slotStart = 109; + _slotEnd = 120; + }; + if (_type == 16) exitWith { + _slotStart = 122; + _slotEnd = 129; + }; }; -_dialog = findDisplay 106; +local _dialog = findDisplay 106; +local _qty_total_ammo = 0; + +for "_i" from _slotStart to _slotEnd do { + local _control = _dialog displayCtrl _i; + local _mag = gearSlotData _control; -_qty_total_ammo = 0; -for "_i" from _slotstart to _slotend do { - _control = _dialog displayCtrl _i; - _mag = gearSlotData _control; if (_mag == _create) then { _qty_total_ammo = _qty_total_ammo + gearSlotAmmoCount _control; }; }; -_qtynew_create_mags_full = 0; -_qtynew_create_ammo_rest = 0; -_qtynew_create_mags_full = floor(_qty_total_ammo/_create_magsize); -_qtynew_create_ammo_rest = _qty_total_ammo - (_qtynew_create_mags_full*_create_magsize); +local _qtynew_create_mags_full = floor (_qty_total_ammo / _magSize); +local _qtynew_create_ammo_rest = _qty_total_ammo - (_qtynew_create_mags_full * _magSize); player removeMagazines _create; + for "_i" from 1 to _qtynew_create_mags_full do { player addMagazine _create; }; if (_qtynew_create_ammo_rest != 0) then { - player addMagazine [_create,_qtynew_create_ammo_rest]; + player addMagazine [_create, _qtynew_create_ammo_rest]; }; +local _magFull = localize "str_combineMagazines"; +local _magFullSingular = localize "str_combineMagazine"; +local _magAmmunition = localize "str_combineBullets"; + // Check if quiver -if(_create == "Quiver") then { - _magFull = localize "str_combineQuivers"; - _magFullSingular = localize "str_combineQuiver"; - _magAmmunition = localize "str_combineArrows"; -} else { - _magFull = localize "str_combineMagazines"; - _magFullSingular = localize "str_combineMagazine"; - _magAmmunition = localize "str_combineBullets"; +if (_create == "Quiver") then { + _magFull = localize "str_combineQuivers"; + _magFullSingular = localize "str_combineQuiver"; + _magAmmunition = localize "str_combineArrows"; }; call { - if (_qtynew_create_ammo_rest == 0) exitwith { - format[localize "str_combineDoneFull",_magCount, _name, _qtynew_create_mags_full,_magFull] call dayz_rollingMessages; - }; - if (_qtynew_create_mags_full == 0) exitwith { - [format[localize "str_combineDonePartialOne",_magCount, _name, _qtynew_create_ammo_rest,_magAmmunition],1] call dayz_rollingMessages; + if (_qtynew_create_ammo_rest == 0) exitWith { + format[localize "str_combineDoneFull", _magCount, _name, _qtynew_create_mags_full, _magFull] call dayz_rollingMessages; }; - [format[localize "str_combineDonePartial",_magCount, _name, _qtynew_create_mags_full, _qtynew_create_ammo_rest,_magAmmunition,_magFullSingular,_magFull],1] call dayz_rollingMessages; + if (_qtynew_create_mags_full == 0) exitWith { + [format[localize "str_combineDonePartialOne", _magCount, _name, _qtynew_create_ammo_rest, _magAmmunition], 1] call dayz_rollingMessages; + }; + [format[localize "str_combineDonePartial", _magCount, _name, _qtynew_create_mags_full, _qtynew_create_ammo_rest, _magAmmunition, _magFullSingular, _magFull], 1] call dayz_rollingMessages; }; +reload player; uiSleep 1; dayz_actionInProgress = false; diff --git a/SQF/dayz_code/actions/player_fillQuiver.sqf b/SQF/dayz_code/actions/player_fillQuiver.sqf index bd881735f..5b6b840f6 100644 --- a/SQF/dayz_code/actions/player_fillQuiver.sqf +++ b/SQF/dayz_code/actions/player_fillQuiver.sqf @@ -1,24 +1,48 @@ -private ["_qty_arrows","_qty_quivers","_control","_qty_quiverarrows","_qty_quiverfreeslots","_qty_arrows2add"]; - disableSerialization; call gear_ui_init; -_qty_arrows = {_x == "1Rnd_Arrow_Wood"} count magazines player; -_qty_quivers = {_x == "12Rnd_Quiver_Wood"} count magazines player; +local _quiver = "12Rnd_Quiver_Wood"; // quiver class +local _arrow = "1Rnd_Arrow_Wood"; // arrow class +local _arrows = {_x == _arrow} count magazines player; // qty of single arrows +local _control = uiNamespace getVariable 'uiControl'; // get item slot +local _qtyArrows = gearSlotAmmoCount _control; // ammo count of selected quiver +local _qtyFreeSlots = 12 - _qtyArrows; // ammo count remaining -_control = uiNamespace getVariable 'uiControl'; -_qty_quiverarrows = gearSlotAmmoCount _control; -_qty_quiverfreeslots = 12-_qty_quiverarrows; - -//if (_qty_quivers > 1) exitWith { localize "str_quiver_reachlimit" call dayz_rollingMessages;}; -if (_qty_quiverfreeslots > 0) then { - _qty_arrows2add = _qty_quiverfreeslots min _qty_arrows; - player removeMagazine "12Rnd_Quiver_Wood"; - for "_x" from 1 to _qty_arrows2add do { - player removeMagazine "1Rnd_Arrow_Wood"; +if (_qtyFreeSlots > 0) then { // quiver is not full + if (_arrows == 0) exitWith { // player has no single arrows + localize "str_quiver_notenougharrows" call dayz_rollingMessages; // You do not have enough arrows. }; - player addMagazine ["12Rnd_Quiver_Wood",_qty_quiverarrows+_qty_arrows2add]; - format[localize "str_quiver_addarrows",_qty_arrows2add] call dayz_rollingMessages; + local _qty_arrows2add = _qtyFreeSlots min _arrows; // max qty of arrows that can be added + + local _dialog = findDisplay 106; // gear panel + local _qArray = []; // quiver ammo count array + + for "_i" from 109 to 120 do { // loop through all primary magazine slots + local _control = _dialog displayCtrl _i; // get magazine slot + local _mag = gearSlotData _control; // get magazine name + + if (_mag == _quiver) then { + _qArray set [count _qArray, gearSlotAmmoCount _control]; // record ammo count of all quivers + }; + }; + { + if (_x == _qtyArrows) exitWith { + _qArray set [_forEachIndex, _qtyArrows + _qty_arrows2add]; // top up ammo count for the appropriate quiver + }; + } forEach _qArray; + + player removeMagazines _quiver; // remove all quivers + + for "_x" from 1 to _qty_arrows2add do { + player removeMagazine _arrow; // clear out single arrows + }; + { + player addMagazine [_quiver, _x]; // recreate all quivers + } forEach _qArray; + + reload player; + + format [localize "str_quiver_addarrows", _qty_arrows2add] call dayz_rollingMessages; // You have added %1 arrows to the quiver. } else { - localize "str_quiver_full" call dayz_rollingMessages; + localize "str_quiver_full" call dayz_rollingMessages; // The quiver is full. }; diff --git a/Server Files/DZE_Server_Config/BattlEye/scripts.txt b/Server Files/DZE_Server_Config/BattlEye/scripts.txt index b575751d3..c1ce67347 100644 --- a/Server Files/DZE_Server_Config/BattlEye/scripts.txt +++ b/Server Files/DZE_Server_Config/BattlEye/scripts.txt @@ -1,7 +1,7 @@ //new2 5 addAction !", \"\\z\\addons\\dayz_code\\" !=" = -1;\n};\nif (_s1 > 0) then {\ns_player_toggleSnap = player addaction [format[\"\" + \"Snap: %1\" +\"\",snapAc" !="-1;\n};\n\nif (_s1 > 0) then {\ns_player_toggleVector = player addaction [format[\"\" + localize \"STR_EPOCH_ACTIO" !"\"addAction\", " !"raddAction" !="_costs] call _fnc_actionTitle;\nSP_refuel_action = _vehicle addAction [_actionTitle,_folder + \"servicePointActions.sqf\",[\"refuel\"" 5 addBackpack !"addBackpackCargoGlobal [_x,(_objWpnQty select _counter)];\n_counter = _counter + 1;\n} count _objWpnTypes;" !"addBackpack _item;\n};\n};\nformat[localize \"str_c" !"case 3: {_holder addBackpackCargoGlobal [_item,_amount];};\n};\n\n\n" !"}) then {\n_newUnit addBackpack _newBackpackType;\n\nd" !"addBackpack _backpackType; \ndayz_myBackpack = unitBackpack player;\n\n\n\n_backpackWpnT" !"};\n} count _wpns;\n\nif (_bcpk != \"\") then {\nplayer addBackpack" !"1 == \"trade_backpacks\") then {\nDZE_myVehicle addBackpack" !"7 addBackpackCargoGlobal [_create,_qty];\n};\nif (surfaceIsWater" !"case 5: {_item addBackpackCargoGlobal [_itemOut,_countOut]}; \n};\n} else" !="m (2 + 1)];\n};\n};\n\nif (_type == 5) exitWith {\n_container addBackpackCargoGlobal [_item, 1];\n};\n};\n} count ([_group, _count] cal" !="5) exitWith {\nif (isNull unitBackpack _unit) then {\n_unit addBackpack _item;\n};\n};\n};\n} foreach ([_group, _count] call dz_fn_loo" !="al [_itemOut,_countOut]};\nif (_type == 5) exitwith {_item addBackpackCargoGlobal [_itemOut,_countOut]}; \n};\n} else {\n_item addMa" !="forEachIndex]} forEach (_backPackMag select 0);};\n\n_crate addBackpackCargoGlobal [_backPack,1];\n};\n\n_sound = _corpse getVariable" !=" addWeaponCargoGlobal [_item,_amount];};\ncase 3: {_holder addBackpackCargoGlobal [_item,_amount];};\n};" -5 addMagazine !raddMagazine !"\"addMagazine\", " !"if (isClass (configfile >> \"cfgmagazines\" >> (_item))) then {_unit addMagazine _item;};\n};\n};\n};\n};" !"_vehicle addMagazineTurret [_ammo,_turret];\nplayer removeMagazine" !"if (dayz_actionInProgress) exitWith {" !"addMagazine _x;\n};\n} foreach _items;\nformat[loc" !"addMagazine \"ItemAntibiotic\" + str(_remain" !"sumeDrop\") == 0) then\n{\nplayer addMagazine" !"ion) do {\ncase \"CfgWeapons\":\n{\nplayer addWeapon _item;\n};\ncase \"CfgMagazines\":\n{\nplayer addMagazine" !"addMagazine [\"12Rnd_Quiver_Wood\",_qty_quiv" !" >> \"containerEmpty\")" !"plant) select 1;\n{\n_item addMagazine" !"addMagazineCargoGlobal [_itemtodrop,1];\n\nformat[localize \"str_f" !"addMagazine _attachment;\n\n\n(findDisplay 10" !"addMagazine getText (configFile >> \"CfgMagazines\" >> _x >> _water" !"};\n};\n\n\nswitch _type do {\ncase 1: {_holder addMagazine" !"addMagazine _item;\n};\n};\n_idc = _idc" !"_newUnit addMagazine [_x select 0,_x select 1]" !"addMagazine _x } count MeleeMagazines;\n} e" !"_meleeNum < 1) then {\nplayer addMagazine" !"addMagazine _qtyRemaining;\n};\n};\ntrue" !"bag\";\n};\n};\n(_this select 0) addMagazine" !"addMagazine \"wholeBloodBagBNEG\";\n};\n};" !"_qty > 0) then {\n_firePlace addMagazine" !"ONEG\" }; \n};\ndayz_myBackpack addMagazine" !"addMagazine _x;\n_countmags = _countmags +1;\n};\n} count _gmag" !"E\"];\n_lootpile addMagazineCargoGlobal [\"TrapBear\", 1]" !"With\n{\nplayer addMagazine (_this select 1" !"lder addMagazineCargoGlobal [_x,(_objWpnQty select _counter)];\n_counter = _counter + 1;\n};\n} co" !"soldItem\"];\n{\n_object addMagazine" !"systemChat localize \"STR_EPOCH_TRADE_" !"if (_silver_1oz > 0) then {\nif (_silver_1oz == 1) then {\nplayer addMagazine" !="Random;\n} else {\n_item = \"ItemBloodbag\";\n};\n};\n_container addMagazineCargoGlobal [_item, 1];\n};\n\nif (_type == 2) exitWith {\n_c" !="electRandom;\n} else {\n_item = \"ItemBloodbag\";\n};\n};\n_unit addMagazine _item;\n};\n\nif (_type == 2) exitWith {\n_unit addWeapon _i" !="];\n\ncall {\nif (_humanityBody >= DZE_Hero) exitwith {_body addMagazine \"ItemDogTagHero\";};\nif (_humanityBody <= DZE_Bandit) exitw" !="_vehicle = \"WeaponHolder\" createVehicle [0,0,0];\n_vehicle addMagazineCargoGlobal [_item, 1];\n\nif (_isWater) then { \n_fixWaterSp" !"eep 3;\n_finished = true;\n};\n\nif (!_finished) then {\n_unit addMagazine _bagUsed;\n_msg = \"str_actions_medical_transfusion_interrup" !="art\") then {\n_body addWeapon _rawfoodtype;\n} else {\n_body addMagazine _rawfoodtype;\n};\n};\n\nif (_bodyType in [\"Cock\",\"Hen\"]) then" +5 addMagazine !raddMagazine !"\"addMagazine\", " !"if (isClass (configfile >> \"cfgmagazines\" >> (_item))) then {_unit addMagazine _item;};\n};\n};\n};\n};" !"_vehicle addMagazineTurret [_ammo,_turret];\nplayer removeMagazine" !"if (dayz_actionInProgress) exitWith {" !"addMagazine _x;\n};\n} foreach _items;\nformat[loc" !"addMagazine \"ItemAntibiotic\" + str(_remain" !"sumeDrop\") == 0) then\n{\nplayer addMagazine" !"ion) do {\ncase \"CfgWeapons\":\n{\nplayer addWeapon _item;\n};\ncase \"CfgMagazines\":\n{\nplayer addMagazine" !" >> \"containerEmpty\")" !"plant) select 1;\n{\n_item addMagazine" !"addMagazineCargoGlobal [_itemtodrop,1];\n\nformat[localize \"str_f" !"addMagazine _attachment;\n\n\n(findDisplay 10" !"addMagazine getText (configFile >> \"CfgMagazines\" >> _x >> _water" !"};\n};\n\n\nswitch _type do {\ncase 1: {_holder addMagazine" !"addMagazine _item;\n};\n};\n_idc = _idc" !"_newUnit addMagazine [_x select 0,_x select 1]" !"addMagazine _x } count MeleeMagazines;\n} e" !"_meleeNum < 1) then {\nplayer addMagazine" !"addMagazine _qtyRemaining;\n};\n};\ntrue" !"bag\";\n};\n};\n(_this select 0) addMagazine" !"addMagazine \"wholeBloodBagBNEG\";\n};\n};" !"_qty > 0) then {\n_firePlace addMagazine" !"ONEG\" }; \n};\ndayz_myBackpack addMagazine" !"addMagazine _x;\n_countmags = _countmags +1;\n};\n} count _gmag" !"E\"];\n_lootpile addMagazineCargoGlobal [\"TrapBear\", 1]" !"With\n{\nplayer addMagazine (_this select 1" !"lder addMagazineCargoGlobal [_x,(_objWpnQty select _counter)];\n_counter = _counter + 1;\n};\n} co" !"soldItem\"];\n{\n_object addMagazine" !"systemChat localize \"STR_EPOCH_TRADE_" !"if (_silver_1oz > 0) then {\nif (_silver_1oz == 1) then {\nplayer addMagazine" !="Random;\n} else {\n_item = \"ItemBloodbag\";\n};\n};\n_container addMagazineCargoGlobal [_item, 1];\n};\n\nif (_type == 2) exitWith {\n_c" !="electRandom;\n} else {\n_item = \"ItemBloodbag\";\n};\n};\n_unit addMagazine _item;\n};\n\nif (_type == 2) exitWith {\n_unit addWeapon _i" !="];\n\ncall {\nif (_humanityBody >= DZE_Hero) exitwith {_body addMagazine \"ItemDogTagHero\";};\nif (_humanityBody <= DZE_Bandit) exitw" !="_vehicle = \"WeaponHolder\" createVehicle [0,0,0];\n_vehicle addMagazineCargoGlobal [_item, 1];\n\nif (_isWater) then { \n_fixWaterSp" !"eep 3;\n_finished = true;\n};\n\nif (!_finished) then {\n_unit addMagazine _bagUsed;\n_msg = \"str_actions_medical_transfusion_interrup" !="art\") then {\n_body addWeapon _rawfoodtype;\n} else {\n_body addMagazine _rawfoodtype;\n};\n};\n\nif (_bodyType in [\"Cock\",\"Hen\"]) then" !="2add do {\nplayer removeMagazine _arrow; \n};\n{\nplayer addMagazine [_quiver, _x]; \n} forEach _qArray;\n\nreload player;\n\nfo" 5 addWeapon !raddWeapon !"\"addWeapon\", " !"if (isClass (configfile >> \"cfgweapons\" >> (_item))) then {_unit addWeapon _item;}\nelse" !",0]] call dayz_NutritionSystem;\n" !"Remove) == 1}) then {\nplayer addWeapon _create;" !"Display 0;\n\n\nif (_weaponInUse) then\n{\n_muz" !"failChance) then {\nswitch (_selection) do {\ncase \"CfgWeapons\":\n{\nplayer addWeapon" !"addWeapon _fixedItem;\nformat[localize \"str_f" !"_wepcounts = (getWeaponCargo _plant) select 1;\n{\n_item addWeapon" !"addWeapon _repair;\n} else {\n\n[_repair" !"player addWeapon dayz_onBack] select 0;\n};\n\n" !"player addWeapon _addWeapon;\n\nif (vehicle player != player) then {\n_display = find" !"};\n};\n\n\nswitch _type do {\ncase 1: {_holder addMagazineCargoGlobal [_item,_amount];};\ncase 2: {_holder addWeapon" !"l fn_chance) then {\nplayer removeWeapon _x;\nplayer addWeapon _rem" !"else {\n_body addWeapon dayz_onBack;\n};\n};\n\n\n_infect" !"\" >> _x)) then {\nplayer addWeapon _x;\n};\n} count _wpns;\n};" !"lder addWeaponCargoGlobal [_x,(_objWpnQty select _counter)];\n_counter = _counter + 1;\n} co" !"WpnQtys = [];\nif (count _backpackWpn > 0) then {\n_backpackWpnTypes = _backpackWpn sel" !"addWeapon (\"Item\"+str(_remain)+\"Matchbox" !"{\nswitch (_x select 0) do\n{\ncase 2:\n{\n(_this select 0) addWeapon" !"addWeaponCargoGlobal [_bcpkWpn, 1];\n};\n};\n};\n};" !"s;\n};\n\n\nplayer addWeapon \"Loot" !"With\n{\nplayer addWeapon (_this select 1" !"\") then {\n_newUnit addWeapon _secweapon;\n};\n\n" !"soldItem\"];\n{\n_object addWeapon" !"then {\nsystemChat format[localize \"STR_EPOCH_" !"DuplicateTool;\n} else {\nplayer addWeapon" !="al [_item, 1];\n};\n\nif (_type == 2) exitWith {\n_container addWeaponCargoGlobal [_item, 1];\n\n_magazines = getArray (configFile >" !=" addMagazine _item;\n};\n\nif (_type == 2) exitWith {\n_unit addWeapon _item;\n};\n\nif (_type == 5) exitWith {\nif (isNull unitBackp" !="ile >> \"CfgWeapons\" >> _x >> \"type\") == 256) then {\nplayer addWeapon _x;\n} else {\n_x call player_addDuplicateTool;\n};\n};\n} count" !="\n_vehicle = \"WeaponHolder\" createVehicle [0,0,0];\n_vehicle addWeaponCargoGlobal [_item, 1];\n\nif (_isWater) then { \n_fixWaterSpa" !="do {_vehicle addMagazineTurret [_ammo,_turret];};\n_vehicle addWeaponTurret [\"CMFlareLauncher\",_turret];\n} else {\n{_vehicle remov" !="ect 2];\n_cross setVariable [\"bury\",true,true];\n};\n\n{_crate addWeaponCargoGlobal [_x,1]} forEach weapons _corpse;\n{_crate addMaga" !="y do {\nif (_rawfoodtype == \"ItemMutantHeart\") then {\n_body addWeapon _rawfoodtype;\n} else {\n_body addMagazine _rawfoodtype;\n};\n}" !="eaponqty = (_newarray select 1) select _i;\ndayz_myBackpack addWeaponCargoGlobal [_weapon,_weaponqty];\n};\n};\n};\n} else {\nsystemCh" !="CK\",_keyName] call dayz_rollingMessages;};\n} else {\nplayer addWeapon _keyID;\nformat[localize \"STR_CL_VG_ADDED_INVENTORY\",_keyNam" 5 allDead !"} count allDead;\n\n\nif (dayz_oldBodyCount > _bodyCount) then {" 5 allGroups !"publicVariableServer \"PVDZ_Server_UpdateGroup\";\n};\n} count allGroups;"