Exports & API
MBT Minigames exposes two client-side exports that cover all use cases.
startHackingSession(data)
Opens the Hacking minigame (Terminal Node Decryption).
local won = exports['mbt_minigames']:startHackingSession({
difficulty = "Medium", -- "Easy" | "Medium" | "Hard" (optional)
time = 40, -- override time limit in seconds (optional)
params = { -- override individual difficulty params (optional)
sequenceLength = 6,
maxMistakes = 3,
},
onSuccess = function() print("Access granted!") end,
onFail = function() print("Access denied.") end,
animation = { }, -- custom animation table (optional — see below)
})
-- won = true if player succeeded, false if failed or timed outParameters
| Key | Type | Description |
|---|---|---|
difficulty | string | "Easy" / "Medium" / "Hard". Falls back to MBT.DefaultDifficulty. |
time | number | Override the time limit in seconds. |
params | table | Override specific difficulty keys (see Configuration for available keys). |
onSuccess | function | Called immediately when the player wins. |
onFail | function | Called immediately when the player loses or times out. |
animation | table | Full animation override. Pass false to skip animation entirely. |
Return Value
Returns true if the player won, false if they lost or timed out. The function yields (blocks) until the minigame ends.
startRepairSession(data)
Opens any of the four minigames by type.
local won = exports['mbt_minigames']:startRepairSession({
type = "bolt_turn", -- required
difficulty = "Hard",
time = 60,
params = { boltCount = 5 },
onSuccess = function() print("Repaired!") end,
onFail = function() print("Failed.") end,
})Parameters
| Key | Type | Description |
|---|---|---|
type | string | Required. "hacking" / "wire_fix" / "bolt_turn" / "code_match" |
difficulty | string | "Easy" / "Medium" / "Hard". Falls back to MBT.DefaultDifficulty. |
time | number | Override the time limit in seconds. |
params | table | Override specific difficulty keys for the chosen type. |
onSuccess | function | Called immediately when the player wins. |
onFail | function | Called immediately when the player loses or times out. |
animation | table | Full animation override. Pass false to skip animation entirely. |
Return Value
Returns true if the player won, false if they lost or timed out. The function yields until the minigame ends.
cancelSession()
Aborts the minigame currently in progress — useful when the player walks away, is interrupted, or the calling resource needs to bail out. The active session cleans up its animation and props, and the original start*Session call returns false. No-op if nothing is running.
exports['mbt_minigames']:cancelSession()A player dying mid-minigame is detected automatically and ends the session the same way — you don't need to call this on death.
Overridable params Keys by Type
hacking
| Key | Type | Description |
|---|---|---|
sequenceLength | number | Number of codes to click (4–8) |
maxMistakes | number | Wrong clicks allowed before failure |
wire_fix
| Key | Type | Description |
|---|---|---|
wireCount | number | Number of wires to route (4–6) |
bolt_turn
| Key | Type | Description |
|---|---|---|
boltCount | number | Number of bolts to tension (3–5) |
heatSpeed | number | Heat build rate multiplier |
maxMistakes | number | Overheat events allowed before failure |
code_match
| Key | Type | Description |
|---|---|---|
segmentCount | number | Codes to match (6–10) |
shiftSpeed | number | Milliseconds between stream shifts |
maxMistakes | number | Missed codes allowed before failure |
Animation Override
Both exports accept a custom animation table. You can override the entire animation or specific fields:
exports['mbt_minigames']:startRepairSession({
type = "hacking",
animation = {
Dict = "anim@heists@ornate_bank@hack",
Enter = "hack_enter",
Loop = "hack_loop",
Exit = "hack_exit",
EnterTime = 1500,
Props = {
{ Model = "hei_prop_hst_laptop", Bone = 28422, Offset = vector3(0,0,0), Rot = vector3(0,0,0) },
},
},
})Pass animation = false to skip the animation entirely (minigame opens immediately without ped animation).
Debug Commands
Available only when MBT.Debug = true in config.lua.
| Command | Description |
|---|---|
/testminigame [type] [difficulty] | Open any minigame directly in-game |
/testscene [type] | Play the animation sequence only (15 seconds), no game |
Examples:
/testminigame hacking Easy
/testminigame bolt_turn Hard
/testscene wire_fix
/testscene code_matchValid types: hacking, wire_fix, bolt_turn, code_match
Valid difficulties: Easy, Medium, Hard
Disable MBT.Debug on production servers. Debug commands are available to all players when enabled.
Integration Example
Full example integrating MBT Minigames into a custom hacking script:
-- In your resource's client.lua
local function attemptHack(callback)
local won = exports['mbt_minigames']:startRepairSession({
type = "hacking",
difficulty = "Hard",
time = 25,
params = { sequenceLength = 7, maxMistakes = 2 },
onSuccess = function()
TriggerServerEvent("myScript:hackSuccess")
end,
onFail = function()
TriggerServerEvent("myScript:hackFail")
end,
})
if callback then callback(won) end
end