Module

General Hooks.

These hooks are regular hooks that can be used in your schema with SCHEMA:HookName(args), in your module with MODULE:HookName(args), or in your addon with hook.Add("HookName", function(args) end). They can be used for an assorted of reasons, depending on what you are trying to achieve.

Functions

MODULE:CanPlayerDropItem(client, item)

Whether or not a player is allowed to drop the given item.

Parameters

  • client Player

    Player attempting to drop an item

  • item Integer

    instance ID of the item being dropped

Returns

  • bool

    Whether or not to allow the player to drop the item

Example Usage

function MODULE:CanPlayerDropItem(client, item)
	return false -- Never allow dropping items.
end

MODULE:CanPlayerEquipItem(client, item)

Whether or not a player can equip the given item. This is called for items with outfit, pacoutfit, or weapons as their base. Schemas/modules can utilize this hook for their items.

Parameters

  • client Player

    Player attempting to equip the item

  • item Table

    Item being equipped

Returns

  • bool

    Whether or not to allow the player to equip the item

Example Usage

function MODULE:CanPlayerEquipItem(client, item)
	return client:isStaff() -- Restrict equipping items to staff only.
end

See Also

MODULE:CanPlayerInteractItem(client, action, item)

Whether or not a player is allowed to interact with an item via an inventory action (e.g picking up, dropping, transferring inventories, etc). Note that this is for an item table, not an item entity. This is called after CanPlayerDropItem and CanPlayerTakeItem.

Parameters

  • client Player

    Player attempting interaction

  • action String

    The action being performed

  • item

    Item's instance ID or item table

Returns

  • bool

    Whether or not to allow the player to interact with the item

Example Usage

function MODULE:CanPlayerInteractItem(client, action, item, data)
	return false -- Disallow interacting with any item.
end

MODULE:CanPlayerTakeItem(client, item)

Whether or not a player is allowed to take an item and put it in their inventory.

Parameters

  • client Player

    Player attempting to take the item

  • item Entity

    Entity corresponding to the item

Returns

  • bool

    Whether or not to allow the player to take the item

Example Usage

function MODULE:CanPlayerTakeItem(client, item)
	return !(client:GetMoveType() == MOVETYPE_NOCLIP and !client:InVehicle()) -- Disallow players in observer taking items.
end

MODULE:CanPlayerUnequipItem(client, item)

Whether or not a player can unequip an item.

Parameters

  • client Player

    Player attempting to unequip an item

  • item Table

    Item being unequipped

Returns

  • bool

    Whether or not to allow the player to unequip the item

Example Usage

function MODULE:CanPlayerUnequipItem(client, item)
	return false -- Disallow unequipping items.
end

See Also

MODULE:DatabaseConnected()

Internal

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

Called when the database has been successfully connected.

MODULE:InitializedConfig()

Called when lia.config has been initialized.

MODULE:InitializedModules()

Called when all the modules have been initialized.

MODULE:InitializedSchema()

Called when the schema has been initialized.

MODULE:LoadData()

Loads the server data.

MODULE:LoadFonts(font, genericFont)

Loads custom fonts for the client.

Parameters

  • font String

    The path to the font file.

  • genericFont String

    The path to the generic font file.

MODULE:LoadLiliaFonts(font, genericFont)

Internal

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

Loads Core Lilia fonts for the client.

Parameters

  • font String

    The path to the font file.

  • genericFont String

    The path to the generic font file.

MODULE:ModuleLoaded()

Called when a module has finished loading.

MODULE:OnItemSpawned(entity)

Called whenever an item entity has spawned in the world. You can access the entity's item table with entity:getItemTable().

Parameters

  • entity Entity

    Spawned item entity

Example Usage

function MODULE:OnItemSpawned(entity)
	local item = entity:getItemTable()
	-- do something with the item here
end

MODULE:OnPickupMoney(client, moneyEntity)

Called when a player picks up money. This function is called when a player picks up money from the groun

Parameters

  • client Player

    The player who picked up the money

  • moneyEntity Entity

    The entity representing the money being picked

MODULE:OnWipeTables()

Internal

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

Called after wiping tables.

MODULE:PlayerModelChanged(client, model)

Called when a player's model is changed.

Parameters

  • client Player

    The client whose model is changed.

  • model String

    The new model path.

MODULE:PostLoadData()

Called after data has been loaded.

MODULE:SaveData()

Saves the server data.

MODULE:ScreenResolutionChanged(width, height)

Called when the screen resolution changes.

Parameters

  • width Integer

    number The new width of the screen.

  • height Integer

    number The new height of the screen.

MODULE:SetupDatabase()

Internal

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

Sets up the database.

MODULE:ShouldClientDrown(client)

Determines whether a client should drown.

Parameters

  • client Player

    The player entity.

Returns

  • bool

    True if the client should drown, false otherwise.

MODULE:ShouldDataBeSaved()

Called to determine whether data should be saved before shutting down the server. This function is called to determine whether data should be saved bore the server shuts down.

Returns

  • bool

    True if data should be saved, false otherwise