Skip to content

Commit

Permalink
Common - Added CBA_fnc_execAfterNFrames from ZEN (#1584)
Browse files Browse the repository at this point in the history
* Added n frame delay

* Revert "Added n frame delay"

This reverts commit 50df691.

* Added function from ZEN

* Update addons/common/fnc_execAfterNFrames.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Update fnc_execNextFrame.sqf

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
  • Loading branch information
johnb432 and PabstMirror committed Jul 13, 2023
1 parent c472830 commit 263286f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions addons/common/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class CfgFunctions {
PATHTO_FNC(directCall);
PATHTO_FNC(objectRandom);
PATHTO_FNC(execNextFrame);
PATHTO_FNC(execAfterNFrames);
PATHTO_FNC(waitAndExecute);
PATHTO_FNC(waitUntilAndExecute);
PATHTO_FNC(compileFinal);
Expand Down
35 changes: 35 additions & 0 deletions addons/common/fnc_execAfterNFrames.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_fnc_execAfterNFrames
Description:
Executes the given code after the specified number of frames.
Parameters:
_function - The function to run. <CODE>
_args - Parameters passed to the function executing. This will be the same array every execution. (optional, default: []) <ANY>
_frames - The amount of frames the execution of the function should be delayed by. (optional, default: 0) <NUMBER>
Returns:
Nothing Useful
Examples:
(begin example)
[{hint "Done!"}, [], 5] call cba_fnc_execAfterNFrames;
(end)
Author:
mharis001, donated from ZEN
---------------------------------------------------------------------------- */

if (canSuspend) exitWith {
[CBA_fnc_execAfterNFrames, _this] call CBA_fnc_directCall;
};

params [["_function", {}, [{}]], ["_args", []], ["_frames", 0, [0]]];

if (_frames > 0) exitWith {
[CBA_fnc_execAfterNFrames, [_function, _args, _frames - 1]] call CBA_fnc_execNextFrame;
};

_args call _function;
4 changes: 2 additions & 2 deletions addons/common/fnc_execNextFrame.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Description:
Parameters:
_function - The function to run. <CODE>
_args - Parameters passed to the function executing. This will be the same array every execution. [optional] <ANY>
_args - Parameters passed to the function executing. This will be the same array every execution. (optional, default: []) <ANY>
Returns:
Nothing
Nothing Useful
Examples:
(begin example)
Expand Down

0 comments on commit 263286f

Please sign in to comment.