# buyProperty

## Description

Triggered when a player attempts to purchase a property.

## Payload Structure

```lua
{
    source = playerId,      -- The player's server ID
    player = playerData,    -- Player data object from framework
    propertyId = propertyId,-- Property identifier
    buyAs = buyAs          -- Purchase type (e.g., 'society', 'user')
}
```

## Parameters

* **source** (number): The server ID of the player attempting the purchase
* **player** (table): Complete player data object provided by the framework (ESX/QBCore)
* **propertyId** (string/number): Unique identifier for the property being purchased
* **buyAs** (string): The purchase context - typically 'player' for personal purchase or 'gang' for organization purchase

## Usage Example

```lua
exports.nolag_properties:registerHook('buyProperty', function(data)
    print(('Player %s is buying property %s as %s'):format(data.source, data.propertyId, data.buyAs))
    
    -- Custom validation logic
    if not canPlayerBuyProperty(data.source, data.propertyId) then
        return false -- Cancel the purchase
    end
    
    -- Log the purchase attempt
    logPropertyTransaction('buy', data)
    
    return true -- Allow the purchase to proceed
end)
```

## Return Values

* **true** or **nil**: Allow the property purchase to continue
* **false**: Cancel the property purchase and prevent the transaction
