Skip to content

Entity

Entity metadata helpers for sound playback, ownership, locks, doors, vehicles, and networked variables.


Overview

The entity meta table extends Garry's Mod entities with helpers for custom sound emission, vehicle ownership, lock state checks, door behavior, and replicated per-entity variables used by the framework.

EmitSound(soundName, soundLevel, pitchPercent, volume, channel, flags, dsp)View Source

Purpose

Extends `Entity:EmitSound` to support URL-based and cached web sounds.

Realm

Shared

Parameters

string soundName The sound path, web URL, or registered websound identifier.

number soundLevel The sound level used for distance calculations.

number pitchPercent The playback pitch.

number volume The playback volume.

number channel The sound channel.

number flags Additional sound flags.

number dsp The DSP preset.

Returns

boolean `true` when the sound is handled by the custom websound path. any Falls back to the base `EmitSound` return value otherwise.

Example Usage

  entity:EmitSound("https://example.com/radio.mp3", 75, 100, 1)

isProp()View Source

Purpose

Checks whether the entity is a physics prop.

Realm

Shared

Returns

boolean `true` if the entity class is `prop_physics`.

Example Usage

  if entity:isProp() then print("prop") end

isItem()View Source

Purpose

Checks whether the entity is a Lilia item entity.

Realm

Shared

Returns

boolean `true` if the entity class is `lia_item`.

Example Usage

  if entity:isItem() then print("item") end

isMoney()View Source

Purpose

Checks whether the entity is a money entity.

Realm

Shared

Returns

boolean `true` if the entity class is `lia_money`.

Example Usage

  if entity:isMoney() then print("money") end

isSimfphysCar()View Source

Purpose

Determines whether the entity should be treated as a simfphys or LVS vehicle.

Realm

Shared

Returns

boolean `true` if the entity matches a known supported vehicle class or flag.

Example Usage

  if entity:isSimfphysCar() then print("vehicle") end

checkDoorAccess(client, access)View Source

Purpose

Checks whether a player has the requested access level on a door.

Realm

Shared

Parameters

Player client The player whose access is being checked.

number access The minimum door access level to require. Defaults to `DOOR_GUEST`.

Returns

boolean `true` if the player is allowed to access the door.

Example Usage

  if door:checkDoorAccess(client, DOOR_TENANT) then return end

keysOwn(client)View Source

Purpose

Assigns ownership metadata to a vehicle for the given player.

Realm

Server

Parameters

Player client The player who should own the vehicle.

Example Usage

  vehicle:keysOwn(client)

keysLock()View Source

Purpose

Locks a vehicle entity.

Realm

Shared

Example Usage

  vehicle:keysLock()

keysUnLock()View Source

Purpose

Unlocks a vehicle entity.

Realm

Shared

Example Usage

  vehicle:keysUnLock()

getDoorOwner()View Source

Purpose

Gets the CPPI owner of a vehicle entity.

Realm

Shared

Returns

Player|nil The vehicle owner when available.

Example Usage

  local owner = vehicle:getDoorOwner()

isLocked()View Source

Purpose

Reads the locked state from the entity's internal variables.

Realm

Shared

Returns

boolean|nil The current locked state, depending on entity type.

Example Usage

  if entity:isLocked() then return end

isDoorLocked()View Source

Purpose

Checks whether a door is currently locked.

Realm

Shared

Returns

boolean `true` if the door reports a locked state.

Example Usage

  if door:isDoorLocked() then return end

isFemale()View Source

Purpose

Determines whether the entity model is considered female.

Realm

Shared

Returns

boolean `true` if the model gender hook resolves to `female`.

Example Usage

  if entity:isFemale() then print("female model") end

getDoorPartner()View Source

Purpose

Finds the paired door entity for a door or door-owned prop.

Realm

Shared

Returns

Entity|nil The partner door entity when one can be found.

Example Usage

  local partner = door:getDoorPartner()

sendNetVar(key, receiver)View Source

Purpose

Sends one networked entity variable to one client or everyone.

Realm

Server

Parameters

string key The netvar key to send.

Player receiver Optional client to receive the update.

Example Usage

  entity:sendNetVar("locked", client)

clearNetVars(receiver)View Source

Purpose

Clears stored networked variables for the entity and notifies clients.

Realm

Server

Parameters

Player receiver Optional client to receive the clear message.

Example Usage

  entity:clearNetVars()

removeDoorAccessData()View Source

Purpose

Removes stored door access data and refreshes affected clients.

Realm

Server

Example Usage

  door:removeDoorAccessData()

setLocked(state)View Source

Purpose

Stores a replicated locked flag on the entity.

Realm

Server

Parameters

boolean state The locked state to replicate.

Example Usage

  entity:setLocked(true)

setKeysNonOwnable(state)View Source

Purpose

Marks a door or entity as not being sellable/ownable through the keys system.

Realm

Server

Parameters

boolean state Whether the entity should be non-ownable.

Example Usage

  door:setKeysNonOwnable(true)

setNetVar(key, value, receiver)View Source

Purpose

Stores a networked variable for the entity and dispatches the update.

Realm

Server

Parameters

string key The netvar key.

any value The value to store.

Player receiver Optional client to receive the update.

Example Usage

  entity:setNetVar("ownerName", client:Name())

setLocalVar(key, value)View Source

Purpose

Stores a server-only local variable for the entity.

Realm

Server

Parameters

string key The local variable key.

any value The value to store.

Example Usage

  entity:setLocalVar("cachedDoorName", "Lobby")

getLocalVar(key, default)View Source

Purpose

Retrieves a server-only local variable from the entity.

Realm

Server

Parameters

string key The local variable key.

any default The fallback value when the key is missing.

Returns

any The stored value or the provided default.

Example Usage

  local name = entity:getLocalVar("cachedDoorName", "Unknown")

playFollowingSound(soundPath, volume, shouldFollow, maxDistance, startDelay, minDistance, pitch, soundLevel, dsp)View Source

Purpose

Plays a local or remote sound and keeps it positioned on the entity.

Realm

Client

Parameters

string soundPath The file path or URL to play.

number volume Playback volume from `0` to `1`.

boolean shouldFollow Whether the sound should continue following the entity.

number maxDistance Maximum audible distance.

number startDelay Optional delay before playback starts.

number minDistance Minimum fade distance.

number pitch Optional playback rate multiplier.

number soundLevel Reserved for compatibility with callers.

number dsp Optional DSP preset.

Example Usage

  entity:playFollowingSound("https://example.com/ambience.mp3", 0.8, true, 1200)

isDoor()View Source

Purpose

Determines whether the entity should be treated as a door.

Realm

Shared

Returns

boolean `true` if the entity class matches the expected door patterns.

Example Usage

  if entity:isDoor() then print("door") end

getNetVar(key, default)View Source

Purpose

Gets a networked variable stored on the entity.

Realm

Shared

Parameters

string key The netvar key.

any default The fallback value when the key is missing.

Returns

any The stored value or the provided default.

Example Usage

  local ownerName = entity:getNetVar("ownerName", "Unowned")