This wiki was in read-only mode for many years, but can now be edited again. A lot of information will need to be updated.

Bz getCountdownRemaining: Difference between revisions

From BZFlagWiki
Jump to navigation Jump to search
Allejo (talk | contribs)
m Allejo moved page Bz getCountdownProgress to Bz getCountdownRemaining: Renamed function
Allejo (talk | contribs)
Update return type and function name
 
Line 1: Line 1:
{{apicall
{{apicall
| name          = bz_getCountdownProgress
| name          = bz_getCountdownRemaining
| returns      = The amount of time remaining in a match in seconds, or <code>-1</code> if a match is not currently in progress.
| returns      = The amount of time remaining in a match in seconds, or <code>-1</code> if a match is not currently in progress.
| returntype    = int
| returntype    = float
| description  = Retrieves the time remaining in a running countdown.
| description  = Retrieves the time remaining in a running countdown.
}}
}}
Line 12: Line 12:
  if (bz_isCountDownActive()) {
  if (bz_isCountDownActive()) {
  bz_sendTextMessagef(BZ_SERVER, player,
  bz_sendTextMessagef(BZ_SERVER, player,
  "Welcome! The current match will finish in %d seconds!", bz_getCountdownProgress());
  "Welcome! The current match will finish in %.0f seconds!", bz_getCountdownRemaining());
  } else {
  } else {
  bz_sendTextMessage(BZ_SERVER, player,
  bz_sendTextMessage(BZ_SERVER, player,

Latest revision as of 21:10, 25 September 2015

float bz_getCountdownRemaining ()


Retrieves the time remaining in a running countdown.

Returns:
The amount of time remaining in a match in seconds, or -1 if a match is not currently in progress.


Example

Display the remaining time to a user upon joining.

case bz_ePlayerJoinEvent: {
	int player = (bz_PlayerJoinPartEventData_V1*)eventData)->playerID;
	if (bz_isCountDownActive()) {
	 	bz_sendTextMessagef(BZ_SERVER, player,
	 		"Welcome! The current match will finish in %.0f seconds!", bz_getCountdownRemaining());
	} else {
	 	bz_sendTextMessage(BZ_SERVER, player,
	 		"Welcome! No match is currently running.");
	}
}break;