# config.client.lua

{% code fullWidth="true" %}

```lua
onPlayerSpawned = function(isFirstSpawn)
    if isFirstSpawn then
        -- exports['vms_guidebook']:openBook("default")
    else
        
    end
end

RegisterNetEvent("vms_spawnselector:WeatherSync")
AddEventHandler("vms_spawnselector:WeatherSync", function(boolean)
    if boolean then
        Wait(150)
        if Config.WeatherSync == 'cd_easytime' then
            TriggerEvent('cd_easytime:PauseSync', true)
        elseif Config.WeatherSync == 'qb-weathersync' then
            TriggerEvent('qb-weathersync:client:DisableSync')
        elseif Config.WeatherSync == 'vSync' then
            TriggerEvent('vSync:toggle', false)
            Wait(100)
            TriggerEvent('vSync:updateWeather', Config.Weather, false)
        end
        Wait(50)
        NetworkOverrideClockTime(Config.Time.hour, Config.Time.minutes, 0)
        ClearOverrideWeather()
        ClearWeatherTypePersist()
        SetWeatherTypePersist(Config.Weather)
        SetWeatherTypeNow(Config.Weather)
        SetWeatherTypeNowPersist(Config.Weather)
    else
        Wait(150)
        if Config.WeatherSync == 'cd_easytime' then
            TriggerEvent('cd_easytime:PauseSync', false)
        elseif Config.WeatherSync == 'qb-weathersync' then
            TriggerEvent('qb-weathersync:client:EnableSync')
        elseif Config.WeatherSync == 'vSync' then
            TriggerEvent('vSync:toggle', true)
            Wait(100)
            TriggerServerEvent('vSync:requestSync')
        end
    end
end)

RegisterNetEvent('vms_spawnselector:openLoaded')
AddEventHandler('vms_spawnselector:openLoaded', function(isFirstSpawn, allHouses, myHouses)
    spawnsList = {}
    local housesList = allHouses
    local myHousesList = myHouses
    if housesList and myHousesList then
        if GetResourceState('vms_housing') == 'started' then
            local function GetCameraForSpawn(coords)
                if coords.w then
                    return {
                        pos = vec3(
                            coords.x - math.sin(math.rad(coords.w)) * 3.0,
                            coords.y + math.cos(math.rad(coords.w)) * 3.0,
                            coords.z + 0.8
                        ),
                        lookAt = vec3(coords.x, coords.y, coords.z + 0.8)
                    }
                else
                    return {
                        pos = vec3(coords.x - 2.5, coords.y, coords.z + 1.4),
                        lookAt = vec3(coords.x, coords.y, coords.z + 1.0)
                    }
                end
            end

            for k, v in pairs(myHousesList) do
                local coords = GetCameraForSpawn(v.coords)
                spawnsList[#spawnsList+1] = {
                    camCoords = coords.pos,
                    spawnCoords = coords.lookAt,
                    label = v.label,
                    address = v.address
                }
            end
        elseif GetResourceState('esx_property') == 'started' then
            if myHousesList[1] then
                for k, v in pairs(myHousesList) do
                    spawnsList[#spawnsList+1] = {
                        camCoords = vec(v.coords.x-20.0, v.coords.y+20.0, v.coords.z + 30.0),
                        spawnCoords = vec(v.coords.x, v.coords.y, v.coords.z),
                        label = Config.Translate['house_label'],
                        address = v.label
                    }
                end
            end
        elseif GetResourceState('qs-housing') == 'started' or GetResourceState('qb-houses') == 'started' then
            for k, v in pairs(myHousesList) do
                if housesList[v.house] then
                    spawnsList[#spawnsList+1] = {
                        camCoords = vec(housesList[v.house].coords.x-20.0, housesList[v.house].coords.y+20.0, housesList[v.house].coords.z + 30.0),
                        spawnCoords = housesList[v.house].coords,
                        label = Config.Translate['house_label'],
                        address = housesList[v.house].label
                    }
                end
            end
        elseif GetResourceState('ps-housing') == 'started' then
            for k, v in pairs(myHousesList) do
                local coords = json.decode(v.door_data)
                if coords and coords.x then
                    spawnsList[#spawnsList+1] = {
                        camCoords = vec(coords.x-20.0, coords.y+20.0, coords.z + 30.0),
                        spawnCoords = vec(coords.x, coords.y, coords.z),
                        label = Config.Translate['house_label'],
                        address = v.street
                    }
                end
            end
        elseif GetResourceState('bcs_housing') == 'started' then
            for k, v in pairs(myHousesList) do
                spawnsList[#spawnsList+1] = {
                    camCoords = vec(v.entry.x - 20.0, v.entry.y + 20.0, v.entry.z + 30.0),
                    spawnCoords = vec(v.entry.x, v.entry.y, v.entry.z),
                    label = Config.Translate['house_label'],
                    address = v.name
                }
            end
        end
    end

    local PlayerData = Config.Core == "ESX" and ESX.GetPlayerData() or Config.Core == "QB-Core" and QBCore.Functions.GetPlayerData()
    if PlayerData.job and PlayerData.job.name then
        if Config.OnlyJobsSpawns[PlayerData.job.name] then
            for k, v in pairs(Config.OnlyJobsSpawns[PlayerData.job.name]) do
                spawnsList[#spawnsList+1] = {
                    camCoords = v.camCoords,
                    spawnCoords = v.spawnCoords,
                    label = v.label,
                    address = v.address
                }
            end
        end
    end

    for k, v in pairs(Config.Spawns) do
        spawnsList[#spawnsList+1] = {
            camCoords = v.camCoords,
            spawnCoords = v.spawnCoords,
            label = v.label,
            address = v.address
        }
    end

    OpenSpawnSelector(isFirstSpawn)
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.vames-store.com/assets/vms_spawnselector/configuration-files/config.client.lua.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.
