DirkScripts
Docs
Quiz
Multi-question quiz system with pass/fail and retake controls.
#lib.registerQuiz (Server)
lualib.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, }, }, })
| Field | Type | Required | Description |
|---|---|---|---|
title | string | yes | Quiz title |
time | number | yes | Quiz duration in seconds |
timeout | number | yes | Cooldown before retake |
passMark | number | yes | Score required to pass |
answerAll | boolean | yes | Require all questions to be answered |
questions | table[] | yes | Quiz questions |
canRetake | boolean | no | Allow players to retake |
secureMode | boolean | no | Hide correct answers from client payload |
Each question supports:
type:single,multiple,text, ornumberquestion: prompt stringoptions: answer options (where applicable)correct: correct answer value
#lib.startQuiz (Client)
lualocal 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)
lualib.closeQuiz()
#lib.getQuiz / lib.deleteQuiz (Server)
lualocal quiz = lib.getQuiz('driving_test') lib.deleteQuiz('driving_test')
