Shared Hooks
Shared hook system for the Lilia framework.
Overview
Shared hooks in the Lilia framework handle functionality available on both client and server, typically for data synchronization, shared utilities, and cross-realm features. They follow the Garry's Mod hook system and can be overridden or extended by addons and modules.
AdjustCreationData(client, data, newData, originalData)
Let schemas modify validated character creation data before it is saved.
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)
Allow items or modules to tweak PAC3 part data before it is attached.
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)
Change the stamina delta applied on a tick.
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)
React when an Advanced Dupe 2 paste finishes under BetterDupe.
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)
Notify when a PAC3 part is attached to a player.
Client-side after PAC3 part data is retrieved and before it is tracked locally.
Parameters:
Player client Player receiving the PAC part.string id Identifier of the part or outfit.
Example Usage:
hook.Add("AttachPart", "TrackPACAttachment", function(client, id)
lia.log.add(client, "pacAttach", id)
end)
BagInventoryReady(bagItem, inventory)
Respond when a bag item finishes creating or loading its child inventory.
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)
React when a bag's inventory is being removed.
Before a bag item deletes its child inventory (e.g., on item removal).
Parameters:
Item bagItem Bag being removed.Inventory inventory Child inventory scheduled for deletion.
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)
Calculate the stamina change for a player on a tick.
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)
Calculate the stamina change for a player on a tick.
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)
Decide whether a character can be transferred to a new faction or class.
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)
Control whether a player can invite another player into a class.
Before sending a class invite through the team management menu.
Parameters:
Player client Player issuing the invite.Player target Player being invited.
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)
Control whether a player can invite another player into their faction.
When a player tries to invite someone to join their faction in the team menu.
Parameters:
Player client Player issuing the invite.Player target Player being invited.
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)
Decide whether an outfit item is allowed to change a player's model.
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)
Determine if a player can edit a vendor's configuration.
When opening the vendor editor or applying vendor changes through the UI.
Parameters:
Player client Player attempting to edit.Entity vendor Vendor entity being edited.
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)
Allow or prevent a player from picking up a money entity.
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)
Filter which weapons appear as selectable in the weapon selector.
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)
Allow schemas to veto or validate a character creation attempt.
On the server when a player submits the creation form and before processing begins.
Parameters:
Player client Player creating the character.table data Raw creation data received from the client.
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)
Decide if a player may join a given class.
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)
Control whether a player can knock on a door with their hands.
When the hands SWEP secondary attack is used on a door entity.
Parameters:
Player arg1 Player attempting to knock.Entity arg2 Door entity being knocked on.
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)
Gate whether a player can change a configuration variable.
Client- and server-side when a config edit is attempted through the admin tools or config UI.
Parameters:
Player client Player attempting the change.string key Config key being modified.
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)
Determine if a player may rotate an item in an inventory grid.
When handling the client drag/drop rotate action for an item slot.
Parameters:
Player client Player requesting the rotation.Item item Item instance being rotated.
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)
Gate whether a player is allowed to throw a punch.
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)
Decide if a player can execute a specific console/chat command.
Each time a command is run through the command library before execution.
Parameters:
Player client Player running the command.table command Command definition table.
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)
Control whether an item action should be available.
While building item action menus both client-side (UI) and server-side (validation).
Parameters:
Item tempItem Item being acted on.string key Action identifier (e.g., "equip", "drop").
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)
Force a character to recognize others within a range.
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)
Override how character flag checks are evaluated.
Whenever `playerMeta:hasFlags` is queried to determine character permissions.
Parameters:
Player client Player whose character is being checked.string flags Flag string to test.
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)
Modify chat metadata before it is dispatched.
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)
React when a new chat/console command is registered.
Immediately after a command is added to the command library.
Parameters:
string command Command identifier.table data Command definition table.
Example Usage:
hook.Add("CommandAdded", "LogCommands", function(name, data)
print("Command registered:", name, "adminOnly:", data.adminOnly)
end)
ConfigChanged(key, value, oldValue, client)
Run logic after a configuration value changes.
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)
Customize how module files are included.
During module loading in the modularity library for each include path.
Parameters:
string path Path of the file being included.table MODULE Module table receiving the include.
Example Usage:
hook.Add("DoModuleIncludes", "TrackModuleIncludes", function(path, MODULE)
MODULE.loadedFiles = MODULE.loadedFiles or {}
table.insert(MODULE.loadedFiles, path)
end)
ForceRecognizeRange(ply, range, fakeName)
Force a character to recognize everyone within a given chat range.
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)
Override the maximum level a character can reach for a given attribute.
Whenever attribute caps are checked, such as when spending points or granting boosts.
Parameters:
Player client Player whose attribute cap is being queried.string id Attribute identifier.
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)
Define the maximum starting value for an attribute during character creation.
While allocating starting attribute points to limit each stat.
Parameters:
Player client Player creating the character.string attribute Attribute identifier.
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)
Specify a character's maximum stamina pool.
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)
Provide a default character description for a faction.
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)
Provide a default character name for a faction.
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)
Override the default inventory dimensions a character starts with.
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)
Decide what name is shown for a player in chat based on recognition.
Client-side when rendering chat messages to resolve a display name.
Parameters:
Player client Speaker whose name is being displayed.string chatType Chat channel identifier.
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)
Adjust the delay between punches for the hands SWEP.
Each time the fists are swung to determine the next attack delay.
Parameters:
Player arg1 Player punching.number arg2 Default delay before the next punch.
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)
Override the model used when an item spawns as a world entity.
When an item entity is created server-side to set its model.
Parameters:
table itemTable Item definition table.Entity itemEntity Spawned item entity.
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)
Override the maximum number of characters a player may create.
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)
Set the total attribute points available during character creation.
On the creation screen when allocating starting attributes.
Parameters:
Player client Player creating the character.number count Default maximum points.
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)
Identify the gender classification for a player model.
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)
Pick the world model used by a money entity based on its amount.
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)
Supply additional dialog options for an NPC conversation.
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)
Adjust fist damage output for a punch.
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)
Set how long a target is ragdolled when nonlethal punches knock them down.
When a punch would kill a player while lethality is disabled.
Parameters:
Player arg1 Attacker.Entity arg2 Target player being knocked out.
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)
Override a vendor's buy/sell price for an item.
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)
Set the ragdoll duration when a player is knocked out.
Whenever `playerMeta:setRagdolled` determines the ragdoll time.
Parameters:
Player client Player being ragdolled.number time Proposed ragdoll time.
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)
Apply a global sale/markup scale to vendor transactions.
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)
Override the display name derived from a weapon when creating an item or showing UI.
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)
Initialize a storage entity's inventory rules or data.
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)
InitializedConfig()
Signal that configuration definitions have been loaded client-side.
After the administration config UI finishes building available options.
Example Usage:
hook.Add("InitializedConfig", "BuildConfigUI", function()
lia.config.buildList()
end)
InitializedItems()
Notify that all items have been registered.
After item scripts finish loading during initialization.
Example Usage:
hook.Add("InitializedItems", "CacheItemIDs", function()
lia.itemIDCache = table.GetKeys(lia.item.list)
end)
InitializedKeybinds()
Signal that keybind definitions are loaded.
After keybinds are registered during initialization.
Example Usage:
hook.Add("InitializedKeybinds", "RegisterCustomBind", function()
lia.key.addBind("ToggleHUD", KEY_F6, "Toggle HUD", function(client) hook.Run("ToggleHUD") end)
end)
InitializedModules()
Announce that all modules have finished loading.
After module include phase completes, including reloads.
Example Usage:
hook.Add("InitializedModules", "WarmWorkshopCache", function()
lia.workshop.cache = lia.workshop.gather()
end)
InitializedOptions()
Notify that all options have been registered and loaded.
After the option library finishes loading saved values on the client.
Example Usage:
hook.Add("InitializedOptions", "ApplyThemeOption", function()
hook.Run("OnThemeChanged", lia.option.get("Theme", "Teal"), false)
end)
InitializedSchema()
Fire once the schema finishes loading.
After schema initialization completes; useful for schema-level setup.
Example Usage:
hook.Add("InitializedSchema", "SetupSchemaData", function()
lia.schema.setupComplete = true
end)
InventoryDataChanged(instance, key, oldValue, value)
React to inventory metadata changes.
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)
Signal that an inventory has finished initializing on the client.
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)
React when an item is added to an inventory.
After an item successfully enters an inventory, both server- and client-side.
Parameters:
Inventory inventory Inventory receiving the item.Item item Item instance added.
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)
React when an item leaves an inventory.
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)
Decide if a character is recognized under a fake name.
When checking recognition with fake names enabled.
Parameters:
Character character Character performing the recognition check.number id Target character ID.
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)
Override whether one character recognizes another.
Whenever recognition checks are performed for chat or display logic.
Parameters:
Character a Character performing the check.number arg2 Target character ID.
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)
Declare which chat types should hide names when unrecognized.
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)
Check if an entity can host a storage trunk.
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)
React when persistent data on an item changes.
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)
Inject or modify the default function set applied to every item.
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)
Notify that an item instance has been initialized client-side.
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)
React when an item's quantity changes.
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)
LiliaLoaded()
Signal that the Lilia client has finished loading.
After pre-load hooks complete on the client startup sequence.
Example Usage:
hook.Add("LiliaLoaded", "OpenHUD", function()
lia.hud.init()
end)
NetVarChanged(client, key, oldValue, value)
Respond to networked variable changes on entities, players, or characters.
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)
Signal that the admin system integration has loaded.
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)
Notify when a ragdolled character finishes getting up.
After a get-up action completes and the ragdoll entity is removed.
Parameters:
Player target Player whose character stood up.Entity entity Ragdoll entity that was removed.
Example Usage:
hook.Add("OnCharGetup", "ClearRagdollState", function(player, ragdoll)
player:setLocalVar("brth", nil)
end)
OnCharVarChanged(character, varName, oldVar, newVar)
React whenever a character variable changes.
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)
React on the client when a config value updates.
Client-side after a config entry changes and is broadcast.
Parameters:
string key Config key.any oldValue Previous value.
any value New value.
Example Usage:
hook.Add("OnConfigUpdated", "ReloadLanguage", function(key, old, new)
if key == "Language" then lia.lang.clearCache() end
end)
OnItemAdded(owner, item)
Handle server-side logic when an item is added to an inventory.
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)
React when an item entity is spawned into the world.
When `lia_item` entities are created for dropped or spawned items.
Parameters:
table itemTable Static item definition.Entity itemEntity Spawned entity representing the item.
Example Usage:
hook.Add("OnItemCreated", "EnableGlow", function(itemTable, entity)
if itemTable.rare then entity:SetRenderFX(kRenderFxHologram) end
end)
OnItemOverridden(item, overrides)
Inspect or modify item override data during registration.
When overrides are applied to an item definition at load time.
Parameters:
table item Item definition being overridden.table overrides Table of override values.
Example Usage:
hook.Add("OnItemOverridden", "EnsureCategory", function(item, overrides)
if overrides.category == nil then overrides.category = "misc" end
end)
OnItemRegistered(ITEM)
Run logic immediately after an item type is registered.
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()
Notify that localization files have finished loading.
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)
Handle PAC3 parts being reassigned to a ragdoll.
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)
React when a player purchases or sells a door.
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)
Called when a player drops an item from their inventory.
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)
Called when a player rotates an item in their inventory.
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)
Called when a player takes an item into their inventory.
After an item has been successfully taken into a player's inventory.
Parameters:
Player client The player who took the item.Item item The item that was taken.
Example Usage:
hook.Add("OnPlayerTakeItem", "LogItemPickup", function(client, item)
print(client:Name() .. " took " .. item:getName())
end)
OnPrivilegeRegistered(arg1, arg2, arg3, arg4)
React when an admin privilege is registered.
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)
React when an admin privilege is removed.
When CAMI/compatibility layers unregister a privilege.
Parameters:
table arg1 Privilege data being removed.any arg2 Optional extra data.
Example Usage:
hook.Add("OnPrivilegeUnregistered", "CleanupPrivilegeCache", function(priv)
lia.admin.cache[priv.Name] = nil
end)
OnThemeChanged(themeName, useTransition)
Notify clients that the active UI theme changed.
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)
Respond after a character is transferred between factions or classes.
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)
React when a new usergroup is created in the admin system.
When an admin integration registers a new group.
Parameters:
string groupName Name of the new group.any arg2 Optional extra data (e.g., privilege list).
Example Usage:
hook.Add("OnUsergroupCreated", "CacheNewGroup", function(name)
lia.admin.refreshGroupCache(name)
end)
OnUsergroupRemoved(groupName)
React when a usergroup is removed.
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)
React when a usergroup is renamed.
After the admin system renames an existing group.
Parameters:
string oldName Previous group name.string newName Updated group name.
Example Usage:
hook.Add("OnUsergroupRenamed", "UpdateGroupCache", function(oldName, newName)
lia.admin.groups[newName] = lia.admin.groups[oldName]
lia.admin.groups[oldName] = nil
end)
OptionAdded(key, name, option)
Notify that a new option has been registered.
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)
Handle updates to option values.
After `lia.option.set` changes a value (client or server).
Parameters:
string key Option key.any old Previous value.
any value New value.
Example Usage:
hook.Add("OptionChanged", "ApplyHUDScale", function(key, old, new)
if key == "HUDScale" then lia.hud.setScale(new) end
end)
OverrideFactionDesc(uniqueID, arg2)
Override the description shown for a faction.
During faction registration/loading while assembling faction data.
Parameters:
string uniqueID Faction unique identifier.string arg2 Current description.
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)
Override the model list for a faction.
During faction registration/loading while choosing models.
Parameters:
string uniqueID Faction identifier.table arg2 Default models table.
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)
Override the display name for a faction.
During faction registration/loading before teams are created.
Parameters:
string uniqueID Faction identifier.string arg2 Default faction name.
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)
Adjust the respawn timer for a player.
When calculating respawn delay on client and server.
Parameters:
Player ply Player that will respawn.number baseTime Base respawn time in seconds.
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)
Perform post-punch logic such as stamina consumption.
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)
PreLiliaLoaded()
Run right before the client finishes loading Lilia.
At the start of the client load sequence before `LiliaLoaded`.
Example Usage:
hook.Add("PreLiliaLoaded", "SetupFonts", function()
lia.util.createFont("liaBig", 32)
end)
RemovePart(client, id)
Notify when a PAC3 part should be removed from a player.
Client-side when a part id is marked for removal from a player.
Parameters:
Player client Player losing the part.string id Identifier of the part to remove.
Example Usage:
hook.Add("RemovePart", "ClearCachedPart", function(client, id)
if client.liaPACParts then client.liaPACParts[id] = nil end
end)
SetupBagInventoryAccessRules(inventory)
Apply standard access rules to a bag's child inventory.
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)
SetupPACDataFromItems()
Build PAC3 data from equipped items and push it to clients.
Shortly after PAC compatibility initializes to rebuild outfit data.
Example Usage:
hook.Add("SetupPACDataFromItems", "AddCustomPAC", function()
for _, client in player.Iterator() do client:syncParts() end
end)
TryViewModel(entity)
Allows overriding the view model entity for PAC compatibility.
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)