input

Creates and displays an input dialog with various field types.

Parameters:

  • label (string): Dialog title

  • data (table): Array of input fields

Input Field Structure:

{
    title = "Field Label",           -- Display label for the field
    type = "input",                  -- Field type (input, number, select, checkbox, etc.)
    description = "Field description", -- Help text for the field
    placeholder = "Enter text...",   -- Placeholder text
    options = {                      -- Options for select type
        {value = 'option1', label = 'Option 1'},
        {value = 'option2', label = 'Option 2'}
    },
    required = true,                 -- Whether field is required
    min = 1,                        -- Minimum value (for number type)
    max = 100                       -- Maximum value (for number type)
}

Returns:

  • table|nil: Array of input values or nil if cancelled

Example:

local result = ps.input('Player Information', {
    {
        title = 'First Name',
        type = 'input',
        placeholder = 'Enter first name',
        required = true
    },
    {
        title = 'Age',
        type = 'number',
        min = 18,
        max = 100,
        required = true
    },
    {
        title = 'Department',
        type = 'select',
        options = {
            {value = 'police', label = 'Police Department'},
            {value = 'ems', label = 'Emergency Medical'},
            {value = 'fire', label = 'Fire Department'}
        },
        required = true
    },
    {
        title = 'On Duty',
        type = 'checkbox',
        description = 'Are you currently on duty?'
    }
})

if result then
    local firstName = result[1]
    local age = result[2]
    local department = result[3]
    local onDuty = result[4]
    
    print("Name:", firstName, "Age:", age, "Dept:", department, "Duty:", onDuty)
else
    print("Input cancelled")
end

Input Field Types

text/input

Basic text input field.

{
    title = 'Player Name',
    type = 'input',
    placeholder = 'Enter player name',
    required = true
}

number

Numeric input with min/max validation.

{
    title = 'Amount',
    type = 'number',
    min = 1,
    max = 999999,
    placeholder = 'Enter amount',
    required = true
}

select

Dropdown selection from predefined options.

{
    title = 'Vehicle Class',
    type = 'select',
    options = {
        {value = 'compact', label = 'Compact Cars'},
        {value = 'sedan', label = 'Sedans'},
        {value = 'suv', label = 'SUVs'},
        {value = 'sports', label = 'Sports Cars'}
    },
    required = true
}

checkbox

Boolean checkbox input.

{
    title = 'Send Notification',
    type = 'checkbox',
    description = 'Send notification to all players'
}

textarea

Multi-line text input.

{
    title = 'Description',
    type = 'textarea',
    placeholder = 'Enter detailed description...',
    required = false
}

Last updated