Skip to content

Extended: CBaseEntity

dounai2333 edited this page Jan 19, 2025 · 3 revisions

Introduction

How to get this userdata:

Entity()
GetEntityByIndex()
FindEntityByName()
CreateEntity()
CreateEntityNoSpawn()

tostring

tostring(entity)

Format entity to a proper string "Entity [{index}][{classname}]".

When formating "worldspawn" entity, string "Entity" will be replaced with "Worldspawn".

Activate

entity:Activate()

Activate the entity. In internal, this call Activate() of the entity.

AddFlags

entity:AddFlags(flag)

Adds flags to the entity.

flag: number

AddSolidFlags

entity:AddSolidFlags(solidflag)

Adds solid flag(s) to the entity.

solidflag: number

AddSpawnFlags

entity:AddSpawnFlags(spawnflag)

Adds onto the current spawnflags of an entity.

spawnflag: number

CanTakeDamage

entity:CanTakeDamage()

Check if current entity can take damage.

Return: true or false

EntIndex

entity:EntIndex()

Same with entity:entindex(). Return the index of entity.

Return: number

EyeAngles

entity:EyeAngles()

Returns the direction a player, npc or ragdoll is looking as a world-oriented angle.

Return: angle

EyePos

entity:EyePos()

Returns the position of an Player/NPC's view.

Return: vector

Fire

entity:Fire(input, value, delay, activator)

Fires an entity's input, conforming to the map IO event queue system.

input: string

value: string or nil

delay: number

activator: player

GetAngles

entity:GetAngles()

Gets the angles of given entity.

Return: angle

GetClassname

entity:GetClassname()

Returns the classname of a entity.

Return: string

GetCollisionBounds

entity:GetCollisionBounds()

Returns an entity's collision bounding box.

Return: vector, vector

GetCollisionGroup

entity:GetCollisionGroup()

Returns the entity's collision group.

Return: number

GetEffects

entity:GetEffects()

Returns a bit flag of all engine effect flags of the entity.

Return: number

GetGravity

entity:GetGravity()

Gets the gravity multiplier of the entity.

Return: number

GetGroundEntity

entity:GetGroundEntity()

Returns the object the entity is standing on.

Return: entity or nil

GetKeyValue

entity:GetKeyValue(key, isstring)

Gets the Hammer key value on an entity.

BUG: If isstring is set to true, but the value isn't a string, game will crash.

Return: string

key: string. Example: origin

isstring: bool

GetLocalAngularVelocity

entity:GetLocalAngularVelocity()

Returns the non-VPhysics angular velocity of the entity relative to its parent entity.

Return: angle

GetModel

entity:GetModel()

Gets the model of given entity.

Return: string

GetModelBounds

entity:GetModelBounds()

Returns the entity's model bounds, not scaled by entity:SetModelScale().

Return: vector, vector

GetModelScale

entity:GetModelScale()

Gets the selected entity's model scale.

Return: number

GetName

entity:GetName()

Returns the map/hammer targetname of this entity.

Return: string

GetOwner

entity:GetOwner()

Returns the owner entity of this entity.

Return: entity or nil

GetParent

entity:GetParent()

Returns the parent entity of this entity.

Return: entity or nil

GetPhysicsObject

entity:GetPhysicsObject()

NOT FINISHED: This part of code is not finished yet, using this most likely won't help you.

Returns the entity's physics object, if the entity has physics.

Return: number

GetPointer

entity:GetPointer()

Return the entity pointer address.

Return: number

GetPos

entity:GetPos()

Gets the position of given entity in the world.

Return: vector

GetRenderMode

entity:GetRenderMode()

Returns the render mode of the entity.

Return: number

GetSolid

entity:GetSolid()

Returns solid type of an entity.

Return: number

GetSolidFlags

entity:GetSolidFlags()

Returns solid flag(s) of an entity.

Return: number

GetSpawnFlags

entity:GetSpawnFlags()

Returns the bitwise spawn flags used by the entity.

Return: number

GetVelocity

entity:GetVelocity()

Returns the entity's velocity.

Return: vector

HasSpawnFlags

entity:HasSpawnFlags(spawnflag)

Returns whether this entity has the specified spawnflags bits set.

Return: true or false

spawnflag: number

Health

entity:Health()

Returns the health of the entity.

Return: number

Ignite

entity:Ignite(length)

Sets the entity on fire.

length: number

IsEffectActive

entity:IsEffectActive(effectflag)

Returns whether an entity has engine effect applied or not.

Return: true or false

effectflag: number

IsFlagSet

entity:IsFlagSet(flag)

Checks if given flag(s) is set or not.

Return: true or false

flag: number

IsOnFire

entity:IsOnFire()

Returns whether the entity is on fire.

Return: true or false

IsOnGround

entity:IsOnGround()

Returns whether the entity is on ground or not.

Return: true or false

IsValid

entity:IsValid()

Returns whether the entity is a valid entity or not.

An entity is valid if:

  1. It is not a nil.
  2. It is not the worldspawn entity.

Return: true or false

IsWeapon

entity:IsWeapon()

Checks if the entity is a weapon or not.

Return: true or false

IsWorld

entity:IsWorld()

Returns if this entity is the map entity Entity[0] worldspawn.

Return: true or false

OnGround

entity:OnGround()

Returns true if the entity is on the ground, and false if it isn't.

Return: true or false

ReadNetvar

entity:ReadNetvar(type, address, ispointer)

Read the networked variable of entity. ispointer is only for string variables.

Return: any

type: string. Example: int, float or vector

address: number. Example: 0xF4

ispointer: bool

RemoveFlags

entity:RemoveFlags(flag)

Removes specified flag(s) from the entity.

flag: number

RemoveSolidFlags

entity:RemoveSolidFlags(solidflag)

Removes solid flag(s) from the entity.

solidflag: number

RemoveSpawnFlags

entity:RemoveSpawnFlags(spawnflag)

Removes a spawnflag from the current spawnflags of an entity.

spawnflag: number

SetAbsVelocity

entity:SetAbsVelocity(velocity)

Sets the entity's velocity.

velocity: vector

SetAngles

entity:SetAngles(angle)

Sets the angles of the entity.

angle: angle

SetCollisionBounds

entity:SetCollisionBounds(mins, maxs, nofire)

Sets the collision bounds for the entity.

If nofire is true, it will not fire the event and doesn't make game update variables.

mins: vector

maxs: vector

nofire: bool

SetCollisionGroup

entity:SetCollisionGroup(group)

Sets the entity's collision group.

group: number

SetGravity

entity:SetGravity(gravity)

Sets the gravity multiplier of the entity.

gravity: number

SetKeyValue

entity:SetKeyValue(key, value)

Sets Hammer key values on an entity.

key: string

value: string

SetLocalAngularVelocity

entity:SetLocalAngularVelocity(angvel)

Sets the entity's angular velocity (rotation speed).

angvel: angle

SetName

entity:SetName(targetname)

Sets the mapping name (targetname) of the entity.

targetname: string

SetParent

entity:SetParent(parent)

Sets the parent of this entity, making it move with its parent. This will make the child entity non solid, nothing can interact with them, including traces.

parent: entity

SetPos

entity:SetPos(pos)

Moves the entity to the specified position.

pos: vector

SetRenderMode

entity:SetRenderMode(rendermode)

Sets the render mode of the entity.

rendermode: number

SetSolid

entity:SetSolid(solid)

Sets the solidity of an entity.

solid: number

SetSolidFlags

entity:SetSolidFlags(solidflag)

Sets solid flag(s) for the entity. This overrides any other flags the entity might have had. Use entity:AddSolidFlags() for adding flags.

solidflag: number

SetSpawnFlags

entity:SetSpawnFlags(spawnflag)

Sets the spawnflags to set of an entity. This overrides any other flags the entity might have had. Use entity:AddSpawnFlags() for adding flags.

spawnflag: number

SetTakeDamage

entity:SetTakeDamage(takedamage)

Sets the entity's take damage flag.

takedamage: number

SetTeam

entity:SetTeam(team)

Sets the entity or player to the chosen team.

team: number

SetVelocity

entity:SetVelocity(velocity)

Sets the entity's velocity.

velocity: vector

Spawn

entity:Spawn()

Initializes the entity and starts its networking. If called on a player, it will respawn them.

TakeDamage

entity:TakeDamage(damage)

Applies the specified amount of damage to the entity.

damage: number

Team

entity:Team()

Returns the entity or player's team ID.

WaterLevel

entity:WaterLevel()

Returns an integer that represents how deep in water the entity is.

0: The entity isn't in water.

1: Slightly submerged (at least to the feet).

2: The majority of the entity is submerged (at least to the waist).

3: Completely submerged.

Return: number

WriteNetvar

entity:WriteNetvar(type, address, value, ispointer)

Write the networked variable of entity to given value. ispointer is only for string variables.

type: string. Example: int, float or vector

address: number. Example: 0xF4

value: any

ispointer: bool

Clone this wiki locally