Skip to content

Client Exports ​

OpenComputer ​

Open a computer from another resource: a laptop item, a phone app, a scripted scene. The server still checks reach and the computer's job lock, so this grants nothing a player could not do at the desk.

Syntax

lua
local opened = exports['sd-computers']:OpenComputer(id, coords, opts)
ParameterTypeDescription
idstringA computer's id from configs/shared/computers.lua
coordsvector3?For a model computer: the prop's position. Left out, the player's own position is used (a laptop held in the hand). A location computer always opens at its config coordinates
optstable?{ style = 'modern' | 'retro' | 'mac' } forces a look for this open

Returns true when the computer was found and opened, false for an unknown id or one an admin removed in the panel.

The camera goes up to the prop's screen as it does from the target option. With no coordinates there is no prop to go to, and the desktop opens fullscreen.

Example

lua
-- A laptop item: open the business laptop computer where the player stands, in the retro look
exports['sd-computers']:OpenComputer('business_laptop', nil, { style = 'retro' })

-- A location computer opens at its own desk
exports['sd-computers']:OpenComputer('mrpd_frontdesk')

Placed computers

OpenComputer opens computers from computers.lua. A computer placed or picked in the admin panel (placed_<n>) is opened at its prop, from its own target option.

StartHack ​

Run one of the hacking minigames as a standalone hack.exe window, with no computer needed: a heist's door panel, a vault terminal. The run goes through the same server-verified pipeline as Command Prompt, and a win returns a proof that your server code redeems with ConsumeHackProof.

Syntax

lua
local won, proof = exports['sd-computers']:StartHack(opts)
local won, proof = exports['sd-computers']:StartHack(game, difficulty)
ParameterTypeDescription
opts.game / gamestringA minigame key: maze, capture, cipher, snake, firewall, evasion, typing, signal, pipe, breakout
opts.difficulty / difficultystring?'easy', 'medium' or 'hard'. Default DefaultDifficulty ('medium')
opts.titlestring?The window's title

Yields until the player wins, loses or closes the window. Returns won (boolean) and, on a win, proof (string). Only one run at a time: a second call while one is open returns false.

A standalone hack window, with no computer

Example

lua
-- client
local won, proof = exports['sd-computers']:StartHack({ game = 'pipe', difficulty = 'medium', title = 'Vault Door' })
if won then
    TriggerServerEvent('my-heist:server:openVault', proof)
end

-- server
RegisterNetEvent('my-heist:server:openVault', function(proof)
    local src = source
    local info = exports['sd-computers']:ConsumeHackProof(src, proof, { game = 'pipe', difficulty = 'medium' })
    if not info then return end -- no proof, someone else's, used, expired, or an easier run
    -- open the vault
end)

Never trust won on its own

won comes from the client. Always redeem the proof on the server before you give anything, or use RunHack, which does it for you.

A run from StartHack is not tied to a place: it proves the player won, not where they were. Check that on the server too. For swapping it into an existing robbery, and the other ways to use the minigames, see Hacks in Your Scripts.