Exports & results ​
np_minigames is always optional for other resources. Detect it with
GetResourceState('np_minigames') == 'started' and keep your own fallback when it isn't running. Step-by-step
patterns are in Integrating your resource; game ids and params in Games & difficulty.
Result ​
Every call ends with one result table:
{
success = true, -- the server's replay says the player won
score = 0.87, -- 0..1 quality (centre hits, heat left, care, accuracy ...)
grade = 'great', -- 'perfect' (>= .95) | 'great' (>= .8) | 'good' (>= .5) | 'pass' | 'fail'
reason = nil, -- on failure, see below
game = 'thermite', difficulty = 'hard', ms = 9120,
stats = { ... }, -- game-specific (hits, misses, picks, peak heat ...)
implausible = nil, -- true when the answer was refused as impossible (also logged in np_admin)
item = { name = 'lockpick', removed = true, degraded = 20, durability = 60 }, -- only with opts.item
profile = 'np_prison:dig', receipt = 'r3f…', -- only for profile runs
}
degraded is the number of durability points taken, durability what is left (0..100). Both are nil when
degrade wasn't set, the item was removed, or the inventory has no durability.
Reasons ​
| Reason | When |
|---|---|
| the game's own | wrong, timeout, overheat, broken, snapped, escaped, miss, early, care, fumes, alarm, … (listed per game on the category pages) |
cancel |
The player pressed Esc (only when cancelable is not false) |
too_fast / clock |
The answer was faster than a fair solve, or its clock ran ahead of the server's (implausible = true) |
moved |
The player went further than maxMove from coords |
dead / interrupted |
The player died or was cuffed |
not_shown |
The client never showed the game within Security.startTimeoutMs |
replaced |
Another start with replace = true ended this one |
dropped |
The player left |
team_failed / out_of_sync |
A team member failed, or the team didn't finish within window |
api |
Cancel was called, or the invoking resource or np_minigames stopped |
invalid |
The answer could not be read |
Refusals before a game starts come back as false, { success = false, reason = ... } with no game played:
busy (a game is running for the player), disabled, unknown_game, no_item, cooldown, unknown_profile,
invalid_item, or the reason a beforeStart hook returned.
Options ​
Every Play, Start, Chain, Team and TeamAsync takes these:
| Key | Default | |
|---|---|---|
difficulty |
Config.Games[id].difficulty or Config.Difficulty.default |
'easy' | 'medium' | 'hard' | 'expert' or 1..4 |
| any game param | the preset's value | e.g. { rounds = 5 }, { cells = 12, seconds = 10 }; also accepted as params = { ... }. Clamped to the param's range |
label, title, sub |
the game's name | Text on the card ("Fleeca keypad", "Layer 2 / 3") |
icon, tint |
the game's own | Font Awesome solid name, Nimbus tile tint |
cancelable |
true |
Esc gives up (reason = 'cancel') |
maxMove |
Config.Security.maxMove (0 = off) |
Metres from coords before moved |
coords |
where the player stood | Start point for maxMove (server) |
replace |
false |
End a running game instead of failing with busy |
noAssist |
false |
Ignore the player's Assist setting for this run |
seed |
random | A fixed puzzle (replays, tests) |
window |
6 |
Team only: seconds between the first and the last finish |
item |
none | An item the player needs and may use up, see Items |
onProgress |
none | function(p): cosmetic progress 0..100, see Progress |
progress |
false |
true: ask the NUI for progress without a callback (only the np_minigames:progress event) |
Server exports ​
These are server-validated: the server builds, times and judges the game.
| Export | Returns | |
|---|---|---|
Play(src, id, opts?) |
ok, result |
Yields until the game ends |
Start(src, id, opts?, cb) |
token | nil, err |
Async; cb(result) when it ends |
Chain(src, steps, opts?) |
ok, results |
Yields. Several games in a row, stops at the first failure. Steps are { id, opts } or { game = id, opts = {} } |
Team(srcs, id, opts?) |
ok, team |
Yields. Two or more players at once; team = { success, reason?, spreadMs, results = { [src] = result } } |
TeamAsync(srcs, id, opts?, cb) |
Async Team, cb(team) |
|
SkillCheck(src, difficulty, inputs?) |
boolean |
Yields. ox_lib lib.skillCheck shape (skill ring): a difficulty string, a list, or { areaSize, speedMultiplier } |
Cancel(src, reason?) |
boolean |
End the player's running game |
IsActive(src) |
boolean, gameId |
|
GetGames() |
table[] |
{ id, label, icon, tint, category, source, params, difficulties, enabled } per game |
GetStats(src) |
table |
{ [gameId] = { plays, wins, perfects, best_points, ... } } |
Build(id, opts?) |
puzzle |
Your own flow: make a puzzle for your own UI … |
Verify(puzzle, answer, elapsedMs) |
result |
… and judge the answer here |
RegisterProfile / UnregisterProfile / Redeem |
See Profiles + receipts | |
RegisterHook(name, fn) |
See Hooks |
-- blocks the calling thread until the game ends
local ok, result = exports.np_minigames:Play(src, 'hexhack', { difficulty = 'hard', label = 'Fleeca keypad', maxMove = 2 })
if ok then OpenVault() end
-- async
local token, err = exports.np_minigames:Start(src, 'drill', { pins = 5 }, function(result) ... end)
-- several in a row; stops at the first failure
local ok, results = exports.np_minigames:Chain(src, {
{ 'thermite', { difficulty = 'medium' } },
{ 'hexhack', { difficulty = 'hard' } },
}, { maxMove = 3 })
-- two or more players at once (np_banking's Pacific sync hack, for any game)
local ok, team = exports.np_minigames:Team({ src1, src2 }, 'hexhack', { window = 6 })
-- ox_lib lib.skillCheck shape
local ok = exports.np_minigames:SkillCheck(src, { 'easy', 'medium', 'hard' }, { 'w', 'a', 's', 'd' })
Play, Chain, Team and SkillCheck block the calling thread. Call them from a thread, for example inside a net
event handler (which already runs in one). Sessions a resource started are ended with api when it stops.
Client exports ​
These start local sessions: the puzzle is made and judged on the client. That's fine for crafting, repairs, emotes and other low-stakes gates, but a modified client can fake it. Anything that pays out should use the server exports or a profile.
| Export | Returns | |
|---|---|---|
Play(id, opts?) |
ok, result |
Yields |
PlayAsync(id, opts?, cb) |
token | nil, err |
cb(ok, result) |
Chain(steps, opts?) |
ok, results |
Yields |
SkillCheck(difficulty, inputs?) |
boolean |
Yields. lib.skillCheck drop-in |
PlayProfile(name, cosmetic?) |
ok, result |
Yields. The one client export that is server-validated, see Profiles |
Cancel() |
boolean |
|
IsActive() |
boolean, id |
|
GetGames() |
table[] |
|
OpenArcade() / CloseArcade() |
boolean |
The practice arcade |
local ok, result = exports.np_minigames:Play('skillcheck', { difficulty = 'easy', label = 'Tighten the bolts' })
exports.np_minigames:PlayAsync('lockpick', opts, function(ok, result) end)
local ok, results = exports.np_minigames:Chain({ { 'lockpick' }, { 'wires', { difficulty = 'hard' } } })
The client Play and PlayAsync take onProgress too (called on the client).
ox_lib SkillCheck drop-in ​
SkillCheck takes the same arguments as ox_lib's lib.skillCheck and plays np_minigames' skill ring:
-- before
if lib.skillCheck({ 'easy', 'easy', { areaSize = 60, speedMultiplier = 2 }, 'hard' }, { 'w', 'a', 's', 'd' }) then ... end
-- after (client, local)
if exports.np_minigames:SkillCheck({ 'easy', 'easy', { areaSize = 60, speedMultiplier = 2 }, 'hard' }, { 'w', 'a', 's', 'd' }) then ... end
-- or validated on the server
if exports.np_minigames:SkillCheck(src, { 'easy', 'medium' }, { 'e' }) then ... end
Each entry is one round: a difficulty name, or { areaSize, speedMultiplier } mapped onto the ring's zone and speed.
Replacing the old in-resource minigames ​
| Was | Now |
|---|---|
| np_banking robbery hack / thermite / drill | Play(src, 'hexhack' | 'thermite' | 'drill', { difficulty, ... }). Pacific terminals: Team({ a, b }, 'hexhack', { window = 6 }) |
np_prison NpPrison.SkillCheck({ rounds = { 'easy', 'medium' } }) |
server: SkillCheck(src, { 'easy', 'medium' }). Client-driven jobs: a profile (RegisterProfile, PlayProfile, Redeem). Low-stakes client gates: SkillCheck({ 'easy', 'medium' }, { 'E' }) |
| np_mechanic torque checks | Play(src, 'torque', { checks = 3, duration = 12000 }) |
| np_fishing cast / strike / fight | Play(src, 'power'), Play(src, 'strike'), Play(src, 'reel', { difficulty = 'hard', power = 7, stamina = 70 }). The difficulty is the fish class (light easy … monster expert) |
| np_drugs lab stages | Play(src, 'balance', { preset = 'simmer', seconds = 30 }). result.stats.care is the care share for purity |
| np_passwords code breaker | Play(src, 'crack', { length = 4 }). The passive original is { mode = 'auto' } |
| np_golf / np_darts / np_billiards skill inputs | swing, putt, sway, stroke |
| np_doors police raid (new in 1.2) | Play(src, 'ram', { difficulty = 'hard' }). Reinforced / vault doors: { difficulty = 'expert' }, or set the door yourself with { doorHp = 160, reinforced = true } (reinforced = 1.5 × doorHp). result.stats carries swings, hits, perfects, glances, weak, integrity, staminaMin and the per-swing stamina / damage curves |
| np_inventory lockpick roll | Play(src, 'lockpick', { difficulty = 'medium', item = { name = 'lockpick', remove = 'fail', chance = 0.35 } }). A failure with reason = 'broken' breaks the pick |
ox_lib lib.skillCheck |
exports.np_minigames:SkillCheck(...) |
How each np_* resource actually wires it up is on Integrations.