Es format

From EventScripts Community Encyclopedia


Overview

Syntax: es_format <variable> <format-string> [token1] [token2] [token3] [...] [token9]

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_xformat

Description

Formats a string according to the format-string and stores it into the variable command.

Parameters

  • variable - Variable to store the string into.
  • format-string - String that you would like to place the parameters into. Will place tokenX in format-string in place of %X.
  • tokenX - Tokens that will be placed in the string. Can have any number of tokens from 0 to 9.


Examples

es_xsetinfo myvar 0
es_xsetinfo param1 "is"
es_xsetinfo param2 "string"
es_xsetinfo param3 "results from placing"
es_xsetinfo param4 "the format-string."
es_format myvar "This %1 the %2 that %3 the tokens into %4" server_var(param1) server_var(param2) server_var(param3) server_var(param4)
es_msg server_var(myvar)
 
//will display: This is the string that results from placing the tokens into the format-string. 


Notes

  • Most quotation marks (") will be consumed by the game and won't be displayed.
  • The maximum number of tokens supported are nine.
  • Useful to bring 2 vars together:
es_xsetinfo var1 "ro"
es_xsetinfo var2 "fl"
es_xsetinfo format 0
es_format format "%1%2" server_var(var1) server_var(var2)
es_msg server_var(format)
 
// Will display: rofl 
  • Useful to add words to a string:
es_xsetinfo string "hello"
es_xsetinfo word1 "world"
es_format string "%1 %2" server_var(string) server_var(word1)
es_msg server_var(string)
 
// Will display: "Hello World" 


See also

blog comments powered by Disqus