GSC reference › Built-in
Assert()
Built-in (engine)
Server + client
Utility
Assert that the given statement is correct. The function will throw a script error if this is false.
Signature
Assert(<value>, [desc])
Parameters
| Name | Required? | Details |
|---|---|---|
| value | Required | statement that is asserted to be correct |
| desc | Optional | string describing the nature of the assert |
Example (from Treyarch's docs)
Assert( enemyInSight == true )
Real uses in BO3's scripts
Called 2,099 times in the decompiled scripts. A few, zombies first:
- scripts/codescripts/character.gsc, line 227
assert(lowest_indices.size, ""); - scripts/codescripts/delete.csc, line 16
assert(isdefined(self)); - scripts/codescripts/delete.gsc, line 16
assert(isdefined(self)); - scripts/codescripts/struct.csc, line 211
assert(!isdefined(level.struct_class_names[""][self.script_linkname]), ""); - scripts/codescripts/struct.gsc, line 212
assert(!isdefined(level.struct_class_names[""][self.script_linkname]), "");
Related built-ins
- array()Create an array
- GetDvarInt()Gets the value of a dvar.
- IsArray()Checks whether this entity/variable is an array
- GetDvarString()Gets the value of a dvar.
- ArrayRemoveValue()Remove a value from an array (may affect multiple indexes)
- GetDvarFloat()Gets the value of a dvar.
- IsSubStr()Returns true/false if <substring> is a substring of <string>.
- GetArrayKeys()Returns an array consisting of the keys of the input array.
- ArrayCombine()Combine two arrays into and returns one new array
- IsInArray()Searches an array to determine if a given value is present in that array
- StrTok()Tokenizes <string> by the delimiters <delim>.
- AssertMsg()Throws a script error with the given message.
New to GSC?
Start with the basics, or paste a compile error to get the fix.
Built-in descriptions, parameters and examples come from Treyarch's BO3 mod tools docs. Usage links point at shiversoftdev/t7-source (decompiled BO3 scripts).