> For the complete documentation index, see [llms.txt](https://savana.gitbook.io/savanascripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://savana.gitbook.io/savanascripts/scripts/garage/editable-files.md).

# Editable Files

{% tabs %}
{% tab title="clienteditable.lua" %}

```lua
function setFuelFunc(veh, gas)
    Entity(veh).state.fuel = gas
end

function getFuelFunc(veh)
    return 100
end

function giveKeyFunc(veh)
    if Config.Framework == 'newqb' or Config.Framework == 'oldqb' then
        TriggerEvent('vehiclekeys:client:SetOwner', Core.Functions.GetPlate(veh))
    else

    end
end

function GetAvatar()
    -- you can edit here
    return 'https://media.discordapp.net/attachments/1038901575139205150/1151212693580169287/Comp_1.gif?width=676&height=676'
end

function createBlips()
    if pedSpawned then return end
    for garaj in pairs(Config.Garages) do
        if Config.Garages[garaj]["showBlip"] then
            local GarageBlip = AddBlipForCoord(Config.Garages[garaj]["pedCoord"].x, Config.Garages[garaj]["pedCoord"].y, Config.Garages[garaj]["pedCoord"].z)
            SetBlipSprite(GarageBlip, Config.Garages[garaj]["blipNumber"])
            SetBlipScale(GarageBlip, Config.Garages[garaj]["blipscale"])
            SetBlipDisplay(GarageBlip, 4)
            SetBlipColour(GarageBlip, Config.Garages[garaj]["blipColor"])
            SetBlipAsShortRange(GarageBlip, true)
            BeginTextCommandSetBlipName("STRING")
            AddTextComponentSubstringPlayerName(Config.Garages[garaj]["blipName"])
            EndTextCommandSetBlipName(GarageBlip)
        end
    end
end

function notify(text, tip)
    if Config.Framework == 'newesx' or Config.Framework == 'oldesx' then
        Core.ShowNotification(text, true) -- newesx, oldesx
    elseif Config.Framework == 'newqb' or Config.Framework == 'oldqb' then
        Core.Functions.Notify(text, tip)  -- newqb, oldqb
    else
        --your notif 
    end
end

function createPeds()
    if pedSpawned then return end

    for k, v in pairs(Config.Garages) do
        if Config.UseTarget == true then
        local current = type(v["ped"]) == "number" and v["ped"] or joaat(v["ped"])

        RequestModel(current)
        while not HasModelLoaded(current) do
            Wait(0)
        end

        GaragePed[k] = CreatePed(0, current, v["pedCoord"].x, v["pedCoord"].y, v["pedCoord"].z-1, v["pedCoord"].w, false, false)
        TaskStartScenarioInPlace(GaragePed[k], v["scenario"], 0, true)
        FreezeEntityPosition(GaragePed[k], true)
        SetEntityInvincible(GaragePed[k], true)
        SetBlockingOfNonTemporaryEvents(GaragePed[k], true)
        if GetResourceState('ox_target') == 'started' then
                local options = {
                    {
                        label = v["targetLabel"],
                        icon = v["targetIcon"],
                        onSelect = function()
                            garagetip = v['type']
                            garageindex = k
                            openGarage()
                        end,
                        canInteract = function(entity)
                            return not IsPedInAnyVehicle(PlayerPedId(), false)
                        end,
                    },
                    {
                        label = v["cartakeinCoordLabel"],
                        icon = v["cartakeinCoordIcon"],
                        onSelect = function()
                            takeinGarage()
                        end,
                        canInteract = function(entity)
                            garagetip = v['type']
                            garageindex = k
                            return IsPedInAnyVehicle(PlayerPedId(), false) and garagetip ~= 'depot'
                        end,
                    }
                }
                exports.ox_target:addSphereZone({
                    coords = GetEntityCoords(GaragePed[k]),
                    radius = 0.35,
                    options = options,
                    debug = false,
                })

        elseif GetResourceState('qb-target') == 'started' then    
            exports['qb-target']:AddTargetEntity(GaragePed[k], {
                    options = {
                        {
                            label = v["targetLabel"],
                            icon = v["targetIcon"],
                            action = function()
                                garagetip = v['type']
                                garageindex = k
                                openGarage()
                            end,
                            canInteract = function(entity)
                                return not IsPedInAnyVehicle(PlayerPedId(), false)
                            end,
                        },
                        {
                            label = v["cartakeinCoordLabel"],
                            icon = v["cartakeinCoordIcon"],
                            action = function()
                                takeinGarage()
                            end,
                            canInteract = function(entity)
                                garagetip = v['type']
                                garageindex = k
                                return IsPedInAnyVehicle(PlayerPedId(), false) and garagetip ~= 'depot'
                            end,
                        }
                    },
                    distance = v["radius"]
                })
        end
        else
            while true do
                local time = 500
                local playerPed = PlayerPedId()
                local playerCoords = GetEntityCoords(playerPed)
                for k,v in pairs(Config.Garages) do
                    if #(playerCoords - vector3(v["pedCoord"].x, v["pedCoord"].y, v["pedCoord"].z)) < 10 then
                        garageindex = k
                        garagetip =  Config.Garages[garageindex]['type']
                    end
                end

                if garageindex ~= nil or garagetip ~= nil then
                    local distance = #(playerCoords - vector3(Config.Garages[garageindex]['pedCoord'].x, Config.Garages[garageindex]['pedCoord'].y, Config.Garages[garageindex]['pedCoord'].z))
                    local distance2 = #(playerCoords - vector3(Config.Garages[garageindex]['cartakeinCoord'].x, Config.Garages[garageindex]['cartakeinCoord'].y, Config.Garages[garageindex]['cartakeinCoord'].z))
                    if not display then
                        if distance < 5 then
                            if not IsPedInAnyVehicle(PlayerPedId(), false) then
                                time = 1
                                DrawMarker(2, Config.Garages[garageindex]['pedCoord'].x, Config.Garages[garageindex]['pedCoord'].y, Config.Garages[garageindex]['pedCoord'].z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.2, 0.15, 255, 51, 51, 255, false, false, false, true, false, false, false)
                                DrawText3D(Config.Garages[garageindex]['pedCoord'].x, Config.Garages[garageindex]['pedCoord'].y, Config.Garages[garageindex]['pedCoord'].z+0.2, 'E - '..Config.Garages[garageindex]["targetLabel"], 0.6)
                                if IsControlJustReleased(0, 38) then
                                    openGarage()
                                end
                            end
                        end
                        if distance2 < 5 then
                            if IsPedInAnyVehicle(PlayerPedId(), false) then
                                time = 1
                                if garagetip ~= 'depot' then
                                    DrawMarker(2, Config.Garages[garageindex]['cartakeinCoord'].x, Config.Garages[garageindex]['cartakeinCoord'].y, Config.Garages[garageindex]['cartakeinCoord'].z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.2, 0.15, 255, 255, 255, 255, false, false, false, true, false, false, false)
                                    DrawText3D(Config.Garages[garageindex]['cartakeinCoord'].x, Config.Garages[garageindex]['cartakeinCoord'].y, Config.Garages[garageindex]['cartakeinCoord'].z+0.2, 'E - Store The Car', 0.6)
                                    if distance2 < 3 then
                                        if IsControlJustReleased(0, 38) then
                                            takeinGarage()
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                Wait(time)
            end
        end
    end

    pedSpawned = true
end
```

{% endtab %}

{% tab title="GetFrameworkObject.lua" %}

```lua
function GetCore()
    local object = nil
    local Framework = Config.Framework

    if Config.Framework == "oldesx" then
        local counter = 0
        while not object  do
            TriggerEvent('esx:getSharedObject', function(obj) object = obj end)
            counter = counter + 1
            if counter == 3 then
                break
            end
            Citizen.Wait(1000)
        end
        if not object then
            print("savana-garage:Framework is not selected in the config correctly if you're sure it's correct please check your events to get framework object")
        end
    end
    
    if Config.Framework == "newesx" then
        local counter = 0
        local status = pcall(function ()
            exports['es_extended']:getSharedObject()
        end)
        if status then        
            while not object do
                object = exports['es_extended']:getSharedObject()
                counter = counter + 1
                if counter == 3 then
                    break
                end
                Citizen.Wait(1000)
            end
        end
        if not object then
            print("savana-garage:Framework is not selected in the config correctly if you're sure it's correct please check your events to get framework object")
        end
    end

    if Config.Framework == "newqb" then
        local counter = 0
        local status = pcall(function ()
            exports["qb-core"]:GetCoreObject()
        end)
        if status then
            while not object  do
                object = exports["qb-core"]:GetCoreObject()
                counter = counter + 1
                if counter == 3 then
                    break
                end
                Citizen.Wait(1000)
            end
        end
        if not object then
            print("savana-garage:Framework is not selected in the config correctly if you're sure it's correct please check your events to get framework object")
        end
    end

    if Config.Framework == "oldqb" then
        local counter = 0

        while  not object do
            counter = counter + 1
            TriggerEvent('QBCore:GetObject', function(obj) object = obj end)
            if counter == 3 then
                break
            end
            Citizen.Wait(1000)
        end
        if not object then
            print("savana-garage:Framework is not selected in the config correctly if you're sure it's correct please check your events to get framework object")
        end
    end

    if Config.Framework == 'autodetect' then
        local counter = 0
        local breakLoop = false
        Citizen.CreateThread(function()
            while not object do
                counter = counter + 1
                if counter == 3 then
                    breakLoop = true
                    counter = 0
                end
                Citizen.Wait(700)
            end
        end)


        while not object do
            local status = pcall(function ()
                object = exports['es_extended']:getSharedObject()
            end)
            Citizen.Wait(1000)
            break
        end

        if object and Framework == 'autodetect' then
            Framework = 'newesx'
        end

        while not object do
            TriggerEvent('esx:getSharedObject', function(obj) object = obj end)
            if breakLoop then
                break
            end
            Citizen.Wait(1000)
        end

        if object and Framework == 'autodetect' then
            Framework = 'oldesx'
        end

        while not object do
            local status = pcall(function ()
                object = exports["qb-core"]:GetCoreObject()
            end)
            Citizen.Wait(1000)
            break
        end

        if object and Framework == 'autodetect' then
            Framework = 'newqb'
        end

        while not object do
            TriggerEvent('QBCore:GetObject', function(obj) object = obj end)
            if breakLoop then
                break
            end
            Citizen.Wait(1000)
        end

        if object and Framework == 'autodetect' then
            Framework = 'oldqb'
        end

        if not object then
            print("savana-garage:Framework object couldn't find. Setting chat to standalone")
            Framework = 'standalone'
        else
            print("savana-garage:Framework object found : ", Framework)
        end
    end

    return object, Framework
end
```

{% endtab %}
{% endtabs %}


---

# 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:

```
GET https://savana.gitbook.io/savanascripts/scripts/garage/editable-files.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.
