Shared
This page documents the functions and methods in the meta table.
Overview
AdjustCreationData(client, data, newData, originalData)
Purpose
Let schemas modify validated character creation data before it is saved.
When Called
After creation data is sanitized and validated in `liaCharCreate`, before the final table is merged and written.
Parameters
Player client Player creating the character.
table data Sanitized values for registered character variables.
table newData Table you can populate with overrides that will be merged into `data`.
table originalData Copy of the raw client payload prior to sanitation.
Example Usage
hook.Add("AdjustCreationData", "ForcePrefix", function(client, data, newData)
if data.faction == FACTION_STAFF then newData.name = "[STAFF] " .. (newData.name or data.name) end
end)
AdjustPACPartData(wearer, id, data)
Purpose
Allow items or modules to tweak PAC3 part data before it is attached.
When Called
Client-side when PAC3 builds part data for an outfit id before `AttachPart` runs.
Parameters
Player wearer Entity that will wear the PAC part.
string id Unique part identifier, usually an item uniqueID.
table data PAC3 data table that can be edited.
Returns
table|nil Return a replacement data table, or nil to keep the modified `data`.
Example Usage
hook.Add("AdjustPACPartData", "TintPoliceVisors", function(wearer, id, data)
if wearer:Team() == FACTION_POLICE and data.Material then data.Material = "models/shiny" end
end)
AdjustStaminaOffset(client, offset)
Purpose
Change the stamina delta applied on a tick.
When Called
Each stamina update before the offset is clamped and written to the player.
Parameters
Player client Player whose stamina is being processed.
number offset Positive regen or negative drain calculated from movement.
Returns
number|nil Override for the stamina offset; nil keeps the existing value.
Example Usage
hook.Add("AdjustStaminaOffset", "HeavyArmorTax", function(client, offset)
if client:GetNWBool("HeavyArmor") then return offset - 1 end
end)
AdvDupe_FinishPasting(tbl)
Purpose
React when an Advanced Dupe 2 paste finishes under BetterDupe.
When Called
After AdvDupe2 completes the paste queue so compatibility state can be reset.
Parameters
table tbl Paste context provided by AdvDupe2 (first entry is the player).
Example Usage
hook.Add("AdvDupe_FinishPasting", "ClearTempState", function(info)
local ply = info[1] and info[1].Player
if IsValid(ply) then ply.tempBetterDupe = nil end
end)
AttachPart(client, id)
BagInventoryReady(bagItem, inventory)
Purpose
Respond when a bag item finishes creating or loading its child inventory.
When Called
After a bag instance allocates an inventory (on instancing or restore) and access rules are applied.
Parameters
Item bagItem The bag item that owns the inventory.
Inventory inventory Child inventory created for the bag.
Example Usage
hook.Add("BagInventoryReady", "AutoLabelBag", function(bagItem, inventory)
inventory:setData("bagName", bagItem:getName())
end)
BagInventoryRemoved(bagItem, inventory)
Purpose
React when a bag's inventory is being removed.
When Called
Before a bag item deletes its child inventory (e.g., on item removal).
Parameters
Example Usage
hook.Add("BagInventoryRemoved", "DropBagContents", function(bagItem, inv)
for _, item in pairs(inv:getItems()) do item:transfer(nil, nil, nil, nil, true) end
end)
CalcStaminaChange(client)
Purpose
Calculate the stamina change for a player on a tick.
When Called
From the stamina timer in the attributes module every 0.25s and on client prediction.
Parameters
Player client Player being processed.
Returns
number Positive regen or negative drain applied to the player's stamina pool.
Example Usage
function MODULE:CalcStaminaChange(client)
local offset = self.BaseClass.CalcStaminaChange(self, client)
if client:IsAdmin() then offset = offset + 1 end
return offset
end
CalcStaminaChange(client)
Purpose
Calculate the stamina change for a player on a tick.
When Called
From the stamina timer in the attributes module every 0.25s and on client prediction.
Parameters
Player client Player being processed.
Returns
number Positive regen or negative drain applied to the player's stamina pool.
Example Usage
function MODULE:CalcStaminaChange(client)
local offset = self.BaseClass.CalcStaminaChange(self, client)
if client:IsAdmin() then offset = offset + 1 end
return offset
end
CanCharBeTransfered(tChar, faction, arg3)
Purpose
Decide whether a character can be transferred to a new faction or class.
When Called
Before character transfer commands/classes move a character to another faction/class.
Parameters
Character tChar Character being transferred.
number|string faction Target faction or class identifier.
number|string arg3 Current faction or class being left.
Returns
boolean, string|nil Return false and an optional reason to block the transfer.
Example Usage
hook.Add("CanCharBeTransfered", "PreventDuplicateFaction", function(char, factionID)
if lia.faction.indices[factionID] and lia.faction.indices[factionID].oneCharOnly then
for _, other in pairs(lia.char.getAll()) do
if other.steamID == char.steamID and other:getFaction() == factionID then
return false, L("charAlreadyInFaction")
end
end
end
end)
CanInviteToClass(client, target)
Purpose
Control whether a player can invite another player into a class.
When Called
Before sending a class invite through the team management menu.
Parameters
Returns
boolean, string|nil Return false (optionally with reason) to block the invite.
Example Usage
hook.Add("CanInviteToClass", "RestrictByRank", function(client, target)
if not client:IsAdmin() then return false, L("insufficientPermissions") end
end)
CanInviteToFaction(client, target)
Purpose
Control whether a player can invite another player into their faction.
When Called
When a player tries to invite someone to join their faction in the team menu.
Parameters
Returns
boolean, string|nil Return false to deny the invitation with an optional message.
Example Usage
hook.Add("CanInviteToFaction", "BlockFullFaction", function(client, target)
local faction = lia.faction.indices[client:Team()]
if faction and faction.memberLimit and faction.memberLimit <= faction:countMembers() then
return false, L("limitFaction")
end
end)
CanOutfitChangeModel(item)
Purpose
Decide whether an outfit item is allowed to change a player's model.
When Called
Before an outfit applies its model change during equip or removal.
Parameters
Item item Outfit attempting to change the player's model.
Returns
boolean Return false to prevent the outfit from changing the model.
Example Usage
hook.Add("CanOutfitChangeModel", "RestrictModelSwap", function(item)
return not item.player:getNetVar("NoModelChange", false)
end)
CanPerformVendorEdit(client, vendor)
Purpose
Determine if a player can edit a vendor's configuration.
When Called
When opening the vendor editor or applying vendor changes through the UI.
Parameters
Returns
boolean, string|nil Return false to block edits with an optional reason.
Example Usage
hook.Add("CanPerformVendorEdit", "AdminOnlyVendors", function(client, vendor)
if not client:IsAdmin() then return false, L("insufficientPermissions") end
end)
CanPickupMoney(activator, moneyEntity)
Purpose
Allow or prevent a player from picking up a money entity.
When Called
When a player uses a `lia_money` entity to collect currency.
Parameters
Entity activator Entity attempting to pick up the money (usually a Player).
Entity moneyEntity Money entity being collected.
Returns
boolean, string|nil Return false to block pickup with an optional message.
Example Usage
hook.Add("CanPickupMoney", "RespectWantedStatus", function(client, money)
if client:getNetVar("isWanted") then return false, L("cannotPickupWhileWanted") end
end)
CanPlayerChooseWeapon(weapon)
Purpose
Filter which weapons appear as selectable in the weapon selector.
When Called
When building the client weapon selection UI before allowing a weapon choice.
Parameters
Weapon weapon Weapon entity being considered.
Returns
boolean Return false to hide or block selection of the weapon.
Example Usage
hook.Add("CanPlayerChooseWeapon", "HideUnsafeWeapons", function(weapon)
if weapon:GetClass():find("admin") then return false end
end)
CanPlayerCreateChar(client, data)
Purpose
Allow schemas to veto or validate a character creation attempt.
When Called
On the server when a player submits the creation form and before processing begins.
Parameters
Returns
boolean, string|nil Return false and an optional message to deny creation.
Example Usage
hook.Add("CanPlayerCreateChar", "LimitByPlaytime", function(client)
if not client:playTimeGreaterThan(3600) then return false, L("needMorePlaytime") end
end)
CanPlayerJoinClass(client, class, info)
Purpose
Decide if a player may join a given class.
When Called
Before assigning a class in the class library and character selection.
Parameters
Player client Player requesting the class.
number class Target class index.
table info Class data table for convenience.
Returns
boolean, string|nil Return false to block the class switch with an optional reason.
Example Usage
hook.Add("CanPlayerJoinClass", "WhitelistCheck", function(client, class, info)
if info.requiresWhitelist and not client:getChar():getClasswhitelists()[class] then
return false, L("noWhitelist")
end
end)
CanPlayerKnock(arg1, arg2)
Purpose
Control whether a player can knock on a door with their hands.
When Called
When the hands SWEP secondary attack is used on a door entity.
Parameters
Returns
boolean Return false to prevent the knock action.
Example Usage
hook.Add("CanPlayerKnock", "BlockPoliceDoors", function(client, door)
if door.isPoliceDoor then return false end
end)
CanPlayerModifyConfig(client, key)
Purpose
Gate whether a player can change a configuration variable.
When Called
Client- and server-side when a config edit is attempted through the admin tools or config UI.
Parameters
Returns
boolean, string|nil Return false to deny the modification with an optional message.
Example Usage
hook.Add("CanPlayerModifyConfig", "SuperAdminOnly", function(client)
if not client:IsSuperAdmin() then return false, L("insufficientPermissions") end
end)
CanPlayerRotateItem(client, item)
Purpose
Determine if a player may rotate an item in an inventory grid.
When Called
When handling the client drag/drop rotate action for an item slot.
Parameters
Returns
boolean, string|nil Return false to block rotation with an optional error message.
Example Usage
hook.Add("CanPlayerRotateItem", "LockQuestItems", function(client, item)
if item:getData("questLocked") then return false, L("itemLocked") end
end)
CanPlayerThrowPunch(client)
Purpose
Gate whether a player is allowed to throw a punch.
When Called
Before the hands SWEP starts a punch, after playtime and stamina checks.
Parameters
Player client Player attempting to punch.
Returns
boolean|string|nil Return false to stop the punch; optionally return a reason string.
Example Usage
hook.Add("CanPlayerThrowPunch", "DisallowTiedPlayers", function(client)
if client:getNetVar("tied") then return false, L("cannotWhileTied") end
end)
CanPlayerUseCommand(client, command)
Purpose
Decide if a player can execute a specific console/chat command.
When Called
Each time a command is run through the command library before execution.
Parameters
Returns
boolean, string|nil Return false to block the command with an optional reason.
Example Usage
hook.Add("CanPlayerUseCommand", "RestrictNonStaff", function(client, command)
if command.adminOnly and not client:IsAdmin() then return false, L("insufficientPermissions") end
end)
CanRunItemAction(tempItem, key)
Purpose
Control whether an item action should be available.
When Called
While building item action menus both client-side (UI) and server-side (validation).
Parameters
Returns
boolean Return false to hide or block the action.
Example Usage
hook.Add("CanRunItemAction", "NoDropQuestItems", function(item, action)
if action == "drop" and item:getData("questLocked") then return false end
end)
CharForceRecognized(ply, range)
Purpose
Force a character to recognize others within a range.
When Called
When the recognition module sets recognition for every character around a player.
Parameters
Player ply Player whose character will recognize others.
string|number range Range preset ("whisper", "normal", "yell") or numeric distance.
Example Usage
hook.Add("CharForceRecognized", "AlwaysRecognizeStaff", function(ply)
if ply:IsAdmin() then ply:getChar():giveAllRecognition() end
end)
CharHasFlags(client, flags)
Purpose
Override how character flag checks are evaluated.
When Called
Whenever `playerMeta:hasFlags` is queried to determine character permissions.
Parameters
Returns
boolean Return true to force pass, false to force fail, or nil to defer to default logic.
Example Usage
hook.Add("CharHasFlags", "HonorVIP", function(client, flags)
if client:IsUserGroup("vip") and flags:find("V") then return true end
end)
ChatParsed(client, chatType, message, anonymous)
Purpose
Modify chat metadata before it is dispatched.
When Called
After chat parsing but before the chat type and message are sent to recipients.
Parameters
Player client Speaker.
string chatType Parsed chat command (ic, ooc, etc.).
string message Original chat text.
boolean anonymous Whether the message is anonymous.
Returns
string, string, boolean|nil Optionally return a replacement chatType, message, and anonymous flag.
Example Usage
hook.Add("ChatParsed", "AddOOCPrefix", function(client, chatType, message, anonymous)
if chatType == "ooc" then return chatType, "[GLOBAL] " .. message, anonymous end
end)
CommandAdded(command, data)
ConfigChanged(key, value, oldValue, client)
Purpose
Run logic after a configuration value changes.
When Called
When a config entry is updated via admin tools or code on the server.
Parameters
string key Config key that changed.
any value New value.
any oldValue Previous value.
Player client optional Player who made the change, if any.
Example Usage
hook.Add("ConfigChanged", "BroadcastChange", function(key, value, old, client)
if SERVER then lia.log.add(client, "configChanged", key, tostring(old), tostring(value)) end
end)
DoModuleIncludes(path, MODULE)
Purpose
Customize how module files are included.
When Called
During module loading in the modularity library for each include path.
Parameters
Example Usage
hook.Add("DoModuleIncludes", "TrackModuleIncludes", function(path, MODULE)
MODULE.loadedFiles = MODULE.loadedFiles or {}
table.insert(MODULE.loadedFiles, path)
end)
ForceRecognizeRange(ply, range, fakeName)
Purpose
Force a character to recognize everyone within a given chat range.
When Called
By recognition commands to mark nearby characters as recognized.
Parameters
Player ply Player whose recognition list is being updated.
string|number range Range preset ("whisper", "normal", "yell") or numeric distance.
string fakeName optional Optional fake name to record for recognition.
Example Usage
hook.Add("ForceRecognizeRange", "LogForcedRecognition", function(ply, range)
lia.log.add(ply, "charRecognizeRange", tostring(range))
end)
GetAttributeMax(client, id)
Purpose
Override the maximum level a character can reach for a given attribute.
When Called
Whenever attribute caps are checked, such as when spending points or granting boosts.
Parameters
Returns
number|nil Maximum allowed level (defaults to infinity).
Example Usage
hook.Add("GetAttributeMax", "HardCapEndurance", function(client, id)
if id == "end" then return 50 end
end)
GetAttributeStartingMax(client, attribute)
Purpose
Define the maximum starting value for an attribute during character creation.
When Called
While allocating starting attribute points to limit each stat.
Parameters
Returns
number|nil Maximum value allowed at creation; nil falls back to default limits.
Example Usage
hook.Add("GetAttributeStartingMax", "LowStartForStrength", function(client, attribute)
if attribute == "str" then return 5 end
end)
GetCharMaxStamina(char)
Purpose
Specify a character's maximum stamina pool.
When Called
Whenever stamina is clamped, restored, or initialized.
Parameters
Character char Character whose stamina cap is being read.
Returns
number|nil Max stamina value; defaults to `DefaultStamina` config when nil.
Example Usage
hook.Add("GetCharMaxStamina", "PerkBonus", function(char)
if char:hasFlags("S") then return lia.config.get("DefaultStamina", 100) + 25 end
end)
GetDefaultCharDesc(client, arg2, data)
Purpose
Provide a default character description for a faction.
When Called
During creation validation and adjustment for the `desc` character variable.
Parameters
Player client Player creating the character.
number arg2 Faction index being created.
table data Creation payload.
Returns
string, boolean|nil Description text and a flag indicating whether to override the player's input.
Example Usage
hook.Add("GetDefaultCharDesc", "StaffDesc", function(client, faction)
if faction == FACTION_STAFF then return L("staffCharacterDiscordSteamID", "n/a", client:SteamID()), true end
end)
GetDefaultCharName(client, faction, data)
Purpose
Provide a default character name for a faction.
When Called
During creation validation and adjustment for the `name` character variable.
Parameters
Player client Player creating the character.
number faction Target faction index.
table data Creation payload.
Returns
string, boolean|nil Name text and a flag indicating whether to override the player's input.
Example Usage
hook.Add("GetDefaultCharName", "StaffTemplate", function(client, faction, data)
if faction == FACTION_STAFF then return "Staff - " .. client:SteamName(), true end
end)
GetDefaultInventorySize(client, char)
Purpose
Override the default inventory dimensions a character starts with.
When Called
During inventory setup on character creation and load.
Parameters
Player client Player owning the character.
Character char Character whose inventory size is being set.
Returns
number, number|nil Inventory width and height; nil values fall back to config defaults.
Example Usage
hook.Add("GetDefaultInventorySize", "LargeBagsForStaff", function(client, char)
if client:IsAdmin() then return 8, 6 end
end)
GetDisplayedName(client, chatType)
Purpose
Decide what name is shown for a player in chat based on recognition.
When Called
Client-side when rendering chat messages to resolve a display name.
Parameters
Returns
string|nil Name to display; nil lets the default recognition logic run.
Example Usage
hook.Add("GetDisplayedName", "ShowAliasInWhisper", function(client, chatType)
if chatType == "w" then return client:getChar():getData("alias") end
end)
GetHandsAttackSpeed(arg1, arg2)
Purpose
Adjust the delay between punches for the hands SWEP.
When Called
Each time the fists are swung to determine the next attack delay.
Parameters
Returns
number|nil Replacement delay; nil keeps the default.
Example Usage
hook.Add("GetHandsAttackSpeed", "FasterCombatDrugs", function(client, defaultDelay)
if client:getNetVar("combatStim") then return defaultDelay * 0.75 end
end)
GetItemDropModel(itemTable, itemEntity)
Purpose
Override the model used when an item spawns as a world entity.
When Called
When an item entity is created server-side to set its model.
Parameters
Returns
string|nil Model path to use; nil keeps the item's configured model.
Example Usage
hook.Add("GetItemDropModel", "IconicMoneyBag", function(itemTable)
if itemTable.uniqueID == "moneycase" then return "models/props_c17/briefcase001a.mdl" end
end)
GetMaxPlayerChar(client)
Purpose
Override the maximum number of characters a player may create.
When Called
When rendering the character list and validating new character creation.
Parameters
Player client Player whose limit is being checked.
Returns
number|nil Maximum character slots; nil falls back to `MaxCharacters` config.
Example Usage
hook.Add("GetMaxPlayerChar", "VIPExtraSlot", function(client)
if client:IsUserGroup("vip") then return (lia.config.get("MaxCharacters") or 5) + 1 end
end)
GetMaxStartingAttributePoints(client, count)
Purpose
Set the total attribute points available during character creation.
When Called
On the creation screen when allocating starting attributes.
Parameters
Returns
number|nil Maximum points allowed; nil keeps the default.
Example Usage
hook.Add("GetMaxStartingAttributePoints", "PerkBonusPoints", function(client, count)
if client:IsAdmin() then return count + 5 end
end)
GetModelGender(model)
Purpose
Identify the gender classification for a player model.
When Called
When entity meta needs to know if a model is treated as female for voice/animations.
Parameters
string model Model path being inspected.
Returns
string|nil "female" to treat as female, or nil for default male handling.
Example Usage
hook.Add("GetModelGender", "CustomFemaleModels", function(model)
if model:find("female_custom") then return "female" end
end)
GetMoneyModel(arg1)
Purpose
Pick the world model used by a money entity based on its amount.
When Called
When a `lia_money` entity initializes and sets its model.
Parameters
number arg1 Amount of currency the entity holds.
Returns
string|nil Model path override; nil falls back to `MoneyModel` config.
Example Usage
hook.Add("GetMoneyModel", "HighValueCash", function(amount)
if amount >= 1000 then return "models/props_lab/box01a.mdl" end
end)
GetNPCDialogOptions(arg1, arg2, arg3)
Purpose
Supply additional dialog options for an NPC conversation.
When Called
When the client requests dialog options for an NPC and builds the menu.
Parameters
Player arg1 Player interacting with the NPC.
Entity arg2 NPC being talked to.
boolean arg3 Whether the NPC supports customization options.
Returns
table|nil Extra dialog options keyed by unique id; nil keeps defaults only.
Example Usage
hook.Add("GetNPCDialogOptions", "AddShopGreeting", function(client, npc)
return {special = {name = "Ask about wares", callback = function() net.Start("npcShop") net.SendToServer() end}}
end)
GetPlayerPunchDamage(arg1, arg2, arg3)
Purpose
Adjust fist damage output for a punch.
When Called
Just before a punch trace applies damage in the hands SWEP.
Parameters
Player arg1 Punching player.
number arg2 Default damage.
table arg3 Context table you may mutate (e.g., `context.damage`).
Returns
number|nil New damage value; nil uses `context.damage` or the original.
Example Usage
hook.Add("GetPlayerPunchDamage", "StrengthAffectsPunch", function(client, damage, ctx)
local char = client:getChar()
if char then ctx.damage = ctx.damage + char:getAttrib("str", 0) * 0.2 end
end)
GetPlayerPunchRagdollTime(arg1, arg2)
Purpose
Set how long a target is ragdolled when nonlethal punches knock them down.
When Called
When a punch would kill a player while lethality is disabled.
Parameters
Returns
number|nil Ragdoll duration in seconds; nil uses `PunchRagdollTime` config.
Example Usage
hook.Add("GetPlayerPunchRagdollTime", "ShorterKO", function(client, target)
if target:IsAdmin() then return 5 end
end)
GetPriceOverride(vendor, uniqueID, price, isSellingToVendor)
Purpose
Override a vendor's buy/sell price for an item.
When Called
When a vendor calculates price for buying from or selling to a player.
Parameters
Entity vendor Vendor entity.
string uniqueID Item unique ID being priced.
number price Base price before modifiers.
boolean isSellingToVendor True if the player is selling an item to the vendor.
Returns
number|nil Replacement price; nil keeps the existing calculation.
Example Usage
hook.Add("GetPriceOverride", "FactionDiscount", function(vendor, uniqueID, price, selling)
if vendor.factionDiscount and not selling then return math.Round(price * vendor.factionDiscount) end
end)
GetRagdollTime(client, time)
Purpose
Set the ragdoll duration when a player is knocked out.
When Called
Whenever `playerMeta:setRagdolled` determines the ragdoll time.
Parameters
Returns
number|nil Replacement time; nil keeps the proposed duration.
Example Usage
hook.Add("GetRagdollTime", "ShorterStaffRagdoll", function(client, time)
if client:IsAdmin() then return math.min(time, 5) end
end)
GetVendorSaleScale(vendor)
Purpose
Apply a global sale/markup scale to vendor transactions.
When Called
When vendors compute sale or purchase totals.
Parameters
Entity vendor Vendor entity performing the sale.
Returns
number|nil Multiplier applied to prices (e.g., 0.9 for 10% off); nil keeps vendor defaults.
Example Usage
hook.Add("GetVendorSaleScale", "HappyHour", function(vendor)
if vendor:GetNWBool("happyHour") then return 0.8 end
end)
GetWeaponName(weapon)
Purpose
Override the display name derived from a weapon when creating an item or showing UI.
When Called
When generating item data from a weapon or showing weapon names in selectors.
Parameters
Entity weapon Weapon entity whose name is being resolved.
Returns
string|nil Custom weapon name; nil falls back to print name.
Example Usage
hook.Add("GetWeaponName", "PrettySWEPNames", function(weapon)
return language.GetPhrase(weapon:GetClass() .. "_friendly") or weapon:GetPrintName()
end)
InitializeStorage(entity)
Purpose
Initialize a storage entity's inventory rules or data.
When Called
After a storage entity is created or loaded and before player interaction.
Parameters
Entity entity Storage entity being prepared.
Example Usage
hook.Add("InitializeStorage", "SetTrunkOwner", function(ent)
if ent:isVehicle() then ent:setNetVar("storageOwner", ent:GetNWString("owner")) end
end)
InventoryDataChanged(instance, key, oldValue, value)
Purpose
React to inventory metadata changes.
When Called
When an inventory's data key is updated and replicated to clients.
Parameters
Inventory instance Inventory whose data changed.
string key Data key.
any oldValue Previous value.
any value New value.
Example Usage
hook.Add("InventoryDataChanged", "UpdateBagLabel", function(inv, key, old, new)
if key == "bagName" then inv:getOwner():notify("Bag renamed to " .. tostring(new)) end
end)
InventoryInitialized(instance)
Purpose
Signal that an inventory has finished initializing on the client.
When Called
After an inventory is created or received over the network.
Parameters
Inventory instance Inventory that is ready.
Example Usage
hook.Add("InventoryInitialized", "ShowInventoryUI", function(inv)
if inv:getOwner() == LocalPlayer() then lia.inventory.show(inv) end
end)
InventoryItemAdded(inventory, item)
Purpose
React when an item is added to an inventory.
When Called
After an item successfully enters an inventory, both server- and client-side.
Parameters
Example Usage
hook.Add("InventoryItemAdded", "PlayPickupSound", function(inv, item)
local owner = inv:getOwner()
if IsValid(owner) then owner:EmitSound("items/ammocrate_open.wav", 60) end
end)
InventoryItemRemoved(inventory, instance, preserveItem)
Purpose
React when an item leaves an inventory.
When Called
After an item is removed from an inventory, optionally preserving the instance.
Parameters
Inventory inventory Inventory losing the item.
Item instance Item removed.
boolean preserveItem True if the item instance is kept alive (e.g., dropped) instead of deleted.
Example Usage
hook.Add("InventoryItemRemoved", "LogRemoval", function(inv, item, preserve)
lia.log.add(inv:getOwner(), "itemRemoved", item.uniqueID, preserve and "preserved" or "deleted")
end)
IsCharFakeRecognized(character, id)
Purpose
Decide if a character is recognized under a fake name.
When Called
When checking recognition with fake names enabled.
Parameters
Returns
boolean Return true if recognized via fake name, false otherwise.
Example Usage
hook.Add("IsCharFakeRecognized", "AlwaysRecognizeSelf", function(character, id)
if character.id == id then return true end
end)
IsCharRecognized(a, arg2)
Purpose
Override whether one character recognizes another.
When Called
Whenever recognition checks are performed for chat or display logic.
Parameters
Returns
boolean Return false to force unrecognized, true to force recognized, or nil to use default logic.
Example Usage
hook.Add("IsCharRecognized", "FactionAutoRecognize", function(character, id)
local other = lia.char.getCharacter(id, character:getPlayer())
if other and other:getFaction() == character:getFaction() then return true end
end)
IsRecognizedChatType(chatType)
Purpose
Declare which chat types should hide names when unrecognized.
When Called
Client-side when choosing to display `[Unknown]` instead of a name.
Parameters
string chatType Chat channel identifier.
Returns
boolean Return true to treat the chat type as requiring recognition.
Example Usage
hook.Add("IsRecognizedChatType", "RecognizedEmote", function(chatType)
if chatType == "me" then return true end
end)
IsSuitableForTrunk(ent)
Purpose
Check if an entity can host a storage trunk.
When Called
Before creating or opening storage tied to an entity (e.g., vehicles).
Parameters
Entity ent Entity being evaluated.
Returns
boolean Return false to disallow trunk storage on this entity.
Example Usage
hook.Add("IsSuitableForTrunk", "AllowSpecificVehicles", function(vehicle)
if vehicle:isSimfphysCar() then return true end
end)
ItemDataChanged(item, key, oldValue, newValue)
Purpose
React when persistent data on an item changes.
When Called
When an item's data key is updated via networking and propagated to clients.
Parameters
Item item Item whose data changed.
string key Data key.
any oldValue Previous value.
any newValue Updated value.
Example Usage
hook.Add("ItemDataChanged", "UpdateDurabilityUI", function(item, key, old, new)
if key == "durability" then item:refreshPanels() end
end)
ItemDefaultFunctions(arg1)
Purpose
Inject or modify the default function set applied to every item.
When Called
During item registration when the base functions table is copied to a new item.
Parameters
table arg1 Functions table for the item being registered.
Example Usage
hook.Add("ItemDefaultFunctions", "AddInspect", function(funcs)
funcs.Inspect = {
name = "inspect",
onRun = function(item) item.player:notify(item:getDesc()) end
}
end)
ItemInitialized(item)
Purpose
Notify that an item instance has been initialized client-side.
When Called
When item data is received over the network and the item is constructed.
Parameters
Item item Newly initialized item instance.
Example Usage
hook.Add("ItemInitialized", "PrimeItemPanels", function(item)
if item.panel then item.panel:Refresh() end
end)
ItemQuantityChanged(item, oldValue, quantity)
Purpose
React when an item's quantity changes.
When Called
After quantity is updated and replicated to clients.
Parameters
Item item Item whose quantity changed.
number oldValue Previous quantity.
number quantity New quantity.
Example Usage
hook.Add("ItemQuantityChanged", "UpdateStackLabel", function(item, old, new)
if item.panel then item.panel:SetStack(new) end
end)
NetVarChanged(client, key, oldValue, value)
Purpose
Respond to networked variable changes on entities, players, or characters.
When Called
Whenever a netVar is updated via `setNetVar` on players, entities, or characters.
Parameters
Entity client Entity whose netVar changed (player or entity).
string key NetVar key.
any oldValue Previous value.
any value New value.
Example Usage
hook.Add("NetVarChanged", "TrackStamina", function(entity, key, old, new)
if key == "stamina" and entity:IsPlayer() then entity.lastStamina = new end
end)
OnAdminSystemLoaded(arg1, arg2)
Purpose
Signal that the admin system integration has loaded.
When Called
After administration modules finish initializing and privileges are available.
Parameters
table arg1 optional Admin integration data, if provided.
table arg2 optional Additional metadata from the admin system.
Example Usage
hook.Add("OnAdminSystemLoaded", "RegisterCustomPrivileges", function()
lia.admin.addPrivilege("spawnVehicles", "Spawn Vehicles")
end)
OnCharGetup(target, entity)
OnCharVarChanged(character, varName, oldVar, newVar)
Purpose
React whenever a character variable changes.
When Called
After a char var setter updates a value and broadcasts it.
Parameters
Character character Character whose variable changed.
string varName Variable key.
any oldVar Previous value.
any newVar New value.
Example Usage
hook.Add("OnCharVarChanged", "FlagChangeNotice", function(char, key, old, new)
if key == "flags" then lia.log.add(char:getPlayer(), "flagsChanged", tostring(old), tostring(new)) end
end)
OnConfigUpdated(key, oldValue, value)
OnItemAdded(owner, item)
Purpose
Handle server-side logic when an item is added to an inventory.
When Called
After an item successfully enters an inventory on the server.
Parameters
Player owner optional Owner player of the inventory, if applicable.
Item item Item instance that was added.
Example Usage
hook.Add("OnItemAdded", "NotifyPickup", function(owner, item)
if IsValid(owner) then owner:notifyLocalized("itemAdded", item:getName()) end
end)
OnItemCreated(itemTable, itemEntity)
Purpose
React when an item entity is spawned into the world.
When Called
When `lia_item` entities are created for dropped or spawned items.
Parameters
Example Usage
hook.Add("OnItemCreated", "EnableGlow", function(itemTable, entity)
if itemTable.rare then entity:SetRenderFX(kRenderFxHologram) end
end)
OnItemOverridden(item, overrides)
Purpose
Inspect or modify item override data during registration.
When Called
When overrides are applied to an item definition at load time.
Parameters
Example Usage
hook.Add("OnItemOverridden", "EnsureCategory", function(item, overrides)
if overrides.category == nil then overrides.category = "misc" end
end)
OnItemRegistered(ITEM)
Purpose
Run logic immediately after an item type is registered.
When Called
At the end of `lia.item.register` once the item table is stored.
Parameters
table ITEM Registered item definition.
Example Usage
hook.Add("OnItemRegistered", "CollectWeaponItems", function(item)
if item.isWeapon then lia.weaponItems = lia.weaponItems or {} table.insert(lia.weaponItems, item.uniqueID) end
end)
OnLocalizationLoaded()
Purpose
Notify that localization files have finished loading.
When Called
After language files and cached phrases are loaded/cleared.
Example Usage
hook.Add("OnLocalizationLoaded", "RefreshLanguageDependentUI", function()
if IsValid(lia.menu.panel) then lia.menu.panel:InvalidateLayout(true) end
end)
OnPAC3PartTransfered(part)
Purpose
Handle PAC3 parts being reassigned to a ragdoll.
When Called
When a player's PAC parts transfer to their ragdoll entity during rendering.
Parameters
Entity|table part PAC3 part being transferred.
Example Usage
hook.Add("OnPAC3PartTransfered", "DisableRagdollPAC", function(part)
part:SetNoDraw(true)
end)
OnPlayerPurchaseDoor(client, door, arg3)
Purpose
React when a player purchases or sells a door.
When Called
During door buy/sell commands after payment/ownership changes are processed.
Parameters
Player client Player performing the transaction.
Entity door Door entity involved.
boolean arg3 True if selling/refunding, false if buying.
Example Usage
hook.Add("OnPlayerPurchaseDoor", "LogDoorSale", function(client, door, selling)
lia.log.add(client, selling and "doorSold" or "doorBought", tostring(door))
end)
OnPlayerDroppedItem(client, spawnedItem)
Purpose
Called when a player drops an item from their inventory.
When Called
After an item has been successfully dropped from a player's inventory.
Parameters
Player client The player who dropped the item.
Entity spawnedItem The spawned item entity that was created.
Example Usage
hook.Add("OnPlayerDroppedItem", "LogItemDrop", function(client, spawnedItem)
print(client:Name() .. " dropped an item")
end)
OnPlayerRotateItem(arg1, item, newRot)
Purpose
Called when a player rotates an item in their inventory.
When Called
After an item has been successfully rotated in a player's inventory.
Parameters
Player arg1 The player who rotated the item.
Item item The item that was rotated.
number newRot The new rotation value.
Example Usage
hook.Add("OnPlayerRotateItem", "LogItemRotation", function(client, item, newRot)
print(client:Name() .. " rotated " .. item:getName() .. " to " .. newRot)
end)
OnPlayerTakeItem(client, item)
OnPrivilegeRegistered(arg1, arg2, arg3, arg4)
Purpose
React when an admin privilege is registered.
When Called
When CAMI/compatibility layers add a new privilege.
Parameters
table arg1 CAMI privilege table or simplified privilege data.
any arg2 Optional extra data from the source integration.
any arg3 Optional extra data from the source integration.
any arg4 Optional extra data from the source integration.
Example Usage
hook.Add("OnPrivilegeRegistered", "SyncPrivileges", function(priv)
print("Privilege added:", priv.Name or priv.name)
end)
OnPrivilegeUnregistered(arg1, arg2)
OnThemeChanged(themeName, useTransition)
Purpose
Notify clients that the active UI theme changed.
When Called
After a theme is applied or a transition completes.
Parameters
string themeName Name of the theme applied.
boolean useTransition True if the theme is transitioning over time.
Example Usage
hook.Add("OnThemeChanged", "RefreshPanels", function(name)
for _, panel in ipairs(vgui.GetWorldPanel():GetChildren()) do if panel.RefreshTheme then panel:RefreshTheme() end end
end)
OnTransferred(target)
Purpose
Respond after a character is transferred between factions or classes.
When Called
Immediately after transfer logic completes in team management.
Parameters
Player target Player whose character was transferred.
Example Usage
hook.Add("OnTransferred", "StripOldClassWeapons", function(client)
client:StripWeapons()
end)
OnUsergroupCreated(groupName, arg2)
OnUsergroupRemoved(groupName)
Purpose
React when a usergroup is removed.
When Called
When an admin integration deletes a group.
Parameters
string groupName Name of the removed group.
Example Usage
hook.Add("OnUsergroupRemoved", "PurgeRemovedGroup", function(name)
lia.admin.groups[name] = nil
end)
OnUsergroupRenamed(oldName, newName)
OptionAdded(key, name, option)
Purpose
Notify that a new option has been registered.
When Called
Immediately after `lia.option.add` stores an option.
Parameters
string key Option key.
table name Stored option table (name is the localized display name).
table option Option metadata table.
Example Usage
hook.Add("OptionAdded", "InvalidateQuickOptions", function(key, opt)
if opt.isQuick or (opt.data and opt.data.isQuick) then lia.option.invalidateCache() end
end)
OptionChanged(key, old, value)
OverrideFactionDesc(uniqueID, arg2)
Purpose
Override the description shown for a faction.
When Called
During faction registration/loading while assembling faction data.
Parameters
Returns
string|nil Replacement description; nil keeps the existing text.
Example Usage
hook.Add("OverrideFactionDesc", "CustomStaffDesc", function(id, desc)
if id == "staff" then return "Lilia staff team" end
end)
OverrideFactionModels(uniqueID, arg2)
Purpose
Override the model list for a faction.
When Called
During faction registration/loading while choosing models.
Parameters
Returns
table|nil Replacement models table; nil keeps defaults.
Example Usage
hook.Add("OverrideFactionModels", "SwapCitizenModels", function(id, models)
if id == "citizen" then return {"models/player/alyx.mdl"} end
end)
OverrideFactionName(uniqueID, arg2)
Purpose
Override the display name for a faction.
When Called
During faction registration/loading before teams are created.
Parameters
Returns
string|nil Replacement name; nil keeps the default.
Example Usage
hook.Add("OverrideFactionName", "RenameCombine", function(id, name)
if id == "combine" then return "Civil Protection" end
end)
OverrideSpawnTime(ply, baseTime)
Purpose
Adjust the respawn timer for a player.
When Called
When calculating respawn delay on client and server.
Parameters
Returns
number|nil New respawn time; nil keeps the base value.
Example Usage
hook.Add("OverrideSpawnTime", "VIPFastRespawn", function(ply, base)
if ply:IsUserGroup("vip") then return math.max(base * 0.5, 1) end
end)
PlayerThrowPunch(client)
Purpose
Perform post-punch logic such as stamina consumption.
When Called
After a punch trace completes in the hands SWEP.
Parameters
Player client Player who just punched.
Example Usage
hook.Add("PlayerThrowPunch", "TrackPunches", function(client)
client.punchesThrown = (client.punchesThrown or 0) + 1
end)
RemovePart(client, id)
SetupBagInventoryAccessRules(inventory)
Purpose
Apply standard access rules to a bag's child inventory.
When Called
Immediately after a bag inventory is created or loaded.
Parameters
Inventory inventory Bag inventory being configured.
Example Usage
hook.Add("SetupBagInventoryAccessRules", "CustomBagRule", function(inventory)
inventory:addAccessRule(function(_, action) if action == "transfer" then return true end end, 2)
end)
TryViewModel(entity)
Purpose
Allows overriding the view model entity for PAC compatibility.
When Called
When determining the view model entity for PAC events.
Parameters
Entity entity The potential view model entity.
Returns
Entity The corrected view model entity, or the original if no correction needed.
Example Usage
hook.Add("TryViewModel", "PACViewModelFix", function(entity)
if entity == pac.LocalPlayer:GetViewModel() then
return pac.LocalPlayer
end
return entity
end)