Items¶
This page documents hooks in the items category.
CanOutfitChangeModel(item)View Source
Purpose
Determines whether equipping or unequipping an outfit may change the character's model, skin, and bodygroups.
Category
Items
Realm
Server
Parameters
Item item The outfit item being equipped or removed.
Returns
boolean|nil Return false to stop the outfit from changing the player's appearance data. Returning nil allows the default behavior to continue.
Example Usage
hook.Add("CanOutfitChangeModel", "liaExampleCanOutfitChangeModel", function(item)
if item.outfitCategory == "uniform" then
return true
end
end)
CanPlayerUseAmmoBox(activator, ammoBox)View Source
Purpose
Determines whether a player may consume an ammo box before ammo is granted.
Category
Items
Realm
Server
Parameters
Returns
boolean|nil Return false to block the ammo box use. Returning nil allows the default behavior to continue.
Example Usage
hook.Add("CanPlayerUseAmmoBox", "liaExampleCanPlayerUseAmmoBox", function(activator, ammoBox)
if activator:InVehicle() then
return false
end
end)
DrawItemEntityInfo(itemEntity, item, infoTable, alpha)View Source
Purpose
Allows modules to append extra lines to the floating world-item information display before it is drawn.
Category
Items
Realm
Client
Parameters
Entity itemEntity The world item entity being drawn.
Item item The item instance represented by the entity.
table infoTable The mutable list of info entries to draw. Append tables containing fields such as `text` and `yOffset`.
number alpha The current text alpha used for the entity info display.
Example Usage
hook.Add("DrawItemEntityInfo", "liaExampleDrawItemEntityInfo", function(itemEntity, item, infoTable, alpha)
if item and item:getData("rarity") then
infoTable[#infoTable + 1] = {
text = "Rarity: " .. tostring(item:getData("rarity")),
yOffset = 0
}
end
end)
GetItemDropModel(itemTable, itemEntity)View Source
Purpose
Allows modules to override the model used by a dropped item entity before fallback item models are applied.
Category
Items
Realm
Server
Parameters
Item itemTable The item instance being represented in the world.
Entity itemEntity The `lia_item` entity receiving the model.
Returns
string|nil Return a model path to override the dropped item model. Returning nil allows the item definition defaults to continue.
Example Usage
hook.Add("GetItemDropModel", "liaExampleGetItemDropModel", function(itemTable, itemEntity)
if itemTable.uniqueID == "moneybag" then
return "models/props_lab/box01a.mdl"
end
end)
GetWeaponName(weaponTable)View Source
Purpose
Allows modules to provide a display name for automatically generated weapon items.
Category
Items
Realm
Shared
Parameters
table weaponTable The weapon table being converted into an item definition.
Returns
string|nil Return a string to override the generated item name, or nil to use the default name source.
Example Usage
hook.Add("GetWeaponName", "liaExampleGetWeaponName", function(weaponTable)
return "Example Value"
end)
HandleItemTransferRequest(client, itemID, x, y, targetInvID)View Source
Purpose
Handles the actual transfer when a player gives an item forward to another player.
Category
Items
Realm
Server
Parameters
Player client The player initiating the transfer.
number itemID The database ID of the item being transferred.
number x optional The destination inventory X position, if one is specified.
number y optional The destination inventory Y position, if one is specified.
number targetInvID The inventory ID receiving the item.
Returns
deferred|nil Return a deferred transfer result to continue the give-forward flow, or nil to stop handling.
Example Usage
hook.Add("HandleItemTransferRequest", "liaExampleHandleItemTransferRequest", function(client, itemID, x, y, targetInvID)
if not IsValid(client) then return end
print(string.format("[MyModule] handled HandleItemTransferRequest for %s", client:Name()))
end)
InitializedItems()View Source
ItemDefaultFunctions(functions)View Source
Purpose
Allows modules to inspect or modify the default item action table during item registration.
Category
Items
Realm
Shared
Parameters
table functions The mutable table of item action definitions.
Example Usage
hook.Add("ItemDefaultFunctions", "liaExampleItemDefaultFunctions", function(functions)
print("[MyModule] handled ItemDefaultFunctions")
end)
ItemFunctionCalled(self, method, client, entity, results)View Source
Purpose
Runs after an item function is executed so modules can inspect the action and its outcome.
Category
Items
Realm
Server
Parameters
Item self The item whose function ran.
string method The function or action identifier that was executed.
Player client The player who triggered the action.
Entity entity The related entity argument, when one was supplied.
any results The result returned by the item function.
Example Usage
hook.Add("ItemFunctionCalled", "liaExampleItemFunctionCalled", function(self, method, client, entity, results)
print(method, self:getName())
end)
OnAmmoBoxUsed(activator, ammoBox, weapon, ammoType, givenAmount)View Source
Purpose
Runs after an ammo box successfully grants ammunition to the player's active weapon type.
Category
Items
Realm
Server
Parameters
Player activator The player who used the ammo box.
Entity ammoBox The ammo box entity that was consumed.
Weapon weapon The active weapon used to determine the ammo type.
string ammoType The primary ammo type granted by the ammo box.
number givenAmount The amount of ammo actually added.
Example Usage
hook.Add("OnAmmoBoxUsed", "liaExampleOnAmmoBoxUsed", function(activator, ammoBox, weapon, ammoType, givenAmount)
print(activator:Nick(), "received", givenAmount, ammoType)
end)
OnItemCreated(item)View Source
Purpose
Runs after an item instance table is created from a registered item definition.
Category
Items
Realm
Shared
Parameters
Item item The newly created item instance.
Example Usage
hook.Add("OnItemCreated", "liaExampleOnItemCreated", function(item)
print("[MyModule] handled OnItemCreated")
end)
OnItemOverridden(itemDef, overrides)View Source
Purpose
Runs after pending overrides have been applied to an item definition.
Category
Items
Realm
Shared
Parameters
Item itemDef The item definition that received overrides.
table overrides The override table that was applied.
Example Usage
hook.Add("OnItemOverridden", "liaExampleOnItemOverridden", function(itemDef, overrides)
print("[MyModule] handled OnItemOverridden")
end)
OnItemRegistered(itemDef)View Source
Purpose
Runs after an item definition or base item has been registered and localized.
Category
Items
Realm
Shared
Parameters
Item itemDef The registered item definition table.
Example Usage
hook.Add("OnItemRegistered", "liaExampleOnItemRegistered", function(itemDef)
print("[MyModule] handled OnItemRegistered")
end)
OnItemSpawned(itemEntity)View Source
Purpose
Runs after a world item entity initializes so modules can apply extra setup to the spawned entity.
Category
Items
Realm
Server
Parameters
Entity itemEntity The newly initialized `lia_item` entity.
Example Usage
hook.Add("OnItemSpawned", "liaExampleOnItemSpawned", function(itemEntity)
itemEntity:SetColor(color_white)
end)
OnPlayerDroppedItem(client, itemEntity)View Source
Purpose
Runs after a player uses the default drop action and the item has been spawned into the world.
Category
Items
Realm
Server
Parameters
Player client The player who dropped the item.
Entity itemEntity The spawned world entity for the dropped item.
Example Usage
hook.Add("OnPlayerDroppedItem", "liaExampleOnPlayerDroppedItem", function(client, itemEntity)
if not IsValid(client) then return end
print(string.format("[MyModule] handled OnPlayerDroppedItem for %s", client:Name()))
end)
OnPlayerInteractItem(client, action, self, result, data)View Source
Purpose
Runs after a player interacts with an item so modules can inspect the completed action and returned data.
Category
Items
Realm
Server
Parameters
Player client The player who completed the item interaction.
string action The action that was attempted.
Item self The item involved in the interaction.
any result The return value from the item interaction.
table data Additional interaction context passed through the item system.
Example Usage
hook.Add("OnPlayerInteractItem", "liaExampleInteractItem", function(client, action, self, result, data)
print(client:Nick(), action, tostring(result))
end)
OnPlayerRotateItem(client, item, rotated)View Source
Purpose
Runs after a player rotates an inventory item using the default rotate action.
Category
Items
Realm
Server
Parameters
Player client The player who rotated the item.
Item item The item instance that was rotated.
boolean rotated The new rotated state stored on the item.
Example Usage
hook.Add("OnPlayerRotateItem", "liaExampleOnPlayerRotateItem", function(client, item, rotated)
if not IsValid(client) then return end
print(string.format("[MyModule] handled OnPlayerRotateItem for %s", client:Name()))
end)
OnPlayerTakeItem(client, item)View Source
Purpose
Runs after a player successfully takes a world item into their inventory.
Category
Items
Realm
Server
Parameters
Player client The player who took the item.
Item item The item instance that was added to the inventory.
Example Usage
hook.Add("OnPlayerTakeItem", "liaExampleOnPlayerTakeItem", function(client, item)
if not IsValid(client) then return end
print(string.format("[MyModule] handled OnPlayerTakeItem for %s", client:Name()))
end)
OnWeaponOverridesBulkSynced(overrides)View Source
Purpose
Runs after the full static weapon override table has been synchronized to the client.
Category
Items
Realm
Client
Parameters
table overrides The full weapon override table keyed by weapon class name.
Example Usage
hook.Add("OnWeaponOverridesBulkSynced", "liaExampleOnWeaponOverridesBulkSynced", function(overrides)
print("[Weapons] Synced static overrides:", table.Count(overrides))
end)
OnWeaponOverrideUpdated(className, key, value)View Source
Purpose
Runs after a single static weapon override field has been updated on the client.
Category
Items
Realm
Client
Parameters
string className The weapon class whose override changed.
string key The item definition field that was updated.
any value The new override value.
Example Usage
hook.Add("OnWeaponOverrideUpdated", "liaExampleOnWeaponOverrideUpdated", function(className, key, value)
print("[Weapons] Updated", className, key)
end)
OnWeaponRuntimeOverridesBulkSynced(overrides)View Source
Purpose
Runs after the full runtime weapon override table has been synchronized to the client.
Category
Items
Realm
Client
Parameters
table overrides The full runtime override table keyed by weapon class name and dot path.
Example Usage
hook.Add("OnWeaponRuntimeOverridesBulkSynced", "liaExampleOnWeaponRuntimeOverridesBulkSynced", function(overrides)
print("[Weapons] Synced runtime overrides:", table.Count(overrides))
end)
OnWeaponRuntimeOverrideUpdated(className, dotPath, value)View Source
Purpose
Runs after a single runtime weapon override path has been updated on the client.
Category
Items
Realm
Client
Parameters
string className The weapon class whose runtime override changed.
string dotPath The nested runtime path that was updated.
any value The new runtime override value.
Example Usage
hook.Add("OnWeaponRuntimeOverrideUpdated", "liaExampleOnWeaponRuntimeOverrideUpdated", function(className, dotPath, value)
print("[Weapons] Runtime update", className, dotPath)
end)
PaintItem(itemTable)View Source
Purpose
Allows modules to override the material used for item world entities and inventory icon model previews.
Category
Items
Realm
Shared
Parameters
Item itemTable The item instance whose visual material is being resolved.
Returns
string|IMaterial|nil Return a material path or material object to override the item's rendered material. Returning nil allows the item's stored material to continue.
Example Usage
hook.Add("PaintItem", "liaExamplePaintItem", function(itemTable)
if itemTable:getData("glowing") then
return "models/debug/debugwhite"
end
end)
PrePlayerInteractItem(client, action, self)View Source
Purpose
Runs just before a player interacts with an item so modules can react before the action result is known.
Category
Items
Realm
Server
Parameters
Player client The player starting the item interaction.
string action The item action being attempted.
Item self The item being interacted with.
Example Usage
hook.Add("PrePlayerInteractItem", "liaExamplePreInteractItem", function(client, action, self)
print(client:Nick(), action, self:getName())
end)