# Wanted UI

<figure><img src="https://580445893-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fzf2ZAqGbUPk9K8cVFSgd%2Fuploads%2FjeFxRd1NC1d1WIQ5CvGs%2Fimage%20(15).png?alt=media&#x26;token=378092e8-96db-4a4d-8ec1-94c235ec48c3" alt=""><figcaption></figcaption></figure>

<details>

<summary>Useable upperLocText</summary>

THEFT : Theft

MURDER : Murder

BOUNTY : BOUNTY

MALE\_WANTED : WANTED

ASSAULT : Assault

ROBBERY : Robbery

LOOTING : Looting

WITNESS : WITNESS

CHEATING : Cheating

THEFT\_LIVESTOCK : Rustling

VANDALISM : Vandalism

NO\_BOUNTY : No Bounty

KIDNAPPING : Kidnapping

ACCOMPLICE : Accomplice

</details>

<details>

<summary>Usable default rdr text</summary>

Key : Text - Use key for data

KIDNAPPING : Kidnapping

INTIMIDATION : Intimidation

ASSAULT\_HORSE : Animal Cruelty

JACK\_VEHICLE : Vehicle Theft

TRAIN\_ROBBERY : Train Robbery

LASSO\_ASSAULT : Assault

THEFT\_HORSE : Horse Theft

STOLEN\_GOODS : Theft

ACCOMPLICE : Accomplice

TRAMPLE\_LAW : Murder

BANK\_ROBBERY : Bank Robbery

STAGECOACH\_ROBBERY : Robbery

LAW\_IS\_THREATENED : Disturbing the Peace

ROBBERY : Robbery

ASSAULT : Assault

KIDNAPPING\_LAW : Kidnapping

ASSAULT\_CORPSE : Disturbing the Peace

VEHICLE\_DESTRUCTION : Vandalism

FEMALE\_WANTED : WANTED

CHEATING : Cheating

DISTURBANCE : Disturbing the Peace

VANDALISM\_VEHICLE : Vandalism

MURDER\_LIVESTOCK : Animal Cruelty

ASSAULT\_LIVESTOCK : Animal Cruelty

JACK\_HORSE : Horse Theft

MURDER\_HORSE : Animal Cruelty

VANDALISM : Vandalism

TRAMPLE : Murder

THREATEN\_LAW : Disturbing the Peace

UNARMED\_ASSAULT : Unarmed Assault

ASSAULT\_ANIMAL : Animal Cruelty

BURGLARY : Trespassing

THREATEN : Disturbing the Peace

TRESPASSING : Trespassing

THEFT\_LIVESTOCK : Rustling

RESIST\_ARREST : Disturbing the Peace

THEFT : Theft

MURDER : Murder

PROPERTY\_DESTRUCTION : Vandalism

ASSAULT\_LAW : Assault

LOOTING : Looting

HIT\_AND\_RUN\_LAW : Unarmed Assault

THEFT\_VEHICLE : Vehicle Theft

MURDER\_LAW : Murder

JAIL\_BREAK : Jail Break

LOITERING : Disturbing the Peace

MURDER\_ANIMAL : Animal Cruelty

HIT\_AND\_RUN : Unarmed Assault

EXPLOSION : Disturbing the Peace

MALE\_WANTED : WANTED

GRAVE\_ROBBERY : Grave Robbery

HASSLE : Disturbing the Peace

WITNESS : WITNESS

</details>

## Usable functions

Description: In the new system, you can now trigger 3 different interfaces at once and then switch between the interfaces you want. Each interface can display 4 lowertexts.

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

```lua
-- Shows the wanted UI using the qadr_ui resource.
-- @param data The data to be displayed in the wanted UI.
-- @return The wanted UI.
local wantedUI = exports["qadr_ui"]:showWanted(data)

-- Updates the first message of the 'wantedUI' object with the provided data.
-- @param data The new message to be displayed.
wantedUI.firstMessage:update(data.firstMessage)

-- Sets the lower text of the "firstMessage" switch in the UI to the second index.
wantedUI.firstMessage:setSwitchLowerTextToIndex(2)

-- Updates the wanted UI with the given data.
-- @param data The data to update the UI with.
wantedUI:update(data)

-- Hides/show the first message in the wanted UI.
wantedUI.firstMessage:setShowMessage(false)

-- Sets the upper localized text of the "CRIME_ACCOMPLICE" message in the "firstMessage" element of the "wantedUI" object.
-- Check "Useable upperLocText" for more text
wantedUI.firstMessage:setUpperLocText("CRIME_ACCOMPLICE")

-- Sets the show warning animation flag to true for the second message in the wantedUI table.
-- @param wantedUI The table containing the notification data.
wantedUI.firstMessage:setShowWarningAnimation(true)

-- Sets the texts for the first message in the wanted UI.
-- @param texts A table containing the texts to be set for each line of the message.
-- Each line is represented by a key-value pair, where the key is a number indicating the line number,
-- and the value is a table containing two fields:
--     - textfromrdr: A boolean indicating whether the text should be translated from RDR's localization system.
--     - text: The actual text to be displayed.
wantedUI.firstMessage:setTexts({
    ["1"] = {
        textfromrdr = true,
        text = "CRIME_ACCOMPLICE",
    },
    ["2"] = {
        textfromrdr = false,
        text = "firstMessage 2",
    },
    ["3"] = {
        textfromrdr = false,
        text = "firstMessage 3",
    },
    ["4"] = {
        textfromrdr = false,
        text = "firstMessage 4",
    }
})

-- Sets the showKnownPulse value for the specified data.
-- @param show A boolean value indicating whether to show the known pulse or not.
-- @return None.
wantedUI.firstMessage:setShowKnownPulse(true)

-- Sets whether or not to show the unknown pulse for the given data.
-- @param show Whether or not to show the unknown pulse.
wantedUI.firstMessage:setShowUnknownPulse(true)

-- Sets the show status of the short wanted cooldown and waits for 10 seconds before executing the callback function (if provided).
-- @param show A boolean value indicating whether to show the short wanted cooldown.
-- @param cb (Optional) The callback function to execute after the 10-second wait.
-- @return None.
wantedUI.firstMessage:setShowShortWantedCooldown(true,function()
    print("short cooldown finished")
end)

-- Sets whether to show the long wanted cooldown and waits for 40 seconds before executing the callback function (if provided).
-- @param show A boolean indicating whether to show the long wanted cooldown.
-- @param cb (Optional) The callback function to execute after the 40 second wait.
-- @return None.
wantedUI.firstMessage:setShowLongWantedCooldown(true,function()
    print("long cooldown finished")
end)

-- Sets the lower text of the first message in the wanted UI to the localized string with the key "HIT_AND_RUN_LAW". Check usable texts
wantedUI.firstMessage:setLowerTextfromIndex(1,"HIT_AND_RUN_LAW")
    
-- Sets the lower raw text of the first message in the wanted UI to "Test Raw Text" or you can use usable text.
-- @param wantedUI The UI element to modify.
wantedUI.firstMessage:setLowerRawTextToIndex(1,"Test Raw Text")

-- Clears the wanted UI.
wantedUI:clear()
```

