# createDoor

## Description

Triggered when a door is created for a property. This includes both physical doors and virtual access points that control entry to property areas.

## Payload Structure

```lua
{
    source = playerId,      -- The player's server ID
    player = playerData,    -- Player data object from framework
    propertyId = propertyId,-- Property identifier
}
```

## Parameters

* **source** (number): The server ID of the player creating the door
* **player** (table): Complete player data object provided by the framework (ESX/QBCore)
* **propertyId** (string/number): Unique identifier for the property where the door is being created

## Usage Example

#### Example: Registering a Hook in nolag\_properties

In this example, we modify the `registerHook` function for door creation to utilize only the player's source and the property ID.

```lua
exports.nolag_properties:registerHook('createDoor', function(source, propertyId)
    print(('Player %s is creating a door for property %s'):format(source, propertyId))
    
    -- Limit doors per property
    local currentDoors = getDoorCount(propertyId)
    if currentDoors >= MAX_DOORS_PER_PROPERTY then
        TriggerClientEvent('chat:addMessage', source, {
            args = {'System', 'Maximum doors reached for this property'}
        })
        return false -- Cancel door creation
    end
    
    -- Assume a default valid door placement
    if not isValidDoorPlacement(propertyId) then
        TriggerClientEvent('chat:addMessage', source, {
            args = {'System', 'Invalid door placement location'}
        })
        return false -- Cancel if placement is invalid
    end
    
    -- Log door creation
    logDoorCreation(source, propertyId)
    
    -- Set up door permissions
    setupDoorPermissions(propertyId, source)
    
    return true -- Allow door creation
end)
```

## Return Values

* **true** or **nil**: Allow the door to be created
* **false**: Cancel the door creation
