Quiz

Library
Updated 2 months ago · v1.3.7

Multi-question quiz system with pass/fail and retake controls.

lib.registerQuiz (Server)

lua
lib.registerQuiz('driving_test', {
    title = 'Driving Theory Test',
    time = 120,
    timeout = 3600,
    passMark = 8,
    answerAll = true,
    canRetake = true,
    secureMode = true,
    questions = {
        {
            type = 'single',
            question = 'What does a red light mean?',
            options = { 'Stop', 'Go', 'Slow down' },
            correct = 1,
        },
    },
})
FieldTypeRequiredDescription
titlestringyesQuiz title
timenumberyesQuiz duration in seconds
timeoutnumberyesCooldown before retake
passMarknumberyesScore required to pass
answerAllbooleanyesRequire all questions to be answered
questionstable[]yesQuiz questions
canRetakebooleannoAllow players to retake
secureModebooleannoHide correct answers from client payload

Each question supports:

  • type: single, multiple, text, or number
  • question: prompt string
  • options: answer options (where applicable)
  • correct: correct answer value

lib.startQuiz (Client)

lua
local ok, info = lib.startQuiz('driving_test')

Returns ok, info where ok is true/false and info is quiz payload or failure reason.

lib.closeQuiz (Client)

lua
lib.closeQuiz()

lib.getQuiz / lib.deleteQuiz (Server)

lua
local quiz = lib.getQuiz('driving_test')
lib.deleteQuiz('driving_test')
Was this page helpful?
This page was last updated on 12 March 2026
DIRKSCRIPTS
All you need for your FiveM server.10% off your first order

Unsubscribe any time.

Copyright © 2026 DirkScripts. Not affiliated with or endorsed by Rockstar North or Take-Two Interactive.