Skip to content

Events, hooks & commands ​

Hooks ​

lua
-- veto or rewrite a start: return false, reason to refuse it
exports.np_minigames:RegisterHook('beforeStart', function(src, id, opts)
  if IsJailed(src) and id ~= 'skillcheck' then return false, 'jailed' end   -- Play returns false, { reason = 'jailed' }
end)

-- read-only: every server session that ends
exports.np_minigames:RegisterHook('afterResult', function(src, result, session) end)
Hook Arguments Return
beforeStart src, id, opts false, reason refuses the start (the caller gets false, { success = false, reason = reason })
afterResult src, result, session ignored (read-only)

A resource's hooks are removed when it stops.

Server events ​

All server-local (AddEventHandler, not net events):

Event Arguments
np_minigames:started src, gameId, invokingResource A server session opened
np_minigames:result src, result, invokingResource A server session ended, with the full result
np_minigames:progress src, p, gameId, invokingResource Cosmetic progress 0..100 (only when the caller asked for it, see Progress)
lua
AddEventHandler('np_minigames:result', function(src, result, invokingResource)
  if result.implausible then print(('%s sent an impossible %s answer'):format(GetPlayerName(src), result.game)) end
end)

Client events ​

Event Arguments
np_minigames:client:started gameId, meta A game opened on this client (server or local session)
np_minigames:client:result result Every game that ends on this client

meta is { label, title, sub, icon, tint, focus, cancelable, practice, assist, team, progress, profile, locale }.

Commands ​

Command Who What
/minigames Everyone Open or close the practice arcade (Config.Arcade.command, optional key mapping in Config.Arcade.key)

Staff send a game to a player from np_admin's player menu: Send a minigame (game id and difficulty; node np_minigames.send). The staff member gets the result as a toast.

Keys ​

Key Where Action
Esc A running game Give up (cancel), unless the caller set cancelable = false
Esc Arcade Close it
per game Game card Shown as key hints on the card: E, SPACE, A–D, W–S, arrows, 1–9 or the mouse, depending on the game. See the category pages (Hacking, Breach, Timing, Control, Sport, Search)

While a game runs it takes NUI focus: keyboard only for keyboard games, keyboard and cursor for mouse games.