Garry's Mod Wiki

Entity:GetInternalVariable

any Entity:GetInternalVariable( string variableName )

Description

An interface for accessing internal key values on entities.

See Entity:GetSaveTable for a more detailed explanation. See Entity:SetSaveValue for the opposite of this function.

Arguments

1 string variableName
Name of variable corresponding to an entity save value.

Returns

1 any
The internal variable value.

Example

Get how long it has been since the player was damaged.

local meta = FindMetaTable( "Player" ) function meta:GetLastDamageTime() return self:GetInternalVariable( "m_flLastDamageTime" ) end print( Entity( 1 ):GetLastDamageTime() )
Output:
-31.965000152588

Example

Determine if a door is locked or not (server side).

function IsDoorLocked( entity ) return ( entity:GetInternalVariable( "m_bLocked" ) ) end
Output: Returns true if the door is locked.

Example

Determines whether the door is open or not (server side).

function DoorIsOpen( door ) local doorClass = door:GetClass() if ( doorClass == "func_door" or doorClass == "func_door_rotating" ) then return self:GetInternalVariable( "m_toggle_state" ) == 0 elseif ( doorClass == "prop_door_rotating" ) then return self:GetInternalVariable( "m_eDoorState" ) ~= 0 else return false end end
Output: Returns true if the door is open.

Page Links


Special Pages


Wikis

?

Render Time: 969ms

DB GetPage 213
Generate Html 9
SaveChanges (1) 733
Render Body 0
Render Sidebar 12