Skip to main content
TRACK B·BUILD REAL PRODUCTS·Verified June 2026 · Lua 5.4 · ox_lib 3.x
Learning with an AI assistant?
Copies this lesson plus 2026 ground rules (no lua54 'yes', Cfx.re Portal, correct callback signatures) as a ready-to-paste mentor prompt.

/survey command: collect player feedback with an ox_lib dialog

By the end of this lesson you type /survey in chat, fill in a three-question form that ox_lib draws for you, hit submit, and watch the validated answers print in the server console, not the client. You write zero HTML, JS, or CSS for the form.

You'll ship
A /survey command that opens an in-game form, then sends the answers to the server, which re-checks them before logging.
Time
About 30 minutes if you go slow.
You'll learn
lib.inputDialog for a free NUI form, then why the client form is untrusted and the server has to re-validate every answer.
Prereqs
Module 04 done. ox_lib installed and ensured before any qu_ resource. You have met lib.inputDialog and TriggerServerEvent.
BEFORE YOU START

Build it

Make the resource folder

The server has one folder for this lesson.

Inside your server's resources folder, create this folder:

code
resources/qu_survey

Create the files

Every file named in the manifest exists.

Create this exact file layout:

code
resources/qu_survey/
fxmanifest.lua
client.lua
server.lua

Write fxmanifest.lua

FiveM knows which files to load and that ox_lib must load first.

Open fxmanifest.lua and paste this:

code
fx_version 'cerulean'
game 'gta5'

shared_script '@ox_lib/init.lua'
client_script 'client.lua'
server_script 'server.lua'

dependencies {
'ox_lib'
}

fx_version 'cerulean' is the current manifest format, so always use it. game 'gta5' says this resource targets GTA V. There is no lua54 'yes' line: that directive was removed in June 2025, Lua 5.4 is now the only runtime, so the line does nothing and you should not add it. The shared_script '@ox_lib/init.lua' line loads ox_lib's lib global into your resource, and dependencies { 'ox_lib' } blocks startup until ox_lib is running.

Write the client form

A command opens the dialog and sends the answers up to the server.

Open client.lua and paste this:

code
RegisterCommand('survey', function()
local answers = lib.inputDialog('Player Feedback Survey', {
    { type = 'input',    label = 'What is your favorite in-game activity?', required = true, max = 100 },
    { type = 'number',   label = 'Rate the server performance (1-10)',      required = true, min = 1, max = 10 },
    { type = 'checkbox', label = 'Would you recommend this server?' },
})

if not answers then
    print('[qu_survey] survey cancelled')
    return
end

TriggerServerEvent('qu_survey:submit', {
    activity   = answers[1],
    rating     = answers[2],
    recommend  = answers[3],
})
end, false)

Write the server validator

The server re-checks every answer before it trusts or logs it.

Open server.lua and paste this:

code
RegisterNetEvent('qu_survey:submit', function(data)
local src = source

if type(data) ~= 'table' then return end

local activity  = data.activity
local rating    = data.rating
local recommend = data.recommend

if type(activity) ~= 'string' or #activity == 0 or #activity > 100 then
    print('[qu_survey] rejected ' .. GetPlayerName(src) .. ': bad activity')
    return
end

rating = tonumber(rating)
if not rating or rating < 1 or rating > 10 then
    print('[qu_survey] rejected ' .. GetPlayerName(src) .. ': rating out of range')
    return
end

local recommendText = (recommend == true) and 'Yes' or 'No'

print('[qu_survey] ' .. GetPlayerName(src) .. ' | activity: ' .. activity
    .. ' | rating: ' .. rating .. ' | recommend: ' .. recommendText)
end)

Start and test it

The validated answers print in the server console.

Make sure ox_lib starts first. Open server.cfg and add both lines in this order:

code
ensure ox_lib
ensure qu_survey

Save, then run this in the txAdmin Live Console (the server console):

code
restart qu_survey

Join the server, then run this from the in-game chat box (press T) (this is a client command):

code
/survey

Type Racing for the activity, 8 for the rating, tick the recommend box, and submit.

The line appears in the server console, not F8, because the answers travelled up to server.lua to be validated before anything was logged.

Keep reading the full lesson

Sign in to start, then unlock every step of this lesson and the full FiveM School with a membership.

Still ahead in this lesson
  • How it works
  • If something went wrong
  • What you can do now
  • Try it yourself

The remainder of Player survey form with ox_lib is available to FiveM School members.