Hooks

Event hooks let third-party resources add new behavior to the housing system without modifying its core code, ensuring flexibility and maintainability. They are for server-side use only.

RegisterHook


exports.origen_housing:registerHook(eventName, function(payload)
end, options)
  • eventName: string

  • payload: table

  • options?: table

    • print?: boolean

      • Print to the console when triggering the event.

    • ownerFilter?: { [string]: true }

      • The event will only trigger for owners defined as keys in a set.

    • houseFilter?: { [number]: true }

      • The event will only trigger for houses defined as keys in a set.

    • zoneFilter?: { [string]: true }

      • The event will only trigger for zone defined as keys in a set.

    • propFilter?: { [string]: true }

      • The event will only trigger for props defined as keys in a set.

    • userFilter?: { [string]: true }

      • The event will only trigger for identifiers defined as keys in a set.

Return:

  • hookId: number

RemoveHooks


exports.origen_housing:removeHooks(id)

id?: number

Hooks events


BuyHouse

This event is triggered when a house is purchased or the setHouseOwner export is used. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • count: number: Number of player's houses

    • payMethod: string

    • price: number

    • isSetOwner: boolean

Example:

local hookId = exports.origen_housing:registerHook('buyHouse', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    houseFilter = { [101] = true, [202] = true },
})

AddHolder

This event is executed when an attempt is made to add a keyholder to the house. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • identifier: string

    • payMethod: string

    • name: string

    • isSetOwner: boolean

    • owner: string

Example:

local hookId = exports.origen_housing:registerHook('addHolder', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    userFilter = { ['identifier1'] = true, ['identifier2'] = true },
    ownerFilter = { ['ownerIdentifier'] = true },
    houseFilter = { [101] = true, [202] = true },
})

RemoveHolder

This event is executed when an attempt is made to remove a keyholder from the house. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • owner: string

    • identifier: string

Example:

local hookId = exports.origen_housing:registerHook('removeHolder', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    userFilter = { ['identifier1'] = true, ['identifier2'] = true },
    ownerFilter = { ['ownerIdentifier'] = true },
    houseFilter = { [101] = true, [202] = true },
})

CreateDoor

This hook is triggered when an attempt is made to create a new door in a house. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • name: string

    • type: string

    • owner: string

    • identifier: string

Example:

local hookId = exports.origen_housing:registerHook('createDoor', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    userFilter = { ['identifier1'] = true, ['identifier2'] = true },
    houseFilter = { [101] = true, [202] = true },
})

DeleteDoor

This hook is triggered when an attempt is made to delete a door from a house. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • id: number

    • owner: string

    • identifier: string

Example:

local hookId = exports.origen_housing:registerHook('deleteDoor', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    userFilter = { ['identifier1'] = true, ['identifier2'] = true },
    houseFilter = { [101] = true, [202] = true },
})

OpenDoor

This hook is triggered when an attempt is made to open a door in a house. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • id: number

    • owner: string

    • identifier: string

Example:

local hookId = exports.origen_housing:registerHook('openDoor', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    userFilter = { ['identifier1'] = true, ['identifier2'] = true },
    houseFilter = { [101] = true, [202] = true },
})

UpdateLight

This hook is triggered when an attempt is made to update a house's lighting. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • propId: string

    • zone: string

    • owner: string

    • propModel: string

    • identifier: string

Example:

local hookId = exports.origen_housing:registerHook('updateLight', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    zoneFilter = { ['exterior'] = true },
    propFilter = { ['lamp_model'] = true },
})

UpdateBoard

This hook is triggered when an attempt is made to update a board within the house. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • propId: string

    • url: string

    • zone: string

    • owner: string

    • propModel: string

    • identifier: string

Example:

local hookId = exports.origen_housing:registerHook('updateBoard', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    zoneFilter = { ['interior'] = true, ['exterior'] = true },
    propFilter = { ['board_model'] = true },
})

BuyFurniture

This hook is triggered when an attempt is made to purchase furniture for a house. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • propId: string

    • zone: string

    • owner: string

    • propModel: string

    • price: number

    • identifier: string

Example:

local hookId = exports.origen_housing:registerHook('buyFurniture', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    ownerFilter = { ['owner123'] = true },
    propFilter = { ['sofa_model'] = true, ['table_model'] = true },
})

UpdateFurniture

This hook is triggered when an attempt is made to update existing furniture in a house. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • propId: string

    • zone: string

    • owner: string

    • propModel: string

    • identifier: string

Example:

local hookId = exports.origen_housing:registerHook('updateFurniture', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    houseFilter = { [505] = true, [606] = true },
    propFilter = { ['bed_model'] = true },
})

DeleteFurniture

This hook is triggered when an attempt is made to remove furniture from a house. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • propId: string

    • zone: string

    • owner: string

    • propModel: string

    • price: number

    • identifier: string

Example:

local hookId = exports.origen_housing:registerHook('deleteFurniture', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    ownerFilter = { ['owner456'] = true },
    zoneFilter = { ['interior'] = true },
    propFilter = { ['chair_model'] = true },
})

BuyUpgrade

This hook is triggered when an attempt is made to purchase an upgrade for a house. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • upgrade: string

    • zone: string

    • owner: string

    • price: number

    • identifier: string

Example:

local hookId = exports.origen_housing:registerHook('buyUpgrade', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    houseFilter = { [101] = true, [202] = true },
})

BuyHouseUpgrade

This hook is triggered when an attempt is made to purchase a house style upgrade. By returning false, you can cancel the action.

  • payload

    • source: number

    • houseID: number

    • style: string

    • owner: string

    • price: number

    • identifier: string

Example:

local hookId = exports.origen_housing:registerHook('buyHouseUpgrade', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    houseFilter = { [303] = true, [404] = true },
})

Last updated