Attach-use waitAndExecute

This commit is contained in:
PabstMirror 2015-01-24 13:14:01 -06:00
parent 1c074e8096
commit 69893a7e99
3 changed files with 7 additions and 23 deletions

View File

@ -4,5 +4,4 @@ PREP(attach);
PREP(canAttach);
PREP(canDetach);
PREP(detach);
PREP(detachDelayFix);
PREP(openAttachUI);

View File

@ -12,7 +12,7 @@ Return Value:
none
*/
private ["_unit", "_itemName", "_count", "_attachedItem"];
private ["_unit", "_itemName", "_count", "_attachedItem", "_fnc_detachDelay"];
_unit = _this select 0;
_itemName = _unit getVariable [QGVAR(ItemName), ""];
@ -33,7 +33,12 @@ if (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "
detach _attachedItem;
_attachedItem setPos [getPos _unit select 0, getPos _unit select 1, ((getPos _unit select 2) - 1000)];
// Delete attached item after 0.5 seconds
[FUNC(detachFix), 0.5, [_attachedItem, (time + 0.5)]] call CBA_fnc_addPerFrameHandler;
systemChat "wait";
_fnc_detachDelay = {
systemChat "deleting";
deleteVehicle (_this select 0);
};
[_fnc_detachDelay, [_attachedItem], 0.5, 0] call EFUNC(common,waitAndExecute);
} else {
// Delete attached item
deleteVehicle _attachedItem;

View File

@ -1,20 +0,0 @@
/*
Author: Pabst Mirror
Description:
Waits then deletes the object. Fixes IR_Grenade's effect not disapearing.
Parameters:
0: ARRAY - [OBJECT - item, NUMBER - time to wait until]
1: NUMBER - CBA's PerFrameHandler ID
*/
_attachedItem = (_this select 0) select 0;
_waitUntilTime = (_this select 0) select 1;
if (time < _waitUntilTime) exitWith {};
deleteVehicle _attachedItem;
//Remove the frame handler
[(_this select 1)] call cba_fnc_removePerFrameHandler;