Repeat

From EventScripts Community Encyclopedia


Overview

Syntax: repeat <operation>

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

Description

Similar to es_delayed but it can be paused/resumed and it repeats your command a set amount of times at a rate in which you set (Interval). If nothing is put for the number of times to execute it will continue to loop until map change

Parameters

  • operation: - To add a loopable command to memory
 repeat create <name> <"command">

To start looping a command already in memory via repeat create:

 repeat start <name> <interval-in-seconds> [times-to-repeat]

To pause an already looping command:

 repeat pause <name>

To resume a paused command:

 repeat resume <name>

To stop a looping command:

 repeat stop <name>

To delete a command-name from memory

 repeat delete <name>

To return the status of a repeat-command

 repeat status <var> <name>


Outputs:
0 = Non-existant 
1 = Exists -- Currently stopped 
2 = Exists -- Currently running 
3 = Exists -- Currently started, but is awaiting 'resume' 


Examples

 
event es_map_start
{
  repeat delete advert1
  repeat delete advert2
  repeat create advert1 "es_toptext #orange Advert1"
  repeat create advert2 "es_msg #green Advert2"
  repeat start advert1 60
  es_delayed 30 repeat start advert2 60
}

Or a roundtimer:
addons/eventscripts/roundtimer/es_roundtimer.txt

block load
{
  es_load corelib
  repeat create roundtimer "es_xdoblock roundtimer/msg"
}
 
block msg
{
  es_msg server_var(roundseconds) seconds left in the round.
  es_xmath roundseconds - 1
}
 
event round_start
{
  es_setinfo roundseconds 60
  es_math roundseconds * server_var(mp_roundtime)
  repeat start roundtimer 1
}
 
event round_end
{
  repeat stop roundtimer
}


Notes

  • All loops are haulted after map change
  • May not resume a stopped command (Can only be restarted with repeat start)


See also

blog comments powered by Disqus