Average

From EventScripts Community Encyclopedia

Overview

Syntax: average <variable> [type] <num1 num2 numN>

Note: Command parameters are described inside the < and > characters. Optional parameters are contained within [ and ] characters.

Variation of this command that doesn't expand variables: average

Description

Averages a given set of numbers and can round the results.

Parameters

  • variable - This is the return variable for the average result.
  • type - This is optional and controls rounding.
    • round - Traditional if remainder is greaterthan or equalto .5 the number is rounded up.
    • ceiling - Number is always rounded up to the nearest whole number.
    • floor - Number is always rounded down to the nearest whole number.


Examples

es_xsetinfo myvar 0
 
//Round a set of numbers 3, 3, 6, and 3 and store it to myvar
average myvar 3 3 6 3  // myvar = 3.75
 
// This stores the rounded average to myvar.
average myvar round 3 3 6 3  // myvar = 4
 
// This stores the average rounded up to myvar.
average myvar ceiling 3 3 6 3  // myvar = 4
 
// This stores the average rounded down to myvar.
average myvar floor 3 3 6 3  // myvar = 3 


Notes

  • This command does not expand variables!


See also

blog comments powered by Disqus