Interaction Prompts

Register core managed prompts, remember, these are client-sided.

CreatePromptGroup

Create a group of prompts that can be enabled/disabled.

Parameter
Required
Type
Description

prompts

List

A list of prompts to create the prompt group for

local promptGroupId = TMC.Functions.CreatePromptGroup({
    {
        Id = 'prompt_internal_name',
        Complete = function()
            -- function to call when user selects item
        end,
        Title = '', -- The title of the prompt
        Description = '', -- Optional description text
        Icon = '', -- The font-awesome icon I.e. 'fas fa-circle'
        AutoComplete = false, -- Optional, auto-complete the prompt selection if only 1 prompt is available
    }
})

DeletePromptGroup

Remove a prompt group and delete it.

Parameter
Required
Type
Description

promptGroupId

Int

The prompt group id

TMC.Functions.DeletePromptGroup(promptGroupId)

ShowPromptGroup

Enable interaction and visibility of a prompt group

Parameter
Required
Type
Description

promptGroupId

Int

The prompt group Id to enable

promptRestrictions

List

A list of prompts to enable if you don't want to enable them all

forceUpdate

Boolean

If we should force an update when the prompt group is already enabled. I.e. to enable a new restricted set of prompts

TMC.Functions.ShowPromptGroup(promptGroupId, { 'prompt_internal_name' })

HidePromptGroup

Hides all prompts from a group

Parameter
Required
Type
Description

promptGroupId

Int

The prompt group Id

TMC.Functions.HidePromptGroup(promptGroupId)

Full Example:

This is a full example of the features available with the PromptGroups

Citizen.CreateThread(function()
    TMC.Functions.AddCircleZone('test_zone', vector3(-223.7, -1536.3, 31.6), 5.0, {
        useZ = true,
        data = {
            job = 'testjob'
        }
    })

    TestPrompt = TMC.Functions.CreatePromptGroup({
        {
            Id = 'test_prompt',
            Complete = function()
                -- Do work
                TMC.Functions.HidePromptGroup(TestPrompt)
                TMC.Functions.SimpleNotify('Test Prompt')
            end,
            Title = 'Test Prompt',
            Description = 'This is a test prompt, see what it can do',
            AutoComplete = true,
            Icon = 'fa-solid fa-circle-question'
        },
        {
            Id = 'test_job_prompt',
            Complete = function()
                TMC.Functions.SimpleNotify('Test Job Prompt')
            end,
            Title = 'Hidden Job Prompt',
            Description = 'This is a private prompt, ooh scary :D',
            AutoComplete = false,
            Icon = 'fa-solid fa-circle-question'
        }
    })

    TMC.Functions.AddPolyZoneEnterHandler('test_zone', function(data)
        if TMC.Functions.HasJob(data.job) then
            -- Show all as player has the job
            TMC.Functions.ShowPromptGroup(TestPrompt)
        else
            -- Only show the main prompt
            TMC.Functions.ShowPromptGroup(TestPrompt, { 'test_prompt' })
        end
    end)

    TMC.Functions.AddPolyZoneExitHandler('test_zone', function()
        if TMC.Functions.IsPromptGroupVisible(TestPrompt) then
            TMC.Functions.HidePromptGroup(TestPrompt)
        end
    end)
end)

Last updated