> 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/hud/editable-files.md).

# Editable Files

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

```lua
k = {}

Server = IsDuplicityVersion()

if Server then
    k.RegisterEvent = function (name, fn)
        RegisterNetEvent(('sHud:%s'):format(name), function (id, ...)
            local src = source
            TriggerClientEvent(('sHud:%s:%s'):format(name, id), src, fn(src, ...))
        end)
    end
else
    local id = GetPlayerServerId(PlayerId())

    k.TriggerServerEvent = function (name, ...)
        local p = promise.new()

		SetTimeout(5000, function()
			p:reject({err="Event not Found!"})
		end)

        local handler = RegisterNetEvent(('sHud:%s:%s'):format(name, id), function (...)
            p:resolve({...})
        end)

        TriggerServerEvent(('sHud:%s'):format(name), id, ...)

        local data = Citizen.Await(p)
        RemoveEventHandler(handler)
        return table.unpack(data)
    end

    function SendReactMessage(action, data)
        SendNUIMessage({
          action = action,
          data = data
        })
    end

    RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
        Wait(2000)
        PlayerData = QBCore.Functions.GetPlayerData()
        init()
    end)
    
    RegisterNetEvent("QBCore:Player:SetPlayerData", function(val)
        PlayerData = val
    end)
    
    RegisterNetEvent('esx:playerLoaded', function()
        init()
    end)
    
    AddEventHandler('onResourceStart', function(resourceName)
        if (GetCurrentResourceName() ~= resourceName) then
          return
        end
        init()
    end)

    k.getFuel = function()
        local vehicle = GetVehiclePedIsIn(PlayerPedId())
        local fuel = config.fuel == "savana-fuel" and exports['savana-fuel']:GetFuel(vehicle) 
            or config.fuel == "ox" and Entity(vehicle).state.fuel 
            or config.fuel == "legacy" and exports['LegacyFuel']:GetFuel(vehicle) 
            or config.fuel == "qbus_fuel" and exports['qbus_fuel']:GetFuel(vehicle) 
            or config.fuel == "x-fuel" and exports['x-fuel']:GetFuel(vehicle)
        
        return fuel
    end

    k.getHealthColor = function(vHealth) 
        if vHealth >= 80 then
            return "green"
        elseif vHealth >= 50 and vHealth < 80 then
            return "yellow"
        elseif vHealth >= 25 and vHealth < 50 then
            return "orange"
        else
            return "red"
        end
    end

    k.notify = function(text, type)
        if config.framework == "qb" then
            QBCore.Functions.Notify(text, type)
        elseif config.framework == "esx" then
            ESX.ShowNotification(text, type)
        else
            SetNotificationTextEntry('STRING')
            AddTextComponentSubstringPlayerName(str)
            DrawNotification(0, 1)
        end
    end

    k.findIndex = function(array, name)
		local id = 1
        if array then
            for k,v in pairs(array) do
                if v.name == name then
                    id = k
                end
            end
        end

		return id
	end

    k.OnVehicle = function(vehicle, plate)
        -- this function callend when player in a car
        -- local VehicleNitrous = exports["qb-tunerchip"]:GetNosLoadedVehs()
        -- local hasNitro = VehicleNitrous[plate]

        -- if hasNitro and hasNitro.level > 0 then
        --     SendReactMessage("updateCarHud", {nos = hasNitro.level})
        -- end
    end

    table_deepclone = function(tbl)
		tbl = table.clone(tbl)
	
		for k, v in pairs(tbl) do
			if type(v) == 'table' then
				tbl[k] = table_deepclone(v)
			end
		end
	
		return tbl
	end

    k.table_deepclone = table_deepclone

    k.GetPlayerMoney = function(type)
        local money = 0
        if config.framework == "esx" then
            local playerData = ESX.GetPlayerData()
            for _, data in pairs(playerData.accounts) do
                if data.name == type then
                    money = data.money
                end
            end
        elseif config.framework == "qb" then
            PlayerData = QBCore.Functions.GetPlayerData()
            while PlayerData == nil do
                PlayerData = QBCore.Functions.GetPlayerData()
                Wait(1000)
            end
            if PlayerData.money ~= nil then
                money = PlayerData.money[type]
            end
        end        
        return money
    end


    k.getVoice = function()
        if GetResourceState('pma-voice') == 'started' then
            local talking = NetworkIsPlayerTalking(PlayerId())
            local range = LocalPlayer.state['proximity']?.distance or 0

            local val = 33
            local color = "#fff"
            
            if range == 1.5 then
                val = 33
            elseif range == 3.0 then
                val = 66
            elseif range == 6.0 then
                val = 100
            end

            if talking then
                local data = GetStatusSettingsItem("mic")
                if data then
                    color = data.colors.primary
                else
                    color ="#ffff50"
                end
            else
                color = "#fff"
            end

            if not display then
                UpdateHud("mic", val, color)
            end
        end
    end

    RegisterNetEvent('hud:client:UpdateNeeds', function(newHunger, newThirst) -- Triggered in qb-core
        if newHunger > 100 then
            newHunger = 100
        end

        if newThirst > 100 then
            newThirst = 100
        end

        hunger = newHunger
        thrist = newThirst
    end)

    AddEventHandler("esx_status:onTick", function(data)
        local _hunger, _thirst
        for i = 1, #data do
            if data[i].name == "thirst" then
                _thirst = math.floor(data[i].percent)
            end
            if data[i].name == "hunger" then
                _hunger = math.floor(data[i].percent)
            end
        end

        hunger = _hunger
        thrist = _thirst
    end)


    RegisterNetEvent('hud:client:UpdateNitrous', function(_, nitroLevel, bool)
        if nitroLevel == nil or nitroLevel <= 2 then
            nitroLevel = 0
        end
        SendReactMessage("updateCarHud", {nos = nitroLevel})
    end)

    CreateThread(function()
        while true do
            SetRadarBigmapEnabled(false, false)
            SetRadarZoom(config.minimapscale)
            Wait(500)
        end
    end)
    
    function map()
        Wait(50)
        local mapType = GetSettingsItem("maptype")
        local defaultAspectRatio = 1920/1080
        local resolutionX, resolutionY = GetActiveScreenResolution()
        local aspectRatio = resolutionX/resolutionY
        local minimapOffset = 0
        if aspectRatio > defaultAspectRatio then
            minimapOffset = ((defaultAspectRatio-aspectRatio)/3.6)-0.008
        end
        if mapType == "square" then
            RequestStreamedTextureDict("squaremap", false)
            if not HasStreamedTextureDictLoaded("squaremap") then
                Wait(150)
            end
            SetMinimapClipType(0)
            AddReplaceTexture("platform:/textures/graphics", "radarmasksm", "squaremap", "radarmasksm")
            AddReplaceTexture("platform:/textures/graphics", "radarmask1g", "squaremap", "radarmasksm")
            SetMinimapComponentPosition("minimap", "L", "B", 0.0 + minimapOffset, -0.047, 0.1638, 0.183)
            SetMinimapComponentPosition("minimap_mask", "L", "B", 0.0 + minimapOffset, 0.0, 0.128, 0.20)
            SetMinimapComponentPosition('minimap_blur', 'L', 'B', -0.012 + minimapOffset, 0.015, 0.262, 0.300)
            SetBlipAlpha(GetNorthRadarBlip(), 0)
            SetMinimapClipType(0)
        elseif mapType == "circle" then
            RequestStreamedTextureDict("circlemap", false)
            if not HasStreamedTextureDictLoaded("circlemap") then
                Wait(150)
            end
            SetMinimapClipType(1)
            AddReplaceTexture("platform:/textures/graphics", "radarmasksm", "circlemap", "radarmasksm")
            AddReplaceTexture("platform:/textures/graphics", "radarmask1g", "circlemap", "radarmasksm")
            SetMinimapComponentPosition("minimap", "L", "B", -0.0100 + minimapOffset, -0.030, 0.180, 0.258)
            SetMinimapComponentPosition("minimap_mask", "L", "B", 0.200 + minimapOffset, 0.0, 0.065, 0.20)
            SetMinimapComponentPosition('minimap_blur', 'L', 'B', 0.00 + minimapOffset, 0.015, 0.252, 0.338)
            SetBlipAlpha(GetNorthRadarBlip(), 0)
            SetMinimapClipType(1)
        end
        DisplayRadar(0)
        SetRadarBigmapEnabled(true, false)
        Wait(0)
        SetRadarBigmapEnabled(false, false)
        if (GetSettingsItem("mapdisplay") and not GetSettingsItem("cinematic")) or GetSettingsItem("alwaysdisplaymap") then
            DisplayRadar(1)
        end
    end

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/hud/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.
