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
idstringAny computer's id: from configs/shared/computers.lua, placed in the admin panel (placed_<n>), or added with AddComputer
coordsvector3?For a model computer: the prop's position. Left out, the player's own position is used (a laptop held in the hand). Every other computer opens at its own spot
optstable?{ style = 'modern' | 'retro' | 'mac' } forces a look for this open

Returns true when the computer was found (the server can still refuse it: too far, no access), 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 prop to go to, the desktop opens fullscreen. The server has the same export, to open a computer for a player from there: OpenComputer.

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')

CloseComputer ​

Close the computer this player has open: they were cuffed, a cutscene starts. They are signed out and logged off as if they shut it down. To close someone else's, or everyone's at one computer, use the server's CloseComputer.

Syntax

lua
local closed = exports['sd-computers']:CloseComputer()

Returns true when a computer was open, false when none was.

IsComputerOpen ​

Syntax

lua
local open = exports['sd-computers']:IsComputerOpen()

Returns true while this player has a computer open. GetCurrentComputer says which one.

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.

Custom Apps ​

SendCustomAppMessage, IsAppOpen and GetCurrentComputer, and the sd-computers:appOpened / sd-computers:appClosed events: see Custom Apps.