Entity Meta
Entity management system for the Lilia framework.
Overview
The entity meta table provides comprehensive functionality for extending Garry's Mod entities with Lilia-specific features and operations. It handles entity identification, sound management, door access control, vehicle ownership, network variable synchronization, and entity-specific operations. The meta table operates on both server and client sides, with the server managing entity data and validation while the client provides entity interaction and display. It includes integration with the door system for access control, vehicle system for ownership management, network system for data synchronization, and sound system for audio playback. The meta table ensures proper entity identification, access control validation, network data synchronization, and comprehensive entity interaction management for doors, vehicles, and other game objects.
EmitSound(soundName, soundLevel, pitchPercent, volume, channel, flags, dsp)
Detour of Entity:EmitSound that plays a sound from this entity, handling web sound URLs and fallbacks. This function overrides the base game's EmitSound method to add support for web-sourced audio streams.
Use whenever an entity needs to emit a sound that may be streamed.
Parameters:
string soundName File path or URL to play.number soundLevel Sound level for attenuation.
number pitchPercent Pitch modifier.
number volume Volume from 0-100.
number channel Optional sound channel.
number flags Optional emit flags.
number dsp Optional DSP effect index.
Returns:
boolean True when handled by websound logic; otherwise base emit result.Example Usage:
ent:EmitSound("lilia/websounds/example.mp3", 75)
isProp()
Indicates whether this entity is a physics prop.
Use when filtering interactions to physical props only.
Returns:
boolean True if the entity class is prop_physics.Example Usage:
if ent:isProp() then handleProp(ent) end
isItem()
Checks if the entity represents a Lilia item.
Use when distinguishing item entities from other entities.
Returns:
boolean True if the entity class is lia_item.Example Usage:
if ent:isItem() then pickUpItem(ent) end
isMoney()
Checks if the entity is a Lilia money pile.
Use when processing currency pickups or interactions.
Returns:
boolean True if the entity class is lia_money.Example Usage:
if ent:isMoney() then ent:Remove() end
isSimfphysCar()
Determines whether the entity belongs to supported vehicle classes.
Use when applying logic specific to Simfphys/LVS vehicles.
Returns:
boolean True if the entity is a recognized vehicle type.Example Usage:
if ent:isSimfphysCar() then configureVehicle(ent) end
checkDoorAccess(client, access)
Verifies whether a client has a specific level of access to a door.
Use when opening menus or performing actions gated by door access.
Parameters:
Player client Player requesting access.number access Required access level, defaults to DOOR_GUEST.
Returns:
boolean True if the client meets the access requirement.Example Usage:
if door:checkDoorAccess(ply, DOOR_OWNER) then openDoor() end
keysOwn(client)
Assigns vehicle ownership metadata to a player.
Use when a player purchases or claims a vehicle entity.
Parameters:
Player client Player to set as owner.Example Usage:
vehicle:keysOwn(ply)
keysLock()
Locks a vehicle entity via its Fire interface.
Use when a player locks their owned vehicle.
Example Usage:
vehicle:keysLock()
keysUnLock()
Unlocks a vehicle entity via its Fire interface.
Use when giving a player access back to their vehicle.
Example Usage:
vehicle:keysUnLock()
getDoorOwner()
Retrieves the owning player for a door or vehicle, if any.
Use when displaying ownership information.
Returns:
Player|nil Owner entity or nil if unknown.Example Usage:
local owner = door:getDoorOwner()
isLocked()
Returns whether the entity is flagged as locked through net vars.
Use when deciding if interactions should be blocked.
Returns:
boolean True if the entity's locked net var is set.Example Usage:
if door:isLocked() then denyUse() end
isDoorLocked()
Checks the underlying lock state of a door entity.
Use when syncing lock visuals or handling use attempts.
Returns:
boolean True if the door reports itself as locked.Example Usage:
local locked = door:isDoorLocked()
isFemale()
Infers whether the entity's model is tagged as female.
Use for gender-specific animations or sounds.
Returns:
boolean True if GetModelGender returns "female".Example Usage:
if ent:isFemale() then setFemaleVoice(ent) end
getDoorPartner()
Finds the paired door entity associated with this door.
Use when syncing double-door behavior or ownership.
Returns:
Entity|nil Partner door entity when found.Example Usage:
local partner = door:getDoorPartner()
sendNetVar(key, receiver)
Sends a networked variable for this entity to one or more clients.
Use immediately after changing lia.net values to sync them.
Parameters:
string key Net variable name to send.Player receiver optional Optional player to send to; broadcasts when nil.
Example Usage:
ent:sendNetVar("locked", ply)
clearNetVars(receiver)
Clears all stored net vars for this entity and notifies clients.
Use when an entity is being removed or reset.
Parameters:
Player receiver optional Optional target to notify; broadcasts when nil.Example Usage:
ent:clearNetVars()
removeDoorAccessData()
Resets stored door access data and closes any open menus.
Use when clearing door permissions or transferring ownership.
Example Usage:
door:removeDoorAccessData()
setLocked(state)
Sets the locked net var state for this entity.
Use when toggling lock status server-side.
Parameters:
boolean state Whether the entity should be considered locked.Example Usage:
door:setLocked(true)
setKeysNonOwnable(state)
Marks an entity as non-ownable for keys/door systems.
Use when preventing selling or owning of a door/vehicle.
Parameters:
boolean state True to make the entity non-ownable.Example Usage:
door:setKeysNonOwnable(true)
setNetVar(key, value, receiver)
Stores a networked variable for this entity and notifies listeners.
Use when updating shared entity state that clients need.
Parameters:
string key Net variable name.any value Value to store and broadcast.
Player receiver optional Optional player to send to; broadcasts when nil.
Example Usage:
ent:setNetVar("color", Color(255, 0, 0))
setLocalVar(key, value)
Saves a local (server-only) variable on the entity.
Use for transient server state that should not be networked.
Parameters:
string key Local variable name.any value Value to store.
Example Usage:
ent:setLocalVar("cooldown", CurTime())
getLocalVar(key, default)
Reads a server-side local variable stored on the entity.
Use when retrieving transient server-only state.
Parameters:
string key Local variable name.any default Value to return if unset.
Returns:
any Stored local value or default.Example Usage:
local cooldown = ent:getLocalVar("cooldown", 0)
playFollowingSound(soundPath, volume, shouldFollow, maxDistance, startDelay, minDistance, pitch, soundLevel, dsp)
Plays a web sound locally on the client, optionally following the entity.
Use when the client must play a streamed sound attached to an entity.
Parameters:
string soundPath URL or path to the sound.number volume Volume from 0-1.
boolean shouldFollow Whether the sound follows the entity.
number maxDistance Maximum audible distance.
number startDelay Delay before playback starts.
number minDistance Minimum distance for attenuation.
number pitch Playback rate multiplier.
number soundLevel Optional sound level for attenuation.
number dsp Optional DSP effect index.
Example Usage:
ent:playFollowingSound(url, 1, true, 1200)
isDoor()
Determines whether this entity should be treated as a door.
Use when applying door-specific logic on an entity.
Returns:
boolean True if the entity class matches common door types.Example Usage:
if ent:isDoor() then handleDoor(ent) end
getNetVar(key, default)
Retrieves a networked variable stored on this entity.
Use when reading shared entity state on either server or client.
Parameters:
string key Net variable name.any default Fallback value if none is set.
Returns:
any Stored net var or default.Example Usage:
local locked = ent:getNetVar("locked", false)