Skip to content

Commit

Permalink
FIX: Very Minor Bug (#369)
Browse files Browse the repository at this point in the history
* FIX: Very Minor Bug

If the player/unit was nil then then the function would be aborted and it wouldn't re-enable the give item button. Instead it would re-enable the give money button.

Also: Consistency...

* Cleanup
  • Loading branch information
DuckyDoesCode authored and Jason2605 committed Oct 6, 2017
1 parent f44a576 commit e3e6241
Showing 1 changed file with 44 additions and 27 deletions.
71 changes: 44 additions & 27 deletions Altis_Life.Altis/core/pmenu/fn_giveItem.sqf
@@ -1,4 +1,5 @@
#include "..\..\script_macros.hpp"

/*
File: fn_giveItem.sqf
Author: Bryan "Tonic" Boardwine
Expand All @@ -8,30 +9,46 @@
removes the item & amount of it from the players virtual
inventory.
*/
private ["_unit","_val"];
_val = ctrlText 2010;
ctrlShow[2002,false];
if ((lbCurSel 2023) isEqualTo -1) exitWith {hint localize "STR_NOTF_noOneSelected";
ctrlShow[2002,true];};
_unit = lbData [2023,lbCurSel 2023];
_unit = call compile format ["%1",_unit];

if ((lbCurSel 2005) isEqualTo -1) exitWith {hint localize "STR_NOTF_didNotSelectItemToGive";ctrlShow[2002,true];};

_item = lbData [2005,(lbCurSel 2005)];
if (isNil "_unit") exitWith {ctrlShow[2002,true];};
if (_unit == player) exitWith {ctrlShow[2002,true];};
if (isNull _unit) exitWith {ctrlShow[2002,true];};

//A series of checks *ugh*
if (!([_val] call TON_fnc_isnumber)) exitWith {hint localize "STR_NOTF_notNumberFormat";ctrlShow[2002,true];};
if (parseNumber(_val) <= 0) exitWith {hint localize "STR_NOTF_enterAmountGive";ctrlShow[2002,true];};
if (isNil "_unit") exitWith {ctrlShow[2001,true]; hint localize "STR_NOTF_notWithinRange";};
if (!([false,_item,(parseNumber _val)] call life_fnc_handleInv)) exitWith {hint localize "STR_NOTF_couldNotGive";ctrlShow[2002,true];};

[_unit,_val,_item,player] remoteExecCall ["life_fnc_receiveItem",_unit];
_type = M_CONFIG(getText,"VirtualItems",_item,"displayName");
hint format [localize "STR_NOTF_youGaveItem",_unit getVariable ["realname",name _unit],_val,(localize _type)];
[] call life_fnc_p_updateMenu;

ctrlShow[2002,true];

ctrlShow [2002,false];

call {
private _value = ctrlText 2010;

if ((lbCurSel 2023) isEqualTo -1) exitWith {
hint localize "STR_NOTF_noOneSelected";
};

if ((lbCurSel 2005) isEqualTo -1) exitWith {
hint localize "STR_NOTF_didNotSelectItemToGive";
};


private _unit = lbData [2023, lbCurSel 2023];
_unit = call compile format ["%1",_unit];

if (isNil "_unit") exitWith {
hint localize "STR_NOTF_notWithinRange";
};
if (isNull _unit || {_unit isEqualTo player}) exitWith {};

private _item = lbData [2005, lbCurSel 2005];

if !([_value] call TON_fnc_isnumber) exitWith {
hint localize "STR_NOTF_notNumberFormat";
};
if (parseNumber _value <= 0) exitWith {
hint localize "STR_NOTF_enterAmountGive";
};
if !([false,_item, parseNumber _value] call life_fnc_handleInv) exitWith {
hint localize "STR_NOTF_couldNotGive";
};

[_unit, _value, _item, player] remoteExecCall ["life_fnc_receiveItem", _unit];
private _type = M_CONFIG(getText,"VirtualItems",_item,"displayName");
hint format [localize "STR_NOTF_youGaveItem", _unit getVariable ["realname", name _unit], _value, localize _type];

[] call life_fnc_p_updateMenu;
};

ctrlShow[2002,true];

0 comments on commit e3e6241

Please sign in to comment.