Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

Count the number of structures of a given type...

 

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
var numStructs = countStruct(structureID[, player]);

Parameters

ParameterTypeMandatoryNotesGame Version
structureIDString(tick)The ID of the structure type to count.3.1.0
player

Number

Constant

(error)

Which player(s) should the structures be counted for?

You can specify a specific player ID, or one of the following constants:

Child pages (Children Display)
alltrue
depthall
pagePlayer Scope
excerpttrue

Default: me

3.1.0

Return value

ValueTypeNotesWarzone Version
<number>NumberThe number of structures of the specified type for the specified player(s).3.1.0
<error>ErrorAn error occurred, most likely you used an unsupported structureID or the specified player does not exist.3.1.0

Notes

Does not count off-world structures (use enumStructOffWorld() to list those).

Example

 

 

Div
classbox suggest

This function is significantly faster than using enumStruct() and inspecting the .length property of the returned array, because countStruct() is referencing an existing value within the game engine and just returning that value.

Div
classbox
Availability
Status
colourGreen
title
Stable
3.1.0+

Requires:

  • Warzone 3.1.0 and above
Div
classbox
Contents

Jump to:

Table of Contents
maxLevel5

Div
classbox

See also

Related articles: