CoD Utility Functions
There are a number of CoD-specific utility functions that you will find useful. They can ALL be found here: http://ugx-mods.com/script/. There are also other functions that Treyarch wrote for CoD5 and IW wrote for CoD4 that can be found in the raw/maps folder of your CoD5/CoD4 installation. The most used utility function is probably the getEnt() function, which is explained below:
Acquiring Ents and working with them in script
So you want to move that purple box 10ft in the air and then make it disappear? Wow, that's really stupid, man. Why would you want to do that? Did you seriously just spend 45 minutes reading this guide page to accomplish that?
Just kidding! On with the actual info:
Acquiring entities is easy. You use getEnt(value, key) to get one ent (and there must only be one of that name!) and getEntArray(value,key) to get a group of ents with the same name. Most of the time, your key will be "targetname" and your value will be whatever you assigned it in Radiant, although you can acquire ents using other key/value pairs as well (but the question is why bother). To acquire any ent, it MUST BE SET AS A SCRIPT_MODEL (XMODEL) OR SCRIPT_BRUSHMODEL (BRUSH) IN ORDER TO BE SEEN BY SCRIPT. Read that sentence like 5 times. Maybe 10. Seriously. It's REALLY important that you understand that and that you don't forget it.
List of Utility Functions & their Purpose
This is not a complete list. This is a growing list of the more often used functions.
Find more here: http://ugx-mods.com/script/. This list contains no duplicate entries from that site.
boolean flag check.
initializes a flag so it can be set. Flags MUST be initialized before they can be used for the first time.
sets a 'flag' which alerts all flag_wait()'s and changes are reflected in flag() checks thereafter
Pauses execution flow until a flag has been set.
Converts string-formatted numbers to integers. This is helpful when you are doing math with strings and it doesn't perform as expected. (Example, 10+10 returns 01010)
Sends a 'notify' on the entity called on. waittill()'s respond to this.
Pauses execution flow for a defined amount of time. Time cannot be smaller than 0.05.
Usually called on triggers, it pauses execution flow until a notify is cast on whatever entity the waittill has been called on. Optionally, you can define a variable to represent whoever caused the event (commonly 'player'). If the waittill() is not cast on an entity, it waits for a general notify. Can also be used with the 'level' entity for cross-script notifies.
trigger waittill("trigger", player)