# Housing

> **Why is raining inside my house? OR why is snowing when I enter my property?**
>
> * The issue occurs because the freeze event is not being triggered upon entering the property. To resolve this, the housing script must synchronize its state with the weather system.
>
> **Suggested Solutions**
>
> * **Contact the Developer:** Request the housing script author to implement compatibility using the provided exports.
> * **Manual Integration:** Locate the weather or time function within your housing script’s client-side code and manually trigger the freeze state.

{% hint style="info" %}
This example uses ps-housing as a reference. I cannot provide custom integrations for every housing script on the market, as ensuring compatibility with third-party assets is the responsibility of their respective authors or the server developers.
{% endhint %}

{% code title="ps-housing/server/sv\_property.lua > line 34" lineNumbers="true" %}

```lua
function Property:PlayerEnter(src)
    local _src = tostring(src)
    local isMlo = self.propertyData.shell == 'mlo'
    local isIpl = self.propertyData.apartment and Config.Apartments[self.propertyData.apartment].interior

    self.playersInside[_src] = true

    if not isMlo then
        -- HERE WE TRIGGER THE WEATHER EVENT:
        -- Player weather will be frozen untill we sync it again
        TriggerClientEvent('av_weather:freeze', src, true, 23, 0, 'CLEAR')
        -- TriggerClientEvent('qb-weathersync:client:DisableSync', src)
    end

    TriggerClientEvent('ps-housing:client:enterProperty', src, self.property_id, isMlo, self.propertyData)

    if next(self.playersDoorbell) then
        TriggerClientEvent("ps-housing:client:updateDoorbellPool", src, self.property_id, self.playersDoorbell)
        if self.playersDoorbell[_src] then
            self.playersDoorbell[_src] = nil
        end
    end

    local citizenid = GetCitizenid(src)

    if self:CheckForAccess(citizenid) then
        local Player = QBCore.Functions.GetPlayer(src)
        local insideMeta = Player.PlayerData.metadata["inside"]

        insideMeta.property_id = self.property_id
        Player.Functions.SetMetaData("inside", insideMeta)
    end

    if not isMlo or isIpl then
        local bucket = tonumber(self.property_id) -- because the property_id is a string
        QBCore.Functions.SetPlayerBucket(src, bucket)
    end
end
```

{% endcode %}

{% code title="ps-housing/server/sv\_property.lua > line 70" lineNumbers="true" %}

```lua
function Property:PlayerLeave(src)
    local _src = tostring(src)
    self.playersInside[_src] = nil

--    TriggerClientEvent('qb-weathersync:client:EnableSync', src)
    -- Player weather and time will be synced with server
    TriggerClientEvent('av_weather:freeze', src, false)
    local citizenid = GetCitizenid(src)

    if self:CheckForAccess(citizenid) then
        local Player = QBCore.Functions.GetPlayer(src)
        local insideMeta = Player.PlayerData.metadata["inside"]

        insideMeta.property_id = nil
        Player.Functions.SetMetaData("inside", insideMeta)
    end

    QBCore.Functions.SetPlayerBucket(src, 0)
end
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.av-scripts.com/guides/weather-script/housing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
