Difference between revisions of "CEngineFuncs"

From Sven Co-op
Jump to navigation Jump to search
(Created page with "The class <code>CEngineFuncs</code> provides an interface that can be used to access some of the engine’s features. HTML documentation can be found [http://baso88.github.io...")
 
m
Line 125: Line 125:
  
 
<span id="droptofloor"></span>
 
<span id="droptofloor"></span>
==== [[#droptofloor|]]<code>DropToFloor</code> ====
+
==== <code>DropToFloor</code> ====
  
 
<pre>int DropToFloor(edict_t@ pEntity)</pre>
 
<pre>int DropToFloor(edict_t@ pEntity)</pre>
Line 135: Line 135:
  
 
<span id="walkmove"></span>
 
<span id="walkmove"></span>
==== [[#walkmove|]]<code>WalkMove</code> ====
+
==== <code>WalkMove</code> ====
  
 
<pre>int WalkMove(edict_t@ pEntity, float flYaw, float flDist, int iMove)</pre>
 
<pre>int WalkMove(edict_t@ pEntity, float flYaw, float flDist, int iMove)</pre>
Line 163: Line 163:
  
 
<span id="getaimvector"></span>
 
<span id="getaimvector"></span>
==== [[#getaimvector|]]<code>GetAimVector</code> ====
+
==== <code>GetAimVector</code> ====
  
 
<pre>void GetAimVector(edict_t@ pEntity, float flSpeed, Vector&amp; out vecReturn)</pre>
 
<pre>void GetAimVector(edict_t@ pEntity, float flSpeed, Vector&amp; out vecReturn)</pre>
Line 186: Line 186:
  
 
<span id="servercommand"></span>
 
<span id="servercommand"></span>
==== [[#servercommand|]]<code>ServerCommand</code> ====
+
==== <code>ServerCommand</code> ====
  
 
<pre>void ServerCommand(const string&amp; in szCommand)</pre>
 
<pre>void ServerCommand(const string&amp; in szCommand)</pre>
Line 194: Line 194:
  
 
<span id="serverexecute"></span>
 
<span id="serverexecute"></span>
==== [[#serverexecute|]]<code>ServerExecute</code> ====
+
==== <code>ServerExecute</code> ====
  
 
<pre>void ServerExecute()</pre>
 
<pre>void ServerExecute()</pre>
Line 202: Line 202:
  
 
<span id="particleeffect"></span>
 
<span id="particleeffect"></span>
==== [[#particleeffect|]]<code>ParticleEffect</code> ====
+
==== <code>ParticleEffect</code> ====
  
 
<pre>void ParticleEffect(const Vector&amp; in vecOrigin, const Vector&amp; in vecDir, float flColor, float flCount)</pre>
 
<pre>void ParticleEffect(const Vector&amp; in vecOrigin, const Vector&amp; in vecDir, float flColor, float flCount)</pre>
Line 226: Line 226:
  
 
<span id="lightstyle"></span>
 
<span id="lightstyle"></span>
==== [[#lightstyle|]]<code>LightStyle</code> ====
+
==== <code>LightStyle</code> ====
  
 
<pre>void LightStyle(int iStyle, const string&amp; in szVal)</pre>
 
<pre>void LightStyle(int iStyle, const string&amp; in szVal)</pre>
Line 244: Line 244:
  
 
<span id="decalindex"></span>
 
<span id="decalindex"></span>
==== [[#decalindex|]]<code>DecalIndex</code> ====
+
==== <code>DecalIndex</code> ====
  
 
<pre>int DecalIndex(const string&amp; in szName)</pre>
 
<pre>int DecalIndex(const string&amp; in szName)</pre>
Line 252: Line 252:
  
 
<span id="pointcontents"></span>
 
<span id="pointcontents"></span>
==== [[#pointcontents|]]<code>PointContents</code> ====
+
==== <code>PointContents</code> ====
  
 
<pre>CONTENTS PointContents(const Vector&amp; in vecPoint)</pre>
 
<pre>CONTENTS PointContents(const Vector&amp; in vecPoint)</pre>
Line 258: Line 258:
  
 
<span id="cvargetfloat"></span>
 
<span id="cvargetfloat"></span>
==== [[#cvargetfloat|]]<code>CVarGetFloat</code> ====
+
==== <code>CVarGetFloat</code> ====
  
 
<pre>float CVarGetFloat(const string&amp; in szCvar)</pre>
 
<pre>float CVarGetFloat(const string&amp; in szCvar)</pre>
Line 264: Line 264:
  
 
<span id="cvargetstring"></span>
 
<span id="cvargetstring"></span>
==== [[#cvargetstring|]]<code>CVarGetString</code> ====
+
==== <code>CVarGetString</code> ====
  
 
<pre>string CVarGetString(const string&amp; in szCvar)</pre>
 
<pre>string CVarGetString(const string&amp; in szCvar)</pre>
Line 270: Line 270:
  
 
<span id="cvarsetfloat"></span>
 
<span id="cvarsetfloat"></span>
==== [[#cvarsetfloat|]]<code>CVarSetFloat</code> ====
+
==== <code>CVarSetFloat</code> ====
  
 
<pre>void CVarSetFloat(const string&amp; in szCvar, float flValue)</pre>
 
<pre>void CVarSetFloat(const string&amp; in szCvar, float flValue)</pre>
Line 276: Line 276:
  
 
<span id="cvarsetstring"></span>
 
<span id="cvarsetstring"></span>
==== [[#cvarsetstring|]]<code>CVarSetString</code> ====
+
==== <code>CVarSetString</code> ====
  
 
<pre>void CVarSetString(const string&amp; in szCvar, const string&amp; in szValue)</pre>
 
<pre>void CVarSetString(const string&amp; in szCvar, const string&amp; in szValue)</pre>
Line 282: Line 282:
  
 
<span id="getvarsofent"></span>
 
<span id="getvarsofent"></span>
==== [[#getvarsofent|]]<code>GetVarsOfEnt</code> ====
+
==== <code>GetVarsOfEnt</code> ====
  
 
<pre>entvars_t@ GetVarsOfEnt(edict_t@ pEdict)</pre>
 
<pre>entvars_t@ GetVarsOfEnt(edict_t@ pEdict)</pre>
Line 288: Line 288:
  
 
<span id="indexofedict"></span>
 
<span id="indexofedict"></span>
==== [[#indexofedict|]]<code>IndexOfEdict</code> ====
+
==== <code>IndexOfEdict</code> ====
  
 
<pre>int IndexOfEdict(const edict_t@ pEdict)</pre>
 
<pre>int IndexOfEdict(const edict_t@ pEdict)</pre>
Line 294: Line 294:
  
 
<span id="pentityofentindex"></span>
 
<span id="pentityofentindex"></span>
==== [[#pentityofentindex|]]<code>PEntityOfEntIndex</code> ====
+
==== <code>PEntityOfEntIndex</code> ====
  
 
<pre>edict_t@ PEntityOfEntIndex(int iIndex)</pre>
 
<pre>edict_t@ PEntityOfEntIndex(int iIndex)</pre>
Line 300: Line 300:
  
 
<span id="findentitybyvars"></span>
 
<span id="findentitybyvars"></span>
==== [[#findentitybyvars|]]<code>FindEntityByVars</code> ====
+
==== <code>FindEntityByVars</code> ====
  
 
<pre>edict_t@ FindEntityByVars(entvars_t@ pVars)</pre>
 
<pre>edict_t@ FindEntityByVars(entvars_t@ pVars)</pre>
Line 306: Line 306:
  
 
<span id="animationautomove"></span>
 
<span id="animationautomove"></span>
==== [[#animationautomove|]]<code>AnimationAutomove</code> ====
+
==== <code>AnimationAutomove</code> ====
  
 
<pre>void AnimationAutomove(const edict_t@ pEdict, float flTime)</pre>
 
<pre>void AnimationAutomove(const edict_t@ pEdict, float flTime)</pre>
Line 314: Line 314:
  
 
<span id="getboneposition"></span>
 
<span id="getboneposition"></span>
==== [[#getboneposition|]]<code>GetBonePosition</code> ====
+
==== <code>GetBonePosition</code> ====
  
 
<pre>void GetBonePosition(const edict_t@ pEdict, int iBone, Vector&amp; out vecOrigin, Vector&amp; out vecAngles)</pre>
 
<pre>void GetBonePosition(const edict_t@ pEdict, int iBone, Vector&amp; out vecOrigin, Vector&amp; out vecAngles)</pre>
Line 338: Line 338:
  
 
<span id="clientprintf"></span>
 
<span id="clientprintf"></span>
==== [[#clientprintf|]]<code>ClientPrintf</code> ====
+
==== <code>ClientPrintf</code> ====
  
 
<pre>void ClientPrintf(CBasePlayer@ pPlayer, PRINT_TYPE printType, const string&amp; in szMessage)</pre>
 
<pre>void ClientPrintf(CBasePlayer@ pPlayer, PRINT_TYPE printType, const string&amp; in szMessage)</pre>
Line 346: Line 346:
  
 
<span id="serverprint"></span>
 
<span id="serverprint"></span>
==== [[#serverprint|]]<code>ServerPrint</code> ====
+
==== <code>ServerPrint</code> ====
  
 
<pre>void ServerPrint(const string&amp; in szMessage)</pre>
 
<pre>void ServerPrint(const string&amp; in szMessage)</pre>
Line 352: Line 352:
  
 
<span id="cmd_args"></span>
 
<span id="cmd_args"></span>
==== [[#cmd_args|]]<code>Cmd_Args</code> ====
+
==== <code>Cmd_Args</code> ====
  
 
<pre>string Cmd_Args()</pre>
 
<pre>string Cmd_Args()</pre>
Line 358: Line 358:
  
 
<span id="cmd_argv"></span>
 
<span id="cmd_argv"></span>
==== [[#cmd_argv|]]<code>Cmd_Argv</code> ====
+
==== <code>Cmd_Argv</code> ====
  
 
<pre>string Cmd_Argv(int iIndex)</pre>
 
<pre>string Cmd_Argv(int iIndex)</pre>
Line 364: Line 364:
  
 
<span id="cmd_argc"></span>
 
<span id="cmd_argc"></span>
==== [[#cmd_argc|]]<code>Cmd_Argc</code> ====
+
==== <code>Cmd_Argc</code> ====
  
 
<pre>int Cmd_Argc()</pre>
 
<pre>int Cmd_Argc()</pre>
Line 370: Line 370:
  
 
<span id="getattachment"></span>
 
<span id="getattachment"></span>
==== [[#getattachment|]]<code>GetAttachment</code> ====
+
==== <code>GetAttachment</code> ====
  
 
<pre>void GetAttachment(const edict_t@ pEdict, int iAttachment, Vector&amp; out vecOrigin, Vector&amp; out vecAngles)</pre>
 
<pre>void GetAttachment(const edict_t@ pEdict, int iAttachment, Vector&amp; out vecOrigin, Vector&amp; out vecAngles)</pre>
Line 394: Line 394:
  
 
<span id="setview"></span>
 
<span id="setview"></span>
==== [[#setview|]]<code>SetView</code> ====
+
==== <code>SetView</code> ====
  
 
<pre>void SetView(const edict_t@ pEdict, const edict_t@ pViewEntity)</pre>
 
<pre>void SetView(const edict_t@ pEdict, const edict_t@ pViewEntity)</pre>
Line 400: Line 400:
  
 
<span id="time"></span>
 
<span id="time"></span>
==== [[#time|]]<code>Time</code> ====
+
==== <code>Time</code> ====
  
 
<pre>float Time()</pre>
 
<pre>float Time()</pre>
Line 406: Line 406:
  
 
<span id="crosshairangle"></span>
 
<span id="crosshairangle"></span>
==== [[#crosshairangle|]]<code>CrosshairAngle</code> ====
+
==== <code>CrosshairAngle</code> ====
  
 
<pre>void CrosshairAngle(const edict_t@ pEdict, float flPitch, float flYaw)</pre>
 
<pre>void CrosshairAngle(const edict_t@ pEdict, float flPitch, float flYaw)</pre>
Line 412: Line 412:
  
 
<span id="getgamedir"></span>
 
<span id="getgamedir"></span>
==== [[#getgamedir|]]<code>GetGameDir</code> ====
+
==== <code>GetGameDir</code> ====
  
 
<pre>string GetGameDir()</pre>
 
<pre>string GetGameDir()</pre>
Line 418: Line 418:
  
 
<span id="setclientmaxspeed"></span>
 
<span id="setclientmaxspeed"></span>
==== [[#setclientmaxspeed|]]<code>SetClientMaxspeed</code> ====
+
==== <code>SetClientMaxspeed</code> ====
  
 
<pre>void SetClientMaxspeed(const edict_t@ pEdict, float flNewMaxSpeed)</pre>
 
<pre>void SetClientMaxspeed(const edict_t@ pEdict, float flNewMaxSpeed)</pre>
Line 424: Line 424:
  
 
<span id="runplayermove"></span>
 
<span id="runplayermove"></span>
==== [[#runplayermove|]]<code>RunPlayerMove</code> ====
+
==== <code>RunPlayerMove</code> ====
  
 
<pre>void RunPlayerMove(edict_t@ pEdict, const Vector&amp; in vecViewAngles, float flForwardMove, float flSideMove, float flUpMove, uint16 iButtons, uint8 iImpulse, uint8 iMsec)</pre>
 
<pre>void RunPlayerMove(edict_t@ pEdict, const Vector&amp; in vecViewAngles, float flForwardMove, float flSideMove, float flUpMove, uint16 iButtons, uint8 iImpulse, uint8 iMsec)</pre>
Line 460: Line 460:
  
 
<span id="numberofentities"></span>
 
<span id="numberofentities"></span>
==== [[#numberofentities|]]<code>NumberOfEntities</code> ====
+
==== <code>NumberOfEntities</code> ====
  
 
<pre>int NumberOfEntities()</pre>
 
<pre>int NumberOfEntities()</pre>
Line 466: Line 466:
  
 
<span id="getinfokeybuffer"></span>
 
<span id="getinfokeybuffer"></span>
==== [[#getinfokeybuffer|]]<code>GetInfoKeyBuffer</code> ====
+
==== <code>GetInfoKeyBuffer</code> ====
  
 
<pre>KeyValueBuffer@ GetInfoKeyBuffer(edict_t@ pEdict)</pre>
 
<pre>KeyValueBuffer@ GetInfoKeyBuffer(edict_t@ pEdict)</pre>
Line 476: Line 476:
  
 
<span id="getphysicskeybuffer"></span>
 
<span id="getphysicskeybuffer"></span>
==== [[#getphysicskeybuffer|]]<code>GetPhysicsKeyBuffer</code> ====
+
==== <code>GetPhysicsKeyBuffer</code> ====
  
 
<pre>KeyValueBuffer@ GetPhysicsKeyBuffer(edict_t@ pEdict)</pre>
 
<pre>KeyValueBuffer@ GetPhysicsKeyBuffer(edict_t@ pEdict)</pre>
Line 486: Line 486:
  
 
<span id="ismapvalid"></span>
 
<span id="ismapvalid"></span>
==== [[#ismapvalid|]]IsMapValid ====
+
==== IsMapValid ====
  
 
<pre>bool IsMapValid(const string&amp; in szMapName) const</pre>
 
<pre>bool IsMapValid(const string&amp; in szMapName) const</pre>
Line 492: Line 492:
  
 
<span id="staticdecal"></span>
 
<span id="staticdecal"></span>
==== [[#staticdecal|]]<code>StaticDecal</code> ====
+
==== <code>StaticDecal</code> ====
  
 
<pre>void StaticDecal(const Vector&amp; in vecOrigin, int iDecalIndex, int iEntityIndex, int iModelIndex)</pre>
 
<pre>void StaticDecal(const Vector&amp; in vecOrigin, int iDecalIndex, int iEntityIndex, int iModelIndex)</pre>
Line 516: Line 516:
  
 
<span id="getplayeruserid"></span>
 
<span id="getplayeruserid"></span>
==== [[#getplayeruserid|]]<code>GetPlayerUserId</code> ====
+
==== <code>GetPlayerUserId</code> ====
  
 
<pre>int GetPlayerUserId(edict_t@ pEdict)</pre>
 
<pre>int GetPlayerUserId(edict_t@ pEdict)</pre>
Line 522: Line 522:
  
 
<span id="isdedicatedserver"></span>
 
<span id="isdedicatedserver"></span>
==== [[#isdedicatedserver|]]<code>IsDedicatedServer</code> ====
+
==== <code>IsDedicatedServer</code> ====
  
 
<pre>bool IsDedicatedServer() const</pre>
 
<pre>bool IsDedicatedServer() const</pre>
Line 528: Line 528:
  
 
<span id="cvargetpointer"></span>
 
<span id="cvargetpointer"></span>
==== [[#cvargetpointer|]]<code>CVarGetPointer</code> ====
+
==== <code>CVarGetPointer</code> ====
  
 
<pre>const Cvar@ CVarGetPointer(const string&amp; in szCvar) const</pre>
 
<pre>const Cvar@ CVarGetPointer(const string&amp; in szCvar) const</pre>
Line 536: Line 536:
  
 
<span id="getplayerstats"></span>
 
<span id="getplayerstats"></span>
==== [[#getplayerstats|]]<code>GetPlayerStats</code> ====
+
==== <code>GetPlayerStats</code> ====
  
 
<pre>void GetPlayerStats(const edict_t@ pEdict, int&amp; out iPing, int&amp; out iPacketLoss)</pre>
 
<pre>void GetPlayerStats(const edict_t@ pEdict, int&amp; out iPing, int&amp; out iPacketLoss)</pre>
Line 557: Line 557:
  
 
<span id="voice_getclientlistening"></span>
 
<span id="voice_getclientlistening"></span>
==== [[#voice_getclientlistening|]]<code>Voice_GetClientListening</code> ====
+
==== <code>Voice_GetClientListening</code> ====
  
 
<pre>void Voice_GetClientListening(int iReceiver, int iSender)</pre>
 
<pre>void Voice_GetClientListening(int iReceiver, int iSender)</pre>
Line 577: Line 577:
  
 
<span id="voice_setclientlistening"></span>
 
<span id="voice_setclientlistening"></span>
==== [[#voice_setclientlistening|]]<code>Voice_SetClientListening</code> ====
+
==== <code>Voice_SetClientListening</code> ====
  
 
<pre>void Voice_SetClientListening(int iReceiver, int iSender, bool fListen)</pre>
 
<pre>void Voice_SetClientListening(int iReceiver, int iSender, bool fListen)</pre>
Line 600: Line 600:
  
 
<span id="getplayerauthid"></span>
 
<span id="getplayerauthid"></span>
==== [[#getplayerauthid|]]<code>GetPlayerAuthId</code> ====
+
==== <code>GetPlayerAuthId</code> ====
  
 
<pre>string GetPlayerAuthId(edict_t@ pEdict)</pre>
 
<pre>string GetPlayerAuthId(edict_t@ pEdict)</pre>
 
Get player auth id. (WON/Steam id).
 
Get player auth id. (WON/Steam id).

Revision as of 19:08, 16 February 2025

The class CEngineFuncs provides an interface that can be used to access some of the engine’s features.

HTML documentation can be found here.

A single global instance exists:

CEngineFuncs g_EngineFuncs;

1 Methods

1.1 ModelIndex

int ModelIndex(const string& in szModelName)

Gets the model index of a model. This index should be considered to be an opaque handle to the model. It does not represent an index into an array.

If the model was not precached, if it’s a dedicated server, it will be shut down, if it’s a listen server, it will throw you back into the main menu and corrupt the Angelscript context.

1.2 ModelFrames

int ModelFrames(int iModelIndex)

Gets the number of frames in a model.

For brush models, this is always 2: a regular and alternate (+A) texture. For studio models, this is all of the submodels in each body part multiplied with each-other. It represents the number of variations that can be created by changing submodels (e.g. heads, weapons, etc). For sprite models, this is the number of frames.

1.3 ChangeLevel

void ChangeLevel(const string& in szLevelName)

Changes the current level to the one specified. Warning: this will change the level right away. Be careful when using this in scripts as it may result in the script being invalidated before it returns.

1.4 VecToYaw

float VecToYaw(const Vector& in vec)

Converts a vector to a yaw value.

1.5 VecToAngles

void VecToAngles(const Vector& in vec, Vector& out angles)

Converts a vector to euler angles.

1.6 MoveToOrigin

void MoveToOrigin(edict_t@ pEntity, const Vector& in vecGoal, float flDist, int iMoveType)

Moves an entity that can fly (pev.flags & FL_FLY), swim (pev.flags & FL_SWIM), or is on ground (pev.flags & FL_ONGROUND) to a location in the world.

Argument Purpose
pEntity Entity to move.
vecGoal Destination origin.
flDist Number of units to move.
iMoveType Indicates how the entity should move.

1.7 ChangeYaw

void ChangeYaw(edict_t@ pEntity)

Change yaw. This updates entvars_t::angles[ 1 ] to approach entvars_t::ideal_yaw, at entvars_t::yaw_speed degrees speed. Not used by any game code. Replaced by CMath::ApproachAngle.

1.8 ChangePitch

void ChangePitch(edict_t@ pEntity)

Change pitch. This updates entvars_t::angles[ 0 ] to approach entvars_t::idealpitch, at entvars_t::pitch_speeddegrees speed. Not used by any game code. Replaced by [CMath::ApproachAngle`](Math%23ApproachAngle#ApproachAngle).

1.9 [[#getentityillum|]]GetEntityIllum

int GetEntityIllum(edict_t@ pEntity)

Get entity illumination. This is a weighted value between 0 and 255, inclusive.

1.10 [[#findclientinpvs|]]FindClientInPVS

edict_t@ FindClientInPVS(edict_t@ pStartEntity)

Find client in Potentially Visible Set. Returns the world if no client could be found in the entity’s PVS. This function’s behaviour is unexpected: it will get the next client every 0.1 seconds, and check if the entity can see it. If so, the client is returned. Otherwise, the world is returned. Use FNullEnt to check if the result is a valid client.

1.11 [[#entitiesinpvs|]]EntitiesInPVS

edict_t@ EntitiesInPVS(edict_t@ pStartEntity)

Find entities in Potentially Visible Set. This builds a list of entities using edict_t::vars::chain. This list is temporary, so store its results elsewhere if it is needed later on.

Note: This operation is expensive as it checks every entity. Avoid using this unless it is absolutely necessary.

1.12 [[#makevectors|]]MakeVectors

void MakeVectors(const Vector& in vec)

Make direction vectors from angles. The results are stored in g_Engine::v_forward, v_right, and v_up. Each vector represents a direction in one of 3 axes.

1.13 [[#anglevectors|]]AngleVectors

void AngleVectors(const Vector& in vecIn, Vector& out vecForward, Vector& out vecRight, Vector& out vecUp)

Make direction vectors from angles. This returns the same results as MakeVectors, except the destination vectors can be provided by you.

1.14 [[#makestatic|]]MakeStatic

void MakeStatic(edict_t@ pEntity)

Make entity static. This moves the entity to the client. Its current visual state is copied over, and the entity is removed on the server side. Only valid while the level is loading.

Note: Creating too many static entities may cause clients to overflow on connect.

1.15 [[#entisonfloor|]]EntIsOnFloor

int EntIsOnFloor(edict_t@ pEntity)

Returns whether the entity is on the floor. This will perform traces to see if there is a floor under the entity, which can be costly if used often.

1.16 DropToFloor

int DropToFloor(edict_t@ pEntity)

Drops the entity to the floor. The entity will be moved down to the floor, effectively being teleported.

Note: maximum drop distance is 256 units.

Returns -1 if the entity is stuck inside a solid object. Returns 0 if the floor is further than 256 units away. Returns 1 if the entity was dropped to the floor.

1.17 WalkMove

int WalkMove(edict_t@ pEntity, float flYaw, float flDist, int iMove)

Make entity walk.

The entity must be capable of flying (FL_FLY) or swimming (FL_SWIM), or be on the ground (FL_ONGROUND).

Argument Purpose
pEntity Entity to move.
flYaw Yaw distance. This is the entity’s current movement direction in the XY plane.
flDist Distance to move, in units.
iMove Movement type. See the WALKMOVE enum.

Returns 1 if the move succeeded (no obstacles in the way), 0 otherwise.

1.18 GetAimVector

void GetAimVector(edict_t@ pEntity, float flSpeed, Vector& out vecReturn)

Get the aim vector for the given entity. Assumes MakeVectors was called with pEntity.vars.angles beforehand.

The aim vector is the autoaim vector used when sv_aim is enabled. It will snap to entities that are close to the entity’s forward vector axis.

Argument Purpose
pEntity Entity to retrieve the aim vector for.
flSpeed Unused.
vecReturn Aim vector.

1.19 ServerCommand

void ServerCommand(const string& in szCommand)

Issues a command to the server. The command must end with either a newline (\n) or a semicolon (;) in order to be considered valid by the engine.

Plugins only.

1.20 ServerExecute

void ServerExecute()

Executes all pending server commands. Note that commands that end the current map may cause data corruption in scripts. Avoid using this unless absolutely necessary.

Plugins only.

1.21 ParticleEffect

void ParticleEffect(const Vector& in vecOrigin, const Vector& in vecDir, float flColor, float flCount)

Emit a particle effect.

Argument Purpose
vecOrigin Origin in the world to emit the effect at.
vecDir Direction that the effect will move in.
flColor Color of the effect.
flCount Number of particles to create.

1.22 LightStyle

void LightStyle(int iStyle, const string& in szVal)

Set a light style.

Argument Purpose
iStyle Light style index. Normally, values below 32 are used for built-in styles, so avoid using them. Half-Life supports up to 64 styles (determined by reverse engineering).
szVal Light pattern. See light entity documentation for custom appearance.

1.23 DecalIndex

int DecalIndex(const string& in szName)

Get decal index.

Returns a value greater than 0 on success, 0 otherwise.

1.24 PointContents

CONTENTS PointContents(const Vector& in vecPoint)

Get the Contents type for a given point.

1.25 CVarGetFloat

float CVarGetFloat(const string& in szCvar)

Get cvar float value. Returns 0 if the cvar doesn’t exist.

1.26 CVarGetString

string CVarGetString(const string& in szCvar)

Get cvar string value. Returns an empty string if the cvar doesn’t exist.

1.27 CVarSetFloat

void CVarSetFloat(const string& in szCvar, float flValue)

Set cvar float value.

1.28 CVarSetString

void CVarSetString(const string& in szCvar, const string& in szValue)

Set cvar string value.

1.29 GetVarsOfEnt

entvars_t@ GetVarsOfEnt(edict_t@ pEdict)

Gets entity variables of entity. Identical to pEdict.vars.

1.30 IndexOfEdict

int IndexOfEdict(const edict_t@ pEdict)

Get entity index of edict. The world is 0, players are 1 through g_Engine.maxClients. Regular entities start at g_Engine.maxClients + 1.

1.31 PEntityOfEntIndex

edict_t@ PEntityOfEntIndex(int iIndex)

Get entity by entity index. Returns null if no edict exists at that index. The returned edict does not necessarily have a valid entity attached to it.

1.32 FindEntityByVars

edict_t@ FindEntityByVars(entvars_t@ pVars)

Find entity by variables. Identical to pVars.pContainingEntity, but also validates the pContainingEntity field.

1.33 AnimationAutomove

void AnimationAutomove(const edict_t@ pEdict, float flTime)

Animation auto move.

Note: Does nothing, remove from the API.

1.34 GetBonePosition

void GetBonePosition(const edict_t@ pEdict, int iBone, Vector& out vecOrigin, Vector& out vecAngles)

Get the bone position of the given entity’s model.

Argument Purpose
pEdict Entity whose bone position should be retrieved.
iBone Bone index.
vecOrigin Bone position.
vecAngles Bone angles.

1.35 ClientPrintf

void ClientPrintf(CBasePlayer@ pPlayer, PRINT_TYPE printType, const string& in szMessage)

Prints text to the given player’s console.

See the PRINT_TYPE enum.

1.36 ServerPrint

void ServerPrint(const string& in szMessage)

Unconditionally print text to the server console.

1.37 Cmd_Args

string Cmd_Args()

Get current command arguments as a string.

1.38 Cmd_Argv

string Cmd_Argv(int iIndex)

Get current command argument by index.

1.39 Cmd_Argc

int Cmd_Argc()

Gets the number of command arguments from the command that is currently being executed.

1.40 GetAttachment

void GetAttachment(const edict_t@ pEdict, int iAttachment, Vector& out vecOrigin, Vector& out vecAngles)

Get attachment position and angles. The position is an absolute world position, the angles are absolute angles in the world.

Argument Purpose
pEdict Entity whose model will be queried for the attachment position.
iAttachment Attachment index.
vecOrigin Attachment origin.
vecAngles Attachment angles.

1.41 SetView

void SetView(const edict_t@ pEdict, const edict_t@ pViewEntity)

Set player view to a given entity. Pass pEdict as the view entity to reset it to the player’s view.

1.42 Time

float Time()

Returns the time since the first call to Time. Used for delta operations that operate in real world time, as opposed to game world time (which will advance frame by frame, and can be paused).

1.43 CrosshairAngle

void CrosshairAngle(const edict_t@ pEdict, float flPitch, float flYaw)

Sets the angles of the given player’s crosshairs to the given settings. Set both to 0 to disable. May not have any effect in Sven Co-op.

1.44 GetGameDir

string GetGameDir()

Get game directory. This is svencoop for Sven Co-op, or the mod directory if run under any other mod.

1.45 SetClientMaxspeed

void SetClientMaxspeed(const edict_t@ pEdict, float flNewMaxSpeed)

Set client max speed. Bounded by sv_maxspeed. Sets pEdict.vars.maxspeed, and the physics info maxspd key.

1.46 RunPlayerMove

void RunPlayerMove(edict_t@ pEdict, const Vector& in vecViewAngles, float flForwardMove, float flSideMove, float flUpMove, uint16 iButtons, uint8 iImpulse, uint8 iMsec)

Run player move. Used to move bots.

Argument Purpose
pEdict client to move. Must be a fake client.
vecViewAngles Client view angles.
flForwardMove Velocity X value.
flSideMove Velocity Y value.
flUpMove Velocity Z value.
iButtons Buttons that are currently pressed in. Equivalent to player pev.button.
iImpulse Impulse commands to execute. Equivalent to player pev.impulse.
iMsec Time between now and previous RunPlayerMove call.

1.47 NumberOfEntities

int NumberOfEntities()

Gets the number of entities. Note: this will calculate the number of entities in real-time. May be expensive if called many times.

1.48 GetInfoKeyBuffer

KeyValueBuffer@ GetInfoKeyBuffer(edict_t@ pEdict)

Get the given client’s info key buffer. This buffer contains settings sent from the client to the server. Returns null if the given edict is not a client or not connected.

Note: Do not store a handle to this instance, it is temporary and may become invalid.

See KeyValueBuffer.

1.49 GetPhysicsKeyBuffer

KeyValueBuffer@ GetPhysicsKeyBuffer(edict_t@ pEdict)

Get the given client’s physics key buffer. This buffer contains settings that the physics code can access. Returns null if the given edict is not a client or not connected.

Note: Do not store a handle to this instance, it is temporary and may become invalid.

See KeyValueBuffer.

1.50 IsMapValid

bool IsMapValid(const string& in szMapName) const

Returns whether the given map is valid. A map is considered valid if the BSP exists.

1.51 StaticDecal

void StaticDecal(const Vector& in vecOrigin, int iDecalIndex, int iEntityIndex, int iModelIndex)

Project a static decal. Only allowed while the map is loading. Only works on brush models.

Argument Purpose
vecOrigin Origin in the world to project the decal at.
iDecalIndex Index of the decal. Must be retrieved using DecalIndex.
iEntityIndex Index of the entity to project the decal onto.
iModelIndex Index of the model to project the decal onto.

1.52 GetPlayerUserId

int GetPlayerUserId(edict_t@ pEdict)

Get player user ID. This is a unique id generated when a player connects. It remains valid as long as the player stays connected to the server.

1.53 IsDedicatedServer

bool IsDedicatedServer() const

Returns whether this is a dedicated server (true) or a listen server (false).

1.54 CVarGetPointer

const Cvar@ CVarGetPointer(const string& in szCvar) const

Gets a pointer to a cvar. Returns null if no cvar by that name exists.

See Cvar.

1.55 GetPlayerStats

void GetPlayerStats(const edict_t@ pEdict, int& out iPing, int& out iPacketLoss)

Get player stats.

Argument Purpose
pEdict Client to get stats from.
iPing Current ping.
iPacketLoss Current packet loss, measured in percentage.

1.56 Voice_GetClientListening

void Voice_GetClientListening(int iReceiver, int iSender)

Returns whether the given client receives voice data sent by the given sender (voice muting).

Argument Purpose
iReceiver Entity index of the receiving client.
iSender Entity index of the sending client.

Note: return type is currently incorrect.

1.57 Voice_SetClientListening

void Voice_SetClientListening(int iReceiver, int iSender, bool fListen)

Sets whether the given client receives voice data sent by the given sender (voice muting).

Note: The game will override these settings.

Argument Purpose
iReceiver Entity index of the receiving client.
iSender Entity index of the sending client.
fListen Whether or not the receiver should be able to hear the sender.

1.58 GetPlayerAuthId

string GetPlayerAuthId(edict_t@ pEdict)

Get player auth id. (WON/Steam id).