# Meters UI

<div data-full-width="true"><figure><img src="https://580445893-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzf2ZAqGbUPk9K8cVFSgd%2Fuploads%2F9C1qcNu6oUS3mIvQY116%2Fqadr_ui-meters.png?alt=media&#x26;token=739685a8-80b1-419a-a888-09aba0dd7d27" alt=""><figcaption></figcaption></figure></div>

You can create 10 meters in same time. All meters run async.

{% embed url="<https://youtu.be/QB-dTLkudRA>" fullWidth="true" %}

## Usable Functions

{% code lineNumbers="true" fullWidth="true" %}

```lua
-- Retrieves meter data from the qadr_ui resource.
-- @return table The meter data.
local meterData = exports["qadr_ui"]:getMeterMain()

-- Clears all meter data.
-- @param meterData The meter data to be cleared.
meterData:clearAllMeter()

-- Adds a meter to the UI container using the provided meter data.
-- You can add up to 10 meters to the container at the same time.
local meter = meterData:addMeterToContainer(uiData)

-- Updates the meter with the given UI data.
-- @param uiData The data to update the meter with.
meter:updateMeter(uiData)

-- Sets a timer for 20 seconds and prints a message when the timer is complete.
-- @param meter The meter object to set the timer on.
-- @param iscomplete A boolean value indicating whether the timer is complete.
meter:SetTimer(second,function(iscomplete)
    if iscomplete then
        print("timer is complete")
    else
        print("fail")
    end
end)

-- Pauses the timer of the meter.
-- @param meter The meter object to pause the timer of.
-- @return nil
meter:timerPause()

-- Resumes the timer of the given meter.
-- @param meter The meter to resume the timer of.
meter:timerResume()

-- Stops the timer of a meter object.
-- @param meter The meter object to stop the timer of.
-- @return nil
meter:timerStop()

-- Retrieves all active meters from the meterData object.
-- @return table A table containing all active meters.
local getallmeters = meterData:getActiveMeters()
for i,v in pairs(getallmeters) do
    -- Retrieves the meter data for the given value 'v' using the 'meterData' object.
    -- The retrieved data is stored in the 'meter' variable.
    local meter = meterData:getMeter(v)
    
    -- Pauses the timer of a meter object.
    -- @param meter The meter object to pause the timer of.
    -- @return nil
    meter:timerPause()
    print(v," paused")
    Wait(5000)
    
    -- Resumes the timer of the given meter.
    -- @param meter The meter to resume the timer of.
    meter:timerResume()
    print(v," resumed")
end
```

{% endcode %}

## Example

{% code lineNumbers="true" fullWidth="true" %}

```lua
RegisterCommand("createMeter",function()
    local uiData = {
        imgColor =  `COLOR_GREEN`,
        isIconBackgroundVisible = 0,
        meterColor =  `COLOR_GREEN`,
        meterValue =  1.0,
        meterVisible = true,
        overlayColor =  `COLOR_GREEN`,
        overlayTxd = "scoretimer_textures",
        overlayTxn = "SCORETIMER_GENERIC_CROSS",
        overlayVisible =  false,
        secondaryImgColor = `COLOR_PURE_WHITE`,
        secondaryTxd =  0,
        secondaryTxn = 0,
        showAlternateIcons = 0,
        showBlinkIcon = 0,
        showPulse = 0,
        txd =  "blips",
        txn =  "blip_ambient_train",
        visible = true,
    }
    local meterData = exports["qadr_ui"]:getMeterMain() -- you can get main meter container and use function
    local meter = meterData:addMeterToContainer(uiData) -- you can add 10 meter to container same time
    if meter then
        meter:updateMeter(uiData)
        meter:SetTimer(20,function(iscomplete)
            print("iscomplete",iscomplete)
            if iscomplete then
                print("timer is complete")
            end
        end)
        meter:timerPause()        
        uiData.imgColor =  `COLOR_RED`
        uiData.meterColor =  `COLOR_RED`
        uiData.overlayColor =  `COLOR_RED`
        uiData.secondaryImgColor = `COLOR_RED`
        uiData.txd =  "blips"
        uiData.txn =  "blip_fence_building"
        uiData.secondaryTxd =  "blips"
        uiData.secondaryTxn =  "blip_deadeye_cross"
        uiData.showAlternateIcons = 1
        uiData.showBlinkIcon = 1
        uiData.showPulse = 1
        meter:updateMeter(uiData)
        Wait(5000)
        meter:timerResume()
        uiData.imgColor =  `COLOR_YELLOW`
        uiData.meterColor =  `COLOR_YELLOW`
        uiData.overlayColor =  `COLOR_YELLOW`
        uiData.secondaryImgColor = `COLOR_YELLOW`
        uiData.txd =  "menu_textures"
        uiData.txn =  "medal_bank_debt_bronze"
        meter:updateMeter(uiData)
        Wait(5000)
        meter1:timerStop()
    end
    Wait(2000)
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://abdulkadir-aktas.gitbook.io/qadr_docs/qadr_ui/meters-ui.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.
