Nexus Minigames

API & brug

Exports, options og eksempler til robbery, crafting og hacking.

Alle exports er client-side og returnerer boolean (success) når spillet er slut — undtagen Stop / IsPlaying / List*.

Play (anbefalet)

-- Preset
local ok = exports['nexus-minigames']:Play('lockpick')

-- Med difficulty + ekstra NUI
local ok = exports['nexus-minigames']:Play('hacking', {
    difficulty = 'hard',
    nui = { time = 5000 },
})

-- Råt spil-id virker også hvis det findes i Config.Games
local ok = exports['nexus-minigames']:Play('memory', {
    difficulty = 'easy',
    cursor = true,
})

Start (råt spil)

local ok = exports['nexus-minigames']:Start('cableConnect', {
    -- nui options til Vue-spillet
}, {
    cursor = true,
    animation = { scenario = 'WORLD_HUMAN_HAMMERING' },
})

Stop & status

if exports['nexus-minigames']:IsPlaying() then
    exports['nexus-minigames']:Stop()
end

Lister

local presets = exports['nexus-minigames']:ListPresets()
-- { { id = 'lockpick', game = 'lockpick', label = 'Dirke lås' }, ... }

local games = exports['nexus-minigames']:ListGames()
-- { 'arrowClicker', 'lockpick', 'codeFind', ... }

Eksempel — butiksdirk

RegisterNetEvent('myshop:client:lockpick', function()
    local ok = exports['nexus-minigames']:Play('lockpick', { difficulty = 'medium' })
    if ok then
        TriggerServerEvent('myshop:server:unlock')
    else
        -- fail / cancel
    end
end)

Eksempel — crafting

local ok = exports['nexus-minigames']:Play('shake', { difficulty = 'easy' })
if not ok then return end
-- fortsæt craft-flow

Kun client

Kald aldrig Play/Start fra server. Valider success server-side efter et authenticated client-event hvis belønningen betyder noget.