Es exists

From EventScripts Community Encyclopedia


Overview

Syntax: es_exists <variable> <type> [keygroup] [key] <name>

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_xexists

Description

Checks for the existence of item specified by type and stores the result in variable. 0 means it does not exist and 1 means it does exists.

Parameters

  • variable - variable in which the result is stored.
  • type - type of item to be checked.
    • keygroup
    • key
    • variable
    • command
    • userid (added in EventScripts v1.2)
    • script (added in EventScripts v1.3)
    • block (added in EventScripts v1.3)
    • saycommand (added in EventScripts v1.5)
    • clientcommand (added in EventScripts v1.5)
    • keyvalue (added in EventScripts v1.5)
    • map (added in EventScripts v1.5)
  • keygroup - keygroup name to use for key, or keyvalue check only. Otherwise do not use this parameter.
  • key - key name to use for keyvalue check only. Otherwise do not use this parameter
  • name - name or id of item to be checked.


Examples

es_xset somevar 0
es_xset myvar 0
es_xexists myvar variable somevar //results 1 for true.
if (server_var(myvar) == 1) do
{
  // do some code if results are true.
}
es_xelse do
{
  // do some code if results are false.
}

For use with key exists:

es_xset key_exist 0
es_exists key_exist key Sounds event_var(userid) // checks if a key named with their userid exists
if (server_var(key_exist) = 0) do
{
//do code if key doesn't exist i.e. create the key
}
else do
{
//do code if key exists.
}

For use with userids:

es_xset userid_exists 0
es_xexists userid_exists userid 34
if (server_var(userid_exists) == 1) then kickid 34

For use with maps:

es_xset map_exists 0
es_xexists map_exists map cs_italy
if (server_var(map_exists) == 1) then changelevel cs_italy


Notes

  • You should always use es_set before es_exists because the variable is not always set to the correct value.
  • Es_exists script looks up if a script is loaded by ES.


See also


blog comments powered by Disqus