VORP Inputs System Documentation
VORP Inputs allows you to build advanced input menus for your scripts with customizable styling and validation.
Table of Contents
Getting Started
The VORP Inputs system is client-side only and provides advanced input functionality for user data collection.
Getting Started > Basic Usage
local result = exports.vorp_inputs:advancedInput(inputConfig)
Parameters:
inputConfig- Configuration table defining the input properties
Returns:
result- String containing the user input
Input Configuration > Input Configuration Object
local myInput = {
type = "enableinput", -- Required: Don't modify
inputType = "input", -- Input type
button = "Confirm", -- Button text
placeholder = "NAME QUANTITY", -- Placeholder text
style = "block", -- Required: Don't modify
attributes = {
inputHeader = "GIVE ITEM", -- Header text
type = "text", -- Input type (text, number, date, textarea, etc.)
pattern = "[0-9]", -- Validation pattern
title = "numbers only", -- Error message for invalid input
style = "border-radius: 10px; background-color: ; border:none;" -- CSS styling
}
}
Input Configuration > Configuration Properties > Main Properties
type- Must be "enableinput" (required, do not modify)inputType- Set to "input" for input fieldsbutton- Text displayed on the confirm buttonplaceholder- Placeholder text shown in empty input fieldstyle- Must be "block" (required, do not modify)
Input Configuration > Configuration Properties > Attributes Object
inputHeader- Header text displayed above the inputtype- HTML input type (see Input Types)pattern- Regular expression for input validation (see Validation Patterns)title- Error message shown when input doesn't match patternstyle- CSS styling for the input field
Input Types
The attributes.type property supports various HTML input types:
Input Types > Text Input
attributes = {
type = "text"
}
Use Case: General text input, names, descriptions
Input Types > Number Input
attributes = {
type = "number"
}
Use Case: Numeric values, quantities, prices
Input Types > Date Input
attributes = {
type = "date"
}
Use Case: Date selection, birth dates, event dates
Input Types > Textarea
attributes = {
type = "textarea"
}
Use Case: Multi-line text input, descriptions, messages
Input Types > Email Input
attributes = {
type = "email"
}
Use Case: Email address validation
Input Types > Password Input
attributes = {
type = "password"
}
Use Case: Password entry (masked input)
Validation Patterns
Use regular expressions in the pattern attribute to validate user input:
Validation Patterns > Numbers Only
pattern = "[0-9]"
Validates: Single digit
pattern = "[0-9]+"
Validates: One or more digits
Validation Patterns > Letters Only
pattern = "[A-Za-z]+"
Validates: Letters only (uppercase and lowercase)
Validation Patterns > Alphanumeric
pattern = "[A-Za-z0-9]+"
Validates: Letters and numbers only
Validation Patterns > Specific Length
pattern = "[0-9]{3}" -- Exactly 3 digits
pattern = "[A-Za-z]{2,10}" -- 2 to 10 letters
Validation Patterns > Custom Patterns
pattern = "^[A-Za-z\\s]+$" -- Letters and spaces only
pattern = "^\\d{1,4}$" -- 1 to 4 digits
pattern = "^[a-z0-9_-]+$" -- Lowercase letters, numbers, underscore, hyphen
Result Processing > Basic Result Handling
local result = exports.vorp_inputs:advancedInput(myInput)
-- Convert to number
result = tonumber(result)
-- Convert to string (if needed)
result = tostring(result)
Result Processing > Splitting Multiple Values
When users enter multiple values separated by spaces:
local result = "apple 5" -- Example result
local splitString = {}
for i in string.gmatch(result, "%S+") do
splitString[#splitString + 1] = i
end
local data1, data2 = splitString[1], splitString[2]
-- data1 = "apple", data2 = "5"
Result Processing > Advanced Result Processing
-- Split and validate multiple values
local function processMultipleInputs(result)
local splitString = {}
for i in string.gmatch(result, "%S+") do
splitString[#splitString + 1] = i
end
if #splitString < 2 then
return nil, "Not enough parameters"
end
local itemName = splitString[1]
local quantity = tonumber(splitString[2])
if not quantity then
return nil, "Invalid quantity"
end
return {
item = itemName,
quantity = quantity
}
end
-- Usage
local result = exports.vorp_inputs:advancedInput(myInput)
local data, error = processMultipleInputs(result)
if data then
print("Item: " .. data.item .. ", Quantity: " .. data.quantity)
else
print("Error: " .. error)
end
Examples > Simple Text Input
local nameInput = {
type = "enableinput",
inputType = "input",
button = "Submit",
placeholder = "Enter your name",
style = "block",
attributes = {
inputHeader = "Character Name",
type = "text",
pattern = "[A-Za-z\\s]+",
title = "Letters and spaces only",
style = "border-radius: 5px; padding: 10px;"
}
}
local playerName = exports.vorp_inputs:advancedInput(nameInput)
if playerName and playerName ~= "" then
print("Player name: " .. playerName)
end
Examples > Number Input with Validation
local quantityInput = {
type = "enableinput",
inputType = "input",
button = "Confirm",
placeholder = "Enter quantity (1-999)",
style = "block",
attributes = {
inputHeader = "Item Quantity",
type = "number",
pattern = "[1-9][0-9]{0,2}", -- 1-999
title = "Enter a number between 1 and 999",
style = "border-radius: 8px; border: 2px solid #333;"
}
}
local quantity = exports.vorp_inputs:advancedInput(quantityInput)
quantity = tonumber(quantity)
if quantity and quantity > 0 and quantity <= 999 then
print("Valid quantity: " .. quantity)
else
print("Invalid quantity entered")
end
Examples > Multi-Value Input (Item and Quantity)
local itemInput = {
type = "enableinput",
inputType = "input",
button = "Give Item",
placeholder = "ITEM_NAME QUANTITY",
style = "block",
attributes = {
inputHeader = "Give Item to Player",
type = "text",
pattern = "^[A-Za-z_]+ [0-9]+$",
title = "Format: ITEM_NAME QUANTITY (e.g., bread 5)",
style = "border-radius: 10px; padding: 12px; font-family: monospace;"
}
}
local result = exports.vorp_inputs:advancedInput(itemInput)
if result then
local splitString = {}
for i in string.gmatch(result, "%S+") do
splitString[#splitString + 1] = i
end
local itemName, quantity = splitString[1], tonumber(splitString[2])
if itemName and quantity then
-- Give item to player
TriggerServerEvent("givePlayerItem", itemName, quantity)
end
end
Examples > Date Input
local dateInput = {
type = "enableinput",
inputType = "input",
button = "Set Date",
placeholder = "Select date",
style = "block",
attributes = {
inputHeader = "Event Date",
type = "date",
title = "Please select a valid date",
style = "border-radius: 6px; padding: 8px;"
}
}
local eventDate = exports.vorp_inputs:advancedInput(dateInput)
if eventDate then
print("Event scheduled for: " .. eventDate)
end
Examples > Textarea Input
local messageInput = {
type = "enableinput",
inputType = "input",
button = "Send Message",
placeholder = "Type your message here...",
style = "block",
attributes = {
inputHeader = "Send Message",
type = "textarea",
pattern = ".{1,500}", -- 1-500 characters
title = "Message must be 1-500 characters",
style = "border-radius: 8px; padding: 10px; min-height: 100px; resize: vertical;"
}
}
local message = exports.vorp_inputs:advancedInput(messageInput)
if message and #message > 0 then
TriggerServerEvent("sendMessage", message)
end
Examples > Styled Input with Custom CSS
local styledInput = {
type = "enableinput",
inputType = "input",
button = "๐ Confirm",
placeholder = "Enter amount...",
style = "block",
attributes = {
inputHeader = "๐ฐ Bank Deposit",
type = "number",
pattern = "[1-9][0-9]*",
title = "Enter a positive number",
style = [[
border-radius: 15px;
padding: 15px;
background: linear-gradient(45deg, #1a1a1a, #2d2d2d);
border: 2px solid #gold;
color: #fff;
font-size: 16px;
box-shadow: 0 4px 8px rgba(0,0,0,0.3);
]]
}
}
local amount = exports.vorp_inputs:advancedInput(styledInput)
amount = tonumber(amount)
if amount and amount > 0 then
TriggerServerEvent("bankDeposit", amount)
end
Best Practices > Input Validation
- Always validate input on both client and server
- Use appropriate patterns for expected input format
- Provide clear error messages in the title attribute
- Handle nil/empty results gracefully
Best Practices > User Experience
- Use descriptive headers that explain what input is expected
- Provide clear placeholders showing input format
- Style inputs consistently across your script
- Give feedback when input is processed
Best Practices > Error Handling
local function safeInputPrompt(inputConfig, validator)
local result = exports.vorp_inputs:advancedInput(inputConfig)
if not result or result == "" then
return nil, "No input provided"
end
if validator and not validator(result) then
return nil, "Invalid input format"
end
return result
end
-- Usage with validator
local result, error = safeInputPrompt(myInput, function(input)
return tonumber(input) ~= nil and tonumber(input) > 0
end)
if result then
-- Process valid input
else
print("Input error: " .. (error or "Unknown error"))
end
Notes
- VORP Inputs is client-side only
- Always validate input on the server side for security
- Use appropriate HTML input types for better user experience
- Regular expressions in patterns help ensure data quality
- CSS styling allows for theme consistency across your scripts
- Multiple values can be separated by spaces and split using string.gmatch
- Consider user experience when designing input prompts