> For the complete documentation index, see [llms.txt](https://igris-script.gitbook.io/igris-script/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://igris-script.gitbook.io/igris-script/paid-script/igris-qcm.md).

# Igris QCM

<figure><img src="https://2862342791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFnkzyjlqOP6UGw1GyN62%2Fuploads%2Fzka3edFPXwUTvO4zUKO5%2Fqcm.png?alt=media&amp;token=f825c922-52cd-4ef2-b50d-fc7184301351" alt=""><figcaption></figcaption></figure>

Standalone RedM resource by Igris. No framework or SQL database required.&#x20;

### Installation

1. Extract the `igris_qcm` folder into your server's resources directory.
2. Edit `config.lua`: server name, rules, Discord invite link, and private webhook URL.
3. Add `ensure igris_qcm` to `server.cfg`, then start or restart the server.
4. Connect with an account that has not yet passed the quiz to test the resource.

The 15 included questions are for demonstration purposes only. Replace them with questions suited to your server rules before opening to the public. The Discord link and webhook URL are empty by default: no external messages are sent until configured. The Discord button displays an informational message while its link is empty. The built-in rules are available immediately after installation.

### Settings

* `QuestionTime = 20`: seconds per question.
* `QuestionCount = 10`: questions randomly selected without repetition for each attempt.
* `FailAtErrors = 3`: 0–2 incorrect answers = pass; 3 or more = fail.
* `RetryCooldown = 30`: cooldown in minutes.
* `MenuTimeout = 300`: five minutes to read the information or start the quiz from the menu.
* `MaxSessions = 64`: maximum number of simultaneous menus and quiz sessions.
* `RulesUrl`: optional; replaces the built-in rules with a link.
* `Text`: editable player-facing text and main result labels. Additional technical messages are internal to server.lua.
* `Questions`: all questions, choices and correct answer positions.
* `Rules`: built-in rules text.

The player completes all 10 questions, even after their third incorrect answer. A timed-out question counts as an incorrect answer and automatically advances to the next question. No intermediate results or correct answers are shown to the player. The time limit is displayed as text; there is no animated countdown or refresh every second. The timer starts when the server sends the question: allow some extra time for slower connections.

Questions and answer choices are shuffled for each attempt. Two players may receive some of the same questions: random selection does not guarantee different sets for each person. `answer` refers to the position of the correct choice in `Config.Questions` in `config.lua`, before shuffling.

### JSON Storage and Attempt Protection

`data/players.json` stores pass records, cooldown expiry times, and the latest scores, linked to the `license:` identifier. No IP addresses, Discord IDs, or passwords are stored. Do not overwrite this file when updating the resource.

All checks and correct answers are handled exclusively on the server. Only one session is allowed per license; double clicks, outdated responses, and nonexistent choices are ignored.

Starting an attempt reserves a cooldown lasting until the maximum quiz duration plus 30 minutes has elapsed. Passing removes this cooldown. Failing or a detected disconnection resets it to 30 minutes from the end of the attempt or the disconnection. If RedM does not report the abandoned attempt, or if the server restarts during the quiz, the reserved cooldown remains: with the default settings, up to 33 minutes and 20 seconds from the start of the attempt. This prevents players from immediately reconnecting to get a new set of questions. Leaving the menu before starting does not trigger a cooldown.

The JSON file is read at startup, kept in memory, and written at the start and end of an attempt or when a reset is performed. The previous save is kept in `data/players.backup.json`. The file is not rewritten after each question. Writes are not an atomic transaction; if the JSON is invalid or a write fails, access is blocked to prevent an unsaved pass result. Stop the resource, inspect the files, restore a valid copy, and then restart. The previous copy may not include the very latest operation.

The resource must remain running: stopping it removes this connection filter. If a queue or another whitelist resource already displays Adaptive Cards, test and coordinate these resources to prevent them from replacing each other's windows.

### Retaking the Quiz

Run this command in the server console only:

```
igris_qcm_reset license:PLAYER_IDENTIFIER
```

The command removes the pass record and cooldown for that license, provided no attempt is currently active. The license can be found in the JSON file or logs. Reconnect afterward. Do not edit the JSON file while the resource is running: the in-memory state will overwrite your changes.
