Entities

Entities are used in to specify player spawn locations or to add effects, doors, items and more to a map.

Category: trigger (7)

ID 96 - Trigger_If (If)

Info

Evaluates a condition and runs its triggers when the condition is true. You can either choose from a set of predefined conditions (see list below) or run a custom Lua condition. The Lua evaluation runs in the same Lua space as all other Lua scripts (map scripts and server scripts) so you can use functions and variables from these scripts.

Condition types (Trigger entities in trigger field if...):
  • 0 - Lua expression (strs[0]) is true (mp_luamap must be enabled to make this work)

  • 1 - at least A player(s) are in area B,C,D,E (x, y, width, height in tiles)

  • 2 - max A player(s) area in area B,C,D,E (x, y, width, height in tiles)

  • 3 - entity state at A, B (position in tiles) is 0 (visible/enabled)

  • 4 - entity state at A, B (position in tiles) is 1 (hidden/disabled)

  • 5 - at least A terrorists are alive

  • 6 - at least A counter-terrorists are alive

  • 7 - max A terrorists are alive

  • 8 - max A counter-terrorists are alive

  • 9 - remaining round time in seconds is greater/equal A (always triggers in game modes without time limit)

  • 10 - remaining round time in seconds is less/equal A (never triggers in game modes without time limit)

  • 11 - at least A item(s) are at B,C (position in tiles)

  • 12 - max A item(s) are at B, C (position in tiles)

  • 13 - any building is at A, B (position in tiles)

  • 14 - no building is at A, B (position in tiles)


Here are some examples for the Lua condition evaluation:

Sample 1: Always trigger
true


Sample 2: Never trigger
false


Sample 3: Only trigger if the Lua variable "sample" has the value 5
sample==5


Sample 4: Only trigger if the Lua variable "sample" has a value between 3 and 7 (4,5,6)
sample>3 and sample<7


Sample 5: Only trigger if there is a player with ID 1 on the server
player(1,"exists")


Attention: The server setting mp_luamap must be 1 to make Lua condition evaluation work (other conditions work always).

Attention: This entity can be abused to execute malicious Lua code. For this reason mp_luamap is set to 0 by default!

Values / Properties

The following values can be set in the entity properties menu of the map editor and can be read using the Lua command entity.

  • ints[0]=Condition type (0 = Lua, > 0: Predefined condition)
  • ints[1]=Condition parameter A (in most cases: amount or X coordinate in tiles)
  • ints[2]=Condition parameter B (in most cases: X or Y coordinate in tiles)
  • ints[3]=Condition parameter C (in most cases: Y coordinate in tiles)
  • ints[4]=Condition parameter D (in most cases: area width in tiles)
  • ints[5]=Condition parameter E (in most cases: area height in tiles)
  • strs[0]=Lua expression to evaluate (in case condition type is 0)