BIS fnc countdown: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<code>([^<]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^<]*) *<\/code>" to "<code>$1$2$3</code>")
m (Some wiki formatting)
 
(6 intermediate revisions by the same user not shown)
Line 6: Line 6:
|gr1= Missions
|gr1= Missions


|descr= Triggers a countdown. {{Feature|Informative|The '''initial''' countdown can be accessed via [[missionNamespace]] variable '''BIS_fnc_countdown_time'''.<br>
|descr= Triggers a countdown.
The initial value is either ''[[serverTime]] (if set globally) or [[time]] (if set locally) + timeInSeconds''. To return the left-over time see {{HashLink|#Example 4}}.}}
{{Feature|informative|
The '''initial''' countdown can be accessed ''via'' [[missionNamespace]]'s variable '''BIS_fnc_countdown_time'''.<br>
The initial value is either <sqf inline>serverTime + timeInSeconds</sqf> (if set globally) or <sqf inline>time + timeInSeconds</sqf> (if set locally).
To return the left-over time see {{Link|#Example 4}}.
}}


|s1= [timeInSeconds, global] call [[BIS_fnc_countdown]]
|s1= [timeInSeconds, global] call [[BIS_fnc_countdown]]
Line 21: Line 25:
|p2= global - [[Boolean]]: True to set it globally (Optional) Default: [[true]]
|p2= global - [[Boolean]]: True to set it globally (Optional) Default: [[true]]


|r1=<nowiki/>
|r1= <nowiki/>
* [[Number]]:
* [[Number]]:
** If set locally: [[time]] + timeInSeconds (see {{HashLink|#Example 1}})
** If set locally: [[time]] + timeInSeconds (see {{Link|#Example 1}})
** If set globally [[serverTime]] + timeInSeconds (see {{HashLink|#Example 2}})
** If set globally [[serverTime]] + timeInSeconds (see {{Link|#Example 2}})
** Returns -1 if countdown is set to [[nil]] (see {{HashLink|#Example 3}})
** Returns -1 if countdown is set to [[nil]] (see {{Link|#Example 3}})
** Return left-over time (see {{HashLink|#Example 4}})
** Return left-over time (see {{Link|#Example 4}})
* [[Boolean]]: returns [[true]] when countdown is > 0 else [[false]] (see {{HashLink|#Example 5}})
* [[Boolean]]: returns [[true]] when countdown is > 0 else [[false]] (see {{Link|#Example 5}})


|x1= <code>private _initialCountdown = [50,false] [[call]] [[BIS_fnc_countdown]]; {{cc|sets countdown to 50 seconds where function is executed}}</code>
|x1= <sqf>private _initialCountdown = [50,false] call BIS_fnc_countdown; // sets countdown to 50 seconds where function is executed</sqf>


|x2= <sqf>private _initialCountdown = [50] call BIS_fnc_countdown; // sets countdown to 50 seconds globally</sqf>
|x2= <sqf>private _initialCountdown = [50] call BIS_fnc_countdown; // sets countdown to 50 seconds globally</sqf>


|x3= <code>[-1] call BIS_fnc_countdown; {{cc|sets ''BIS_fnc_countdown_time'' to [[nil]]}}</code>
|x3= <sqf>[-1] call BIS_fnc_countdown; // sets BIS_fnc_countdown_time to nil</sqf>


|x4= <sqf>private _timeLeft = [0] call BIS_fnc_countdown; // returns the left over-time</sqf>
|x4= <sqf>private _timeLeft = [0] call BIS_fnc_countdown; // returns the left over-time</sqf>


|x5= <code>[[private]] _isTimeLeft = <noWiki>[</noWiki>[[true]]] [[call]] [[BIS_fnc_countdown]]; {{cc|returns [[true]] if countdown is greater 0}}</code>
|x5= <sqf>private _isTimeLeft = [true] call BIS_fnc_countdown; // returns true if countdown is greater than 0</sqf>


|seealso= [[BIS_fnc_VRTimer]]
|seealso= [[BIS_fnc_VRTimer]]
}}
}}

Latest revision as of 21:54, 28 January 2023

Hover & click on the images for description

Description

Description:
Triggers a countdown.
The initial countdown can be accessed via missionNamespace's variable BIS_fnc_countdown_time.

The initial value is either serverTime + timeInSeconds (if set globally) or time + timeInSeconds (if set locally).

To return the left-over time see Example 4.
Execution:
call
Groups:
Missions

Syntax

Syntax:
[timeInSeconds, global] call BIS_fnc_countdown
Parameters:
timeInSeconds - can be:
  • Number:
    • Any number to set the length of the countdown in seconds
    • -1 to set the countdown to nil
    • 0 to return the left-over time
  • Boolean:
    • true to find out if countdown is active and if there is left-over time
global - Boolean: True to set it globally (Optional) Default: true
Return Value:

Examples

Example 1:
private _initialCountdown = [50,false] call BIS_fnc_countdown; // sets countdown to 50 seconds where function is executed
Example 2:
private _initialCountdown = [50] call BIS_fnc_countdown; // sets countdown to 50 seconds globally
Example 3:
[-1] call BIS_fnc_countdown; // sets BIS_fnc_countdown_time to nil
Example 4:
private _timeLeft = [0] call BIS_fnc_countdown; // returns the left over-time
Example 5:
private _isTimeLeft = [true] call BIS_fnc_countdown; // returns true if countdown is greater than 0

Additional Information

See also:
BIS_fnc_VRTimer

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note