Skip to content

Commit

Permalink
Added function from ZEN
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Jul 11, 2023
1 parent ab61a68 commit 0a06b6c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
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
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;
2 changes: 1 addition & 1 deletion addons/common/fnc_execNextFrame.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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
Expand Down

0 comments on commit 0a06b6c

Please sign in to comment.