Ifx

From EventScripts Community Encyclopedia


Overview

Syntax: ifx <command>(<variable or mathparse>) do

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

Description

Will execute the do { } block depending on the <command>.

Parameters

  • command - Must be:
    • parse - Does not expand server_var/event_var variables. Runs the provided text through the es_mathparse engine and executes the following block only if the result of the math is non-zero (i.e. true). parse can only use numerical values, it cannot compare strings!
    • true - Does not expand server_var/event_var variables. If the value inside the variable is non-zero, the block following will execute. If the value is 0 or an empty string, the block will not execute.
    • false - Does not expand server_var/event_var variables. If the value inside the variable is non-zero, the block following will not execute. If the value is 0 or an empty string, the block will execute.


Examples

True/False:

event player_hurt
{
	es_set attacker_userid event_var(attacker)
	ifx true(attacker_userid) do
	{
		//Do the block if the userid is not 0 = Not hurt by world
	}
	else do
	{
		//Else do
	}
}
ifx true(eventscripts_currentmap) do
{
	// good method to get if a game is running
}

mathparse:

es_set x "12"
es_set y "15"
 
ifx parse("x < y") do
{
	// this is faster than the "if" command
}
es_set x 5
 
ifx parse("x == 5") do
{
	// this is faster than the "if" command
}

Using ifx with 'and' and 'or' statements:

es_xset a 1
es_xrand b 3 4
es_xset c 0
ifx parse("b == 3") do
{
        es_xset c 1
}
ifx parse("a < 2 and b > 3 or c != 0") do 
{ 
        es_msg Look it works!
}

Will send the message to all players 'Look it works'


Notes

  • Ifx true/false does not support values in the brackets!
  • Ifx does not support then!
  • Ifx was first introduced in EventScripts v1.5.


See also

blog comments powered by Disqus