> For the complete documentation index, see [llms.txt](https://xcore.gitbook.io/xcore-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xcore.gitbook.io/xcore-docs/vehicleshop/client.config-file.md).

# CLIENT.CONFIG FILE

<pre class="language-lua"><code class="lang-lua"><strong>-- Spawns a vehicle (customize as needed)
</strong>local function pdm_vehicle_spawn(vehicle)
    -- Called when a vehicle is spawned. Add your custom logic here.
    -- print("VEHICLE:" .. vehicle)
end

-- Spawns a test vehicle and sets fuel and keys according to config
local function pdm_test_vehicle_spawn(vehicle)
    -- Set fuel level based on selected fuel system
    if config.settings.fuel == 'ox_fuel' then
        Entity(vehicle).state.fuel = 100.0 -- OX Fuel system
    elseif config.settings.fuel == 'legacy_fuel' then
        exports["LegacyFuel"]:SetFuel(vehicle, 100) -- LegacyFuel system
    elseif config.settings.fuel == 'ti_fuel' then
        exports["ti_fuel"]:setFuel(vehicle,100.0) -- TI Fuel system
    elseif config.settings.fuel == 'x-fuel' then
        exports['x-fuel']:SetFuel(vehicle, 100.0) -- X-Fuel system
    elseif config.settings.fuel == 'custom' then
        -- Add your custom fuel system logic here
    end

    local plate = GetVehicleNumberPlateText(vehicle) -- Get vehicle plate

    -- Give vehicle keys based on selected key system
    if config.settings.vehiclekey == 'wasabi' then
        exports.wasabi_carlock:GiveKey(GetVehicleNumberPlateText(vehicle)) -- Wasabi carlock
    elseif config.settings.vehiclekey == 'okok' then
        TriggerServerEvent("okokGarage:GiveKeys", plate) -- okokGarage
    --elseif config.settings.vehiclekey == 'jg' then
    --    Waiting for release
    elseif config.settings.vehiclekey == 'custom' then
        -- exports.mm_carkeys:GiveKeyItem(plate, vehicle)
        -- Add your custom key system logic here
        TriggerServerEvent('xcore_vehiclekeys:givecarkeys', plate, vehicle, NetworkGetNetworkIdFromEntity(vehicle))
    end
end

-- Removes keys for a spawned vehicle
local function pdm_delete_spawned_vehicle(vehicle)
    -- Remove vehicle keys based on selected key system
    if config.settings.vehiclekey == 'wasabi' then
        exports.wasabi_carlock:RemoveKey(GetVehicleNumberPlateText(vehicle)) -- Wasabi carlock
    elseif config.settings.vehiclekey == 'okok' then
        TriggerServerEvent("okokGarage:RemoveKeys", plate, source) -- okokGarage
    --elseif config.settings.vehiclekey == 'jg' then
    --    Wait for release
    elseif config.settings.vehiclekey == "custom" then
        TriggerServerEvent('xcore_vehiclekeys:removecarkeys', GetVehicleNumberPlateText(vehicle), vehicle, NetworkGetNetworkIdFromEntity(vehicle)) -- Custom key system
    end
end

-- Handles logic after buying a spawned car (sets fuel and gives keys)
local function pdm_spawned_buy_car(vehicle)
    -- Set fuel level based on selected fuel system
    if config.settings.fuel == 'ox_fuel' then
        Entity(vehicle).state.fuel = 100.0 -- OX Fuel system
    elseif config.settings.fuel == 'legacy_fuel' then
        exports["LegacyFuel"]:SetFuel(vehicle, 100) -- LegacyFuel system
    elseif config.settings.fuel == 'ti_fuel' then
        exports["ti_fuel"]:setFuel(vehicle,100.0) -- TI Fuel system
    elseif config.settings.fuel == 'x-fuel' then
        exports['x-fuel']:SetFuel(vehicle, 100.0) -- X-Fuel system
    elseif config.settings.fuel == 'custom' then
        -- Add your custom fuel system logic here
    end

    local plate = GetVehicleNumberPlateText(vehicle) -- Get vehicle plate
    
    -- Give vehicle keys based on selected key system
    if config.settings.vehiclekey == 'wasabi' then
        exports.wasabi_carlock:GiveKey(plate) -- Wasabi carlock
    elseif config.settings.vehiclekey == 'okok' then
        TriggerServerEvent("okokGarage:GiveKeys", plate) -- okokGarage
    --elseif config.settings.vehiclekey == 'jg' then
    --    Waiting for release
    elseif config.settings.vehiclekey == 'custom' then
        -- exports.mm_carkeys:GiveKeyItem(plate, vehicle)
        TriggerServerEvent('xcore_vehiclekeys:givecarkeys', NetworkGetNetworkIdFromEntity(vehicle)) -- Custom key system
    end
end

-- Sends a notification to the player using the selected notification system
local function sendNotify(data)
    -- data: {title, description, position, iconAnimation, type, duration}
    if config.settings.notify == 'ox_lib' then
        lib.notify({
            title = data.title, -- Notification title
            description = data.description, -- Notification description
            position = data.position, -- Notification position
            iconAnimation = data.iconAnimation, -- Icon animation
            type = data.type, -- Notification type (success, error, etc.)
            duration = data.duration, -- Duration in ms
        })
    elseif config.settings.notify == 'okok' then
        exports['okokNotify']:Alert(data.title, data.description, data.duration, data.type, true) -- okokNotify
    elseif config.settings.notify == 'qs' then
        exports['qs-notify']:Alert(data.description, data.duration, data.type) -- qs-notify
    elseif config.settings.notify == 'esx' then
        ESX.ShowNotification(data.description) -- ESX notification
    elseif config.settings.notify == 'custom' then
        -- Add your custom notification logic here
    end
end

-- Export functions for use elsewhere in the resource
return {
    pdm_vehicle_spawn = pdm_vehicle_spawn, -- Vehicle spawn handler
    pdm_test_vehicle_spawn = pdm_test_vehicle_spawn, -- Test vehicle spawn handler
    sendNotify = sendNotify, -- Notification handler
    pdm_spawned_buy_car = pdm_spawned_buy_car, -- Buy car handler
    pdm_delete_spawned_vehicle = pdm_delete_spawned_vehicle, -- Delete vehicle handler
}

</code></pre>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://xcore.gitbook.io/xcore-docs/vehicleshop/client.config-file.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
