Skip to content

Server Exports ​

Hacking ​

RunHack ​

Run a hacking minigame on a player from the server and get a verified result. The simplest way to put a hack in front of something: the server asks the player's client to play, and redeems the proof itself.

Syntax

lua
local won = exports['sd-computers']:RunHack(source, game, difficulty)
ParameterTypeDescription
sourcenumberThe player's server id
gamestringA minigame key: maze, capture, cipher, snake, firewall, evasion, typing, signal, pipe, breakout
difficultystring?'easy', 'medium' or 'hard'. Default DefaultDifficulty ('medium')

Yields until the player wins, loses or quits. Returns true only for a verified win at that game and difficulty, and false straight away if that player already has a hack window open. A run is not tied to a place, so check where the player is yourself. See Hacks in Your Scripts for the ways to put a hack into a robbery.

Example

lua
if exports['sd-computers']:RunHack(source, 'maze', 'hard') then
    -- open the door
end

ConsumeHackProof ​

Redeem the proof a client got from StartHack. One-shot: a proof works once, only for the player who played it, and expires after ProofTTL (120 seconds).

Syntax

lua
local info = exports['sd-computers']:ConsumeHackProof(source, proof, expect)
ParameterTypeDescription
sourcenumberThe player who played it
proofstringWhat StartHack returned on the client
expecttable?{ game?, difficulty? }: insist on that game, and at least that difficulty

Returns { game, difficulty, elapsed } for a good proof, or false.

Example

lua
local info = exports['sd-computers']:ConsumeHackProof(source, proof, { game = 'pipe', difficulty = 'medium' })
if info then
    print(('won %s on %s in %.1fs'):format(info.game, info.difficulty, info.elapsed))
end

System Logs ​

AddLog ​

Write an entry to a computer's System Logs (Event Viewer), e.g. a door script logging "Vault door opened" to the security office's PC.

Syntax

lua
exports['sd-computers']:AddLog(computer, level, source, message, data)
ParameterTypeDescription
computerstringA computer's id (a location computer, or a placed one: placed_<n>), or '<id>@x,y,z' for one prop of a model computer
levelstring'information', 'warning', 'error', 'success' or 'failure'
sourcestring?The Source column, e.g. your resource's name. Default: the resource calling it
messagestringThe entry (512 characters at most)
datatable?Extra details, shown in the entry's detail pane

Example

lua
exports['sd-computers']:AddLog('mrpd_frontdesk', 'warning', 'sd-doors', 'Evidence locker opened', { by = 'Officer Hale' })

Mail ​

While the sd-phone link has Mail on, these work on the phone's mailboxes (the ones players actually read) instead of the built-in ones.

SendMail ​

Send a system or NPC mail: job offers, statements, heist intel. No sent copy is kept and nothing bounces.

Syntax

lua
local result = exports['sd-computers']:SendMail(data)
FieldTypeDescription
tostring | string[]One address, several separated by commas, or a list (20 at most). An address with no @ gets @lsmail.com (Domain)
subjectstring?200 characters at most
bodystring?10,000 characters at most
fromtable?{ name, email }. email with no @ gets the domain. Default: System, no-reply@lsmail.com

Returns { success = boolean, delivered = string[] }: the addresses it reached.

Example

lua
exports['sd-computers']:SendMail({
    to = 'jessica.hale@lsmail.com',
    subject = 'Shift starts',
    body = 'See you at 8.',
    from = { name = 'LSPD HR', email = 'hr' },
})

MailAddressExists ​

Syntax

lua
local exists = exports['sd-computers']:MailAddressExists(email)

Returns true when the address exists.

GetMailAddresses ​

The addresses a character is signed into, e.g. to mail them a reward.

Syntax

lua
local addresses = exports['sd-computers']:GetMailAddresses(citizenid)

Returns a list of addresses (string[]).

Computers ​

GetComputers ​

Every computer: the ones from the config and the ones made in the admin panel. A config computer an admin removed in the panel is left out.

Syntax

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

Returns a list of:

FieldTypeDescription
idstringThe computer's id (placed_<n> for one from the panel)
labelstringIts name
hostnamestringIts machine name
coordsvector3?A location computer's or a placed computer's position
modelstring | string[]?A model computer's prop model(s)
placedboolean?true = made in the admin panel
propstring?The prop a placed computer is
worldboolean?true = a prop the game already had there, picked in the panel

Printing ​

A page is a table. Only title is required, plus something under it (body, fields, table or image):

FieldTypeDescription
titlestringThe page's title (120 characters)
kindstring?The paper it is on: 'mail', 'statement' (letterhead), 'logs' (green-bar listing paper). Default 'custom', plain paper
letterheadstring?A letterhead line across the top
subheadstring?A line under the title
fieldstable?{ { label, value } }, up to 24 rows
bodystring?The text (MaxChars, 20,000 by default)
tabletable?{ head = { ... }, rows = { { ... } } }, up to 8 columns and 200 rows
imagestring?A picture address (https://...)
footerstring?A line at the bottom

GetPrinters ​

Syntax

lua
local printers = exports['sd-computers']:GetPrinters()

Returns { id, label, coords }[], every printer, by id.

PrintAt ​

Print a page at a printer. It waits in the tray like any other print.

Syntax

lua
local ok, why = exports['sd-computers']:PrintAt(printerId, page, opts)
ParameterTypeDescription
printerIdnumberA printer's id, from GetPrinters
pagetableThe page (above)
optstable?{ copies?, by?, from?, citizenid? }: how many, and who and which machine the tooltip says printed it

Returns true, or false and why: 'disabled', 'no_printer', 'bad_page', 'tray_full' or 'failed'.

GivePrintout ​

Put a printed page straight into a player's inventory, with no printer in between.

Syntax

lua
local ok, why = exports['sd-computers']:GivePrintout(source, page, opts)
ParameterTypeDescription
sourcenumberThe player's server id
pagetableThe page (above)
optstable?{ copies?, by?, from? }. by defaults to the player's name

Returns true, or false and why: 'disabled', 'bad_page', 'inventory_full' or 'failed'.

Example

lua
exports['sd-computers']:GivePrintout(source, {
    title = 'Vehicle Release',
    letterhead = 'Los Santos Police Department',
    fields = {
        { label = 'Plate', value = '46EEK572' },
        { label = 'Released to', value = 'Jessica Hale' },
    },
    body = 'This vehicle may be collected from the Mission Row impound lot.',
    footer = 'Form LSPD-114',
}, { by = 'Officer Hale', from = 'Records' })

Events ​

breachCompleted ​

Fired on the server after every successful breach, once the reward is paid. Each target can also name an event of its own (reward.event), fired with the same arguments.

lua
AddEventHandler('sd-computers:server:breachCompleted', function(source, info)
    -- info = { target = 'fleeca_ledger', computer = 'public_pc', instance = 'public_pc@123,-456,30' }
end)
FieldDescription
info.targetThe target's id
info.computerThe computer's id
info.instanceThe exact computer: for a model computer, '<id>@x,y,z' of the prop