Start a game from your script#
Call the exports on the client, inside a thread. Check IsBusy() first, then check the result on your server before you give anything out.
CreateThread(function()
if exports['glitch-minigames']:IsBusy() then return end
local result = exports['glitch-minigames']:StartLockpickGame(3, 30, 2, 40, 500)
local won = result == true or (type(result) == 'table' and result.success == true)
if won then
TriggerServerEvent('myresource:lockpicked')
end
end)
Most games return true or false. StartVerbalMemoryGame returns { success, score, strikes }, and a Zero day skip returns plain true, so the check above covers both.
Per-call style and XP options#
Any export takes an optional table as its last argument. It changes that one game only.
exports['glitch-minigames']:StartPairsGame(4, 60000, 0, {
colour = 'cyan', -- or a table such as { primary = '#ff3355' }
theme = 'tablet', -- panel look
keybinds = 'device', -- keycap HUD look
sounds = 'classic', -- sound set
xp = false, -- no XP, perks or retries for this call
noSkip = true, -- never offer the Zero day skip
})
Pass { xp = false } from jobs and everyday actions that use a game but should not give hacking XP. Circle Click needs { xp = true } to give XP:
exports['glitch-minigames']:StartCircleClickGame(5, 1, 45, 3, 0.15, true, { 'W', 'A', 'S', 'D' }, 1, { xp = true })
Settings-table games#
Shape Recall, Memory Diff, Traceroute and Carrier Tune take one settings table. preset picks easy, normal, nopixel or hard, and any other key overrides that preset.
local won = exports['glitch-minigames']:StartShapeRecallGame({ preset = 'hard', rounds = 5 }, { theme = 'tablet' })
local won2 = exports['glitch-minigames']:StartTracerouteGame({ preset = 'easy', ttl = 50000 })
Drills#
-- Fleeca drill, or a jackhammer with { anim = 'jackhammer' }
local drilled = exports['glitch-minigames']:StartDrilling({ anim = 'jackhammer' })
-- Plasma drill, difficulty 1 to 10 (default 5)
local cut = exports['glitch-minigames']:StartPlasmaDrilling(7)
-- Callback form: the export still waits, returns nil and passes the result to the callback
exports['glitch-minigames']:StartPlasmaDrilling(7, function(success)
print('plasma drill', success)
end)
Server-checked XP#
The safest setup gives XP only from your own server code. Set config.XP.ClientReported = false, then award XP after your server has checked the result:
-- server
RegisterNetEvent('myresource:hackDone', function()
local src = source
-- your own checks here: distance, job, item, cooldown...
exports['glitch-minigames']:AwardXP(src, 'StartBruteForce', true)
end)
Or keep client-reported XP and set config.XP.RequireServerSession = true. Open a session when the player reaches a real hack:
-- server, when the player starts a real hack
exports['glitch-minigames']:OpenXPSession(source, 'StartBruteForce', 90)
-- server, if the hack is aborted
exports['glitch-minigames']:CloseXPSession(source, 'StartBruteForce')
Timed hacking buff#
A consumable or buff can make timed games last longer while it is active. The value is a share from 0 to 0.5:
-- server
Player(src).state:set('hackTimeBonus', 0.05, true) -- 5% longer
Player(src).state:set('hackTimeBonus', nil, true) -- buff over
Show the controls HUD for your own script#
TriggerEvent('glitch-minigames:controlsPanel', 'Heist editor', {
{ keys = { 'Q' }, label = 'Look around' },
})
TriggerEvent('glitch-minigames:controlsPanel', nil) -- hide
The event is ignored while a game runs.
Translate a string#
config.Text = {
['Cancel'] = 'Annuler',
['Backdoor open - one more try'] = 'Porte derobee ouverte - encore un essai',
}