-
Notifications
You must be signed in to change notification settings - Fork 4
Script Builtin Functions
This is the overview of script builtins provided by engine, they are autogenerated by pragma engine and defined in inc/pragma_builtins.qc
.
They are grouped into three categories:
- shared - can be executed by all programs
- client - can only be executed by client programs
progs/client.dat
- server - can only be executed by server programs
progs/server.dat
builtins listed below can be executed by client and server programs
void print(string s)
Prints text to console
void dprint(string s)
Prints text to console when developer mode is enabled (cvar developer 1
must be set)
void resetrunaway()
Resets the infinite loop error
counter, this should be used in heavy functions that do a lot of operations and accidentally trigger this error.
void traceon()
Enable script execution trace, code you want to trace should be between traceon()
and traceoff()
. The stack trace will be printed to console after QC program has ended execution. developer 1
must be set to use this.
void traceoff()
Stops tracking program execution, see traceon()
. developer 1
must be set to use this.
void crash()
Hard crashes engine, useful for debugging (legends say). developer 1
must be set to use this.
void printstack()
Prints script stack execution to console. developer 1
must be set to use this.
void localcmd(string str)
Executes string in local command buffer, an example could be localcmd("name player; reconnect\n");
float argc()
Returns arguments count of a command, this is used in ClientCommand
and ServerCommand
functions.
string argv(float idx)
Returns argument number idx
as a string, this is used in ClientCommand
and ServerCommand
functions.
float cvar(string str)
Returns cva value as float
string cvarstring(string str)
Returns cvar value as string
void cvarset(string str, string val)
Sets value of a local cvar, this will not change cvars flagged as CVAR_ROM
.
void cvarforceset(string str, string val)
Sets value of a local cvar, this will change even cvars marked as CVAR_ROM
, be very careful with this.
string ftos(float f)
returns float as string
string vtos(vector v1)
returns vector as string
float rint(float val)
Rounds val
to an integral value
float floor(float val)
Rounds val
downward, returning the largest integral value that is not greater than val
float ceil(float val)
Rounds val
upward, returning the smallest integral value that is not less than val
.
float sin(float val)
Returns the sine of an angle of val
radians.
float cos(float val)
Returns the cosine of an angle of val
radians.
float sqrt(float val)
Returns the square root of val
.
vector normalize(vector in)
Returns the normalized in
vector.
float vlen(vector in)
Return the length of in
vector.
float vectoyaw(vector in)
Returns the YAW
angle of in
vector.
float vectoangles(vector in)
vectoangles
float random()
Returns random number in range [-1.0 - 1.0]
builtins listed below can be executed by server programs
TODO fixme
builtins listed below can be executed by client programs
TODO fixme