> For the complete documentation index, see [llms.txt](https://0bugscripts.gitbook.io/0bugscripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0bugscripts.gitbook.io/0bugscripts/infinity-scripts/spawn-selector-v2/configuration.md).

# Configuration

{% hint style="info" %}

#### **Spawn Selector TriggerEvent**&#x20;

{% endhint %}

```lua
-- Default startup
TriggerEvent('0bug_Spawnselector:OpenUI') 

-- Create Private Locations

event = {
  event = "test:open:menu",
  side = "client" -- "server", "client"
}

TriggerEvent('0bug_Spawnselector:CustomOpenUI', locations, event)

--- @param locations object Create private locations.
--- @param event object Event.
--- @return boolean Status (true: success, false: error).

-- First Join / Apartments Startup 
TriggerEvent('0bug_Spawnselector:OpenUI', identifier, new) 

--- @param identifier string Character identifier/citizenid.
--- @param new boolean New character.
--- @return boolean Status (true: success, false: error).
```

#### **General Settings**&#x20;

* **LastLocation**: Enables respawn at the player's last location. (<mark style="color:green;">`true`</mark><mark style="color:blue;">/</mark><mark style="color:red;">`false`</mark>)
* **SpawnHouses**: Enables house-based spawn points (Owned houses) .(<mark style="color:green;">`true`</mark><mark style="color:blue;">/</mark><mark style="color:red;">`false`</mark><mark style="color:blue;">)</mark>
* **Jobs**: Enables job-specific spawn points. (<mark style="color:green;">`true`</mark><mark style="color:blue;">/</mark><mark style="color:red;">`false`</mark><mark style="color:blue;">)</mark>
* **PublicLocations**: Enables general public spawn locations. (<mark style="color:green;">`true`</mark><mark style="color:blue;">/</mark><mark style="color:red;">`false`</mark><mark style="color:blue;">)</mark>
* **SmoothCamTime**: Sets the smooth camera transition time in milliseconds.

#### **Apartment Settings**

* **Apartments**: Enables apartment-based spawn points. (<mark style="color:green;">`true`</mark><mark style="color:blue;">/</mark><mark style="color:red;">`false`</mark><mark style="color:blue;">)</mark>
* **ApartmentScriptName**: The name of your apartment script. Default is <mark style="color:blue;">"qb-apartments"</mark>.
* **ApartmentsLocations**: Auto-filled by the apartment script.

**Custom Apartment Locations**

* **GetApartments**: A function to define custom apartment locations. Example usage:

```lua
GetApartments = function()
   --[[
    WIZF.AddLocation({
      type = "home",
      name = "Apartment",
      adress = "",
      coords = vector3(x, y, z),
      target = "apartment"
    })
  ]]
  end,
```

#### **House Settings**

* **`HousesLocations`**: Auto-filled by the house script.
* **`SQL_SELECT_HOUSES_LOCATION`**: Database query configuration for fetching house locations:
  * `table`: The database table name (default: `"player_houses"`).
  * `identifierColonName`: Column for player identification (default: `"citizenid"`).
  * `selectColon`: Column for the house identifier (default: `"house"`).

**Custom House Logic**

* **`GetOwnedHouses`**: Fetches owned houses and adds them to the spawn selector. Example:

  ```lua
  GetOwnedHouses = function()
      Callback("GetOwnedHouses", function(data)
        if data ~= nil then
          WIZF.AddLocation({
            type = "home",
            name = Locales[Config.Lang].myHome,
            adress = Locales[Config.Lang].myHomeAdress,
            coords = Config.Houses[data] ~= nil and Config.Houses[data].coords.enter,
            target = "house",
            data = data
          })
        end
      end)
    end,
  ```

#### **Player Spawn Function**

```lua
SpawnPlayer = function()
    DoScreenFadeIn(200)
    -- ESX
    TriggerServerEvent('esx:onPlayerSpawn')
    TriggerEvent('esx:onPlayerSpawn')
    TriggerEvent('playerSpawned')

    -- QBCORE
    TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
    TriggerEvent('QBCore:Client:OnPlayerLoaded')
  end,
```

**Adding Location Example**&#x20;

```lua
{
  name = "Police Department",
  address = "Police Station",
  type = "job",
  coords = vector4(428.23, -984.28, 29.76, 3.5),
  job = "police"
}
```

**Translations**&#x20;

```lua
Locales["en"] = {
  frontTitle = "SPAWN",
  backTitle = "SELECTOR",
  spawnText = "SPAWN",
  lastLocationName = "Last Location",
  lastLocationAdress = "",
  myHome = "My Home",
  myHomeAdress = "Comfort in every corner"
}
```

## Framework Configuration Guide

If you're using a different framework path/name (e.g., np-core instead of qb-core), you'll need to modify the <mark style="color:blue;">threads.lua</mark> file in <mark style="color:green;">0bug-core</mark>:

1. Open <mark style="color:orange;">0bug-core/threads.lua</mark>
2. Locate the <mark style="color:red;">GetFramework()</mark> function
3. Modify the export paths according to your framework:

```lua
function GetFramework()
    local Get = nil
    
    -- For ESX with custom path
    if WIZ_CONFIG.Framework == "ESX" then
        Get = exports['your-es-extended-path']:getSharedObject()
        if Get == nil then
            while Get == nil do
                TriggerEvent('esx:getSharedObject', function(Set) Get = Set end)
                Citizen.Wait(200)
            end
        end
    end
    
    -- For QBCore with custom path (e.g., bl-core)
    if WIZ_CONFIG.Framework == "QBCore" then
        Get = exports["your-qb-path"]:GetCoreObject()  -- Example: exports["bl-core"]:GetCoreObject()
        if Get == nil then
            while Get == nil do
                TriggerEvent('QBCore:GetObject', function(Set) Get = Set end)
                Citizen.Wait(200)
            end
        end
    end
    
    -- For QBox with custom path 
     if WIZ_CONFIG.Framework == "QBox" then
        Get = exports['your-qbox-path']:GetCoreObject()
        if Get == nil then
            while Get == nil do
                Get = exports['qb-core']:GetCoreObject()
                Citizen.Wait(200)
            end
        end
    end
    
    return Get
end
```