{% endcode %}

## Video

{% embed url="<https://www.youtube.com/watch?v=w_5sprU3zIE>" fullWidth="true" %}

## Main Example

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

```lua
RegisterCommand("wantedUI",function(src,args,raw)
    local data = {
        showBountyHunterMessage = true, -- show bounty hunter message http://prntscr.com/gDsOV-qLN_4W
        firstMessage = {
            showMessage = false
        },
        secondMessage = {
            showMessage = false,
        },
        thirdMessage = {
            showMessage = false,
        }
    }
    local wantedUI = exports["qadr_ui"]:showWanted(data)
    print("wanted ui created")
    Wait(2000)
    data.firstMessage.upperLocText = "CRIME_ACCOMPLICE"
    data.firstMessage.upperTextStyle = 0
    data.firstMessage.showWarningAnimation = true
    data.firstMessage.showMessage = true
    data.firstMessage.texts = {
        ["1"] = {
            textfromrdr = true,
            text = "CRIME_ACCOMPLICE",
        },
        ["2"] = {
            textfromrdr = false,
            text = "Text 2 u",
        },
        ["3"] = {
            textfromrdr = false,
            text = "Text 3 u",
        },
        ["4"] = {
            textfromrdr = false,
            text = "Text 4 u",
        }
    }
    data.firstMessage.switchLowerTextToIndex = 1
    print("wanted ui data updated")
    wantedUI.firstMessage:update(data.firstMessage)
    print("updated data sent to native ui")
    Wait(2000)
    wantedUI.firstMessage:setSwitchLowerTextToIndex(2)
    print("switched lower text to index 2")
    Wait(2000)
    data.firstMessage.texts["2"].text = "New Text 2"
    data.firstMessage.showMessage = true
    data.firstMessage.showWarningAnimation = true
    data.firstMessage.upperLocText = "INVESTIGATING"
    print("wanted ui data updated")
    wantedUI:update(data)
    print("updated data sent to native ui")
    Wait(3000)
    
    wantedUI.firstMessage:setShowMessage(false)
    print("first message set hide")
    wantedUI.firstMessage:setShowMessage(true)
    print("second message set show")
    wantedUI.firstMessage:setUpperLocText("CRIME_ACCOMPLICE")
    print("second message set upper text to CRIME_ACCOMPLICE")
    wantedUI.firstMessage:setUpperTextStyle(0)
    print("second message set upper text style to 0")
    wantedUI.firstMessage:setShowWarningAnimation(true)
    print("second message set show warning animation to true")
    wantedUI.firstMessage:setSwitchLowerTextToIndex(1)
    print("second message set switch lower text to index 1")
    wantedUI.firstMessage:setTexts({
        ["1"] = {
            textfromrdr = true,
            text = "CRIME_ACCOMPLICE",
        },
        ["2"] = {
            textfromrdr = false,
            text = "firstMessage 2",
        },
        ["3"] = {
            textfromrdr = false,
            text = "firstMessage 3",
        },
        ["4"] = {
            textfromrdr = false,
            text = "firstMessage 4",
        }
    })
    print("second message set texts")
    Wait(5000)
    wantedUI.firstMessage:setShowKnownPulse(true)
    print("second message set show known pulse to true")
    print("short cooldown started")
    wantedUI.firstMessage:setShowShortWantedCooldown(true,function()
        print("short cooldown finished")
    end)
    print("long cooldown started")
    wantedUI.firstMessage:setShowLongWantedCooldown(true,function()
        print("long cooldown finished")
    end)
    wantedUI.firstMessage:setLowerTextfromIndex(1,"HIT_AND_RUN_LAW")
    
    wantedUI.firstMessage:setLowerRawTextToIndex(1,"Test Raw Text")
    Wait(2000)
    print("wanted ui cleared")
    wantedUI:clear()
end)
```

{% endcode %}
