Usage

Integrating nn_minigames into Your Script

This guide shows how to trigger minigames from any FiveM resource (doors, hacking, lockpicking, crafting, etc.) using exports. No need to duplicate UI or logic—just call the export and handle success or failure.


Quick start

Simplest: one line, sync (block until done, get true/false):

-- In your client script, e.g. when player tries to lockpick a door
if exports['nn_minigames']:lockpick('medium') then
    -- Success: open door, give item, etc.
    TriggerServerEvent('myscript:server:unlockDoor', doorId)
else
    -- Failed or cancelled
    print('Lockpick failed')
end

With callback (async):

exports['nn_minigames']:lockpick('medium', nil, function(success)
    if success then
        TriggerServerEvent('myscript:server:unlockDoor', doorId)
    else
        print('Lockpick failed or cancelled')
    end
end)

Both patterns work for every minigame: replace lockpick with hacking, reactiontest, wirecutting, etc. (see Minigame type reference).


Ways to call a minigame

You can use any of these from your script.

1. Generic: StartMinigame(type, ...)

Use when the minigame type is a variable or you want one API for all games.

With difficulty and optional config:

Sync (no callback, returns boolean):

2. Named exports: StartLockpick, StartHacking, etc.

Same behaviour as above, but with a dedicated export per minigame. Easiest for autocomplete and readability.

3. Short name: lockpick, hacking, reactiontest, etc.

Same as the named exports, but with the minigame type as the export name. Good for short one-liners.


Async vs sync

Mode
How to use
Callback?
Return value

Async

Pass a function as the last argument

Yes

Nothing useful

Sync

Do not pass a callback

No

true or false

  • Async: The script continues; when the minigame ends, your callback runs with one argument: success (boolean). Use when you don’t want to block (e.g. multiple systems running).

  • Sync: The call blocks until the minigame finishes (or is cancelled). The export returns true on success, false on fail/cancel. Use for simple “do minigame then do one thing” flows (e.g. lockpick door → open if success).

Callback signature (async only):

  • One argument: success (boolean). true = player won, false = player lost or cancelled (ESC).


Difficulty and custom config

  • Difficulty: 'easy', 'medium', or 'hard'. Optional; default is 'medium' if omitted.

  • Custom config: Optional table to override parts of the minigame config (e.g. timeLimit, description). Pass nil if you don’t need overrides.

Examples:

Difficulty and overrides depend on what each minigame supports in nn_minigames config; see the resource’s config files for full options.


Examples by use case

Lockpick a door (sync)

Hack a terminal (async)

Cut wires (sync)

Reaction test (e.g. for robbery start)

Button mash (e.g. open crate / struggle)

Dynamic minigame type from config


Minigame type reference

Use these as the minigame type string for StartMinigame, or as the export name for the short form (e.g. exports['nn_minigames']:lockpick(...)).

Type string
Short export
Typical use

buttonmash

buttonmash

Mash key to succeed

stopthebar

stopthebar

Stop bar in zone

holdrelease

holdrelease

Hold and release in zone

directionsequence

directionsequence

Repeat arrow sequence

quicktime

quicktime

Press key when prompted

clicktiming

clicktiming

Click at the right time

matchpairs

matchpairs

Match pairs of cards

temperature

temperature

Keep temp in range

balance

balance

Weight balance

lockpick

lockpick

Lockpicking

simonsays

simonsays

Repeat colour sequence

hacking

hacking

Type code / hack

wirecutting

wirecutting

Cut correct wires

slotmachine

slotmachine

Slot machine

rhythm

rhythm

Rhythm / key timing

puzzleslider

puzzleslider

Slider puzzle

reactiontest

reactiontest

React when prompted

numbersequence

numbersequence

Remember number sequence

pressuregauge

pressuregauge

Stop needle in zone


Other exports

  • CancelMinigame() – Cancel the current minigame (e.g. if player walks away). Callback will still run with success = false if you used async.

  • IsMinigameActive() – Returns true if a minigame is currently open. Use to avoid starting a second one or to show a message.

  • GetMinigameConfig(minigameType, difficulty?) – Returns the config table for that minigame/difficulty (for reading values; you usually don’t need this for integration).

  • OpenSettingsUI() / CloseSettingsUI() / IsSettingsOpen() – For opening/closing the nn_minigames settings UI from another script if needed.


Last updated