From 06ed1fc10c206178b97a31d0184cdd3af96ac797 Mon Sep 17 00:00:00 2001 From: Zac Surplice Date: Tue, 24 Sep 2013 21:40:28 +1000 Subject: [PATCH] No gear menu near locked vehicles --- SQF/dayz_code/Configs/rscTitles.hpp | 2 ++ SQF/dayz_code/actions/player_harvestPlant.sqf | 26 ++++++++++++------- SQF/dayz_code/compile/fn_gearMenuChecks.sqf | 7 +++++ SQF/dayz_code/init/compiles.sqf | 1 + 4 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 SQF/dayz_code/compile/fn_gearMenuChecks.sqf diff --git a/SQF/dayz_code/Configs/rscTitles.hpp b/SQF/dayz_code/Configs/rscTitles.hpp index 8c309bd22..8678a3568 100644 --- a/SQF/dayz_code/Configs/rscTitles.hpp +++ b/SQF/dayz_code/Configs/rscTitles.hpp @@ -875,7 +875,9 @@ class RscDisplayGear { idd = 106; enableDisplay = 1; + onLoad = "_this call fn_gearMenuChecks;[] spawn object_monitorGear; {player removeMagazines _x} forEach MeleeMagazines; call gear_ui_init; if (isNil('IGUI_GEAR_activeFilter')) then { IGUI_GEAR_activeFilter = 0;}; private ['_dummy']; _dummy = [_this,'initDialog'] call compile preprocessFile '\ca\ui\scripts\handleGear.sqf'; _dummy = [_this,'onLoad'] execVM '\ca\ui\scripts\handleGear.sqf'; _dummy;"; onUnload = "call player_gearSync; call dayz_forceSave;"; + class controls { class CA_Filter_Icon: RscPicture diff --git a/SQF/dayz_code/actions/player_harvestPlant.sqf b/SQF/dayz_code/actions/player_harvestPlant.sqf index 7a5a468ea..d76884252 100644 --- a/SQF/dayz_code/actions/player_harvestPlant.sqf +++ b/SQF/dayz_code/actions/player_harvestPlant.sqf @@ -93,18 +93,26 @@ if (count(_findNearestTree) >= 1) then { if (_proceed) then { + _invResult = false; + _i = 0; for "_x" from 1 to _countOut do { - player addMagazine _itemOut; + _invResult = [player,_itemOut] call BIS_fnc_invAdd; + if(_invResult) then { + _i = _i + 1; + }; }; - - // chop down tree - if("" == typeOf _tree) then { - _tree setDamage 1; + + if(_i != 0) then { + // chop down tree + if("" == typeOf _tree) then { + _tree setDamage 1; + }; + //diag_log format["DEBUG TREE DAMAGE: %1", _tree]; + + cutText [format["\n\n%1 of %2 has been successfully added to your inventory.", _i,_itemOut], "PLAIN DOWN"]; + } else { + cutText [format["\n\n%1 of %2 could not be added to your inventory. (not enough room?)", _i,_itemOut], "PLAIN DOWN"]; }; - //diag_log format["DEBUG TREE DAMAGE: %1", _tree]; - - cutText [format["\n\n%1 of %2 has been successfully added to your inventory.", _countOut,_itemOut], "PLAIN DOWN"]; - } else { r_interrupt = false; if (vehicle player == player) then { diff --git a/SQF/dayz_code/compile/fn_gearMenuChecks.sqf b/SQF/dayz_code/compile/fn_gearMenuChecks.sqf new file mode 100644 index 000000000..3841d180c --- /dev/null +++ b/SQF/dayz_code/compile/fn_gearMenuChecks.sqf @@ -0,0 +1,7 @@ +disableSerialization; +_display = (_this select 0); +_close = {locked _x} count (nearestObjects [player, ["AllVehicle"], 10]) > 0; + +if(_close) then { + _display closeDisplay 1; +}; \ No newline at end of file diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index 3df4adff9..809fc1bd6 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -56,6 +56,7 @@ if (!isDedicated) then { player_alertZombies = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_alertZombies.sqf"; player_fireMonitor = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\fire_monitor.sqf"; player_friendliesCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_friendliesCheck.sqf"; + fn_gearMenuChecks = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_gearMenuChecks.sqf"; //Objects object_roadFlare = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_roadFlare.sqf";