Handle Buy House Event

The housing:handleBuyHouse event is designed to trigger when a player purchases a house in the Housing system. This event allows developers to listen to the transaction and implement custom logic such as logging, external integrations, or additional processes.


Event syntax

AddEventHandler('housing:handleBuyHouse', function(playerSrc, house, housePrice, isCredit)
    -- Your custom logic here
end)

Parameters Explained

  1. playerSrc: The server ID of the player who is purchasing the house.

  2. house: The unique identifier of the house being purchased.

  3. housePrice: The price of the house.

  4. isCredit: A boolean value indicating if the house is being purchased with credit (true) or with direct payment (false).


Example use case

Log the details of the house purchase to the console or a file for administrative purposes.

AddEventHandler('housing:handleBuyHouse', function(playerSrc, house, housePrice, isCredit)
    print(("[Housing] Player %d purchased house %s for $%d. Payment method: %s"):format(
        playerSrc, house, housePrice, isCredit and "Credit" or "Cash"
    ))
end)

Last updated

Was this helpful?