Es foreachkey

From EventScripts Community Encyclopedia


Overview

Syntax: es_foreachkey <variablename> in <keygroupname> "<commandstring>"

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: es_xforeachkey

Description

Loops through a keygroup's keys and executes a command of your choosing. A variable is set to the name of the key before the command is run inside the loop.


Parameters

  • variablename - the name of the variable to create and set to the key's name before each commandstring fires.
  • keygroupname - the name of the keygroup in which to loop through the keys
  • "commandstring" This is the command-string you wish to execute for every key within the specified keygroup


Examples

// this will create a keygroup of all players
es_createplayerlist examplegroup
// This will loop through all of the players and output their userid:
es_foreachkey example_player in examplegroup "es_msg Found playerid server_var(example_player) !"


Notes

  • Loops are rarely good for performance-- it's recommended that you only loop through long keygroups during non-time-critical events (e.g. es_map_start, round_end, etc).


See also

blog comments powered by Disqus