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
local won = exports['sd-computers']:RunHack(source, game, difficulty)| Parameter | Type | Description |
|---|---|---|
source | number | The player's server id |
game | string | A minigame key: maze, capture, cipher, snake, firewall, evasion, typing, signal, pipe, breakout |
difficulty | string? | '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
if exports['sd-computers']:RunHack(source, 'maze', 'hard') then
-- open the door
endConsumeHackProof
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
local info = exports['sd-computers']:ConsumeHackProof(source, proof, expect)| Parameter | Type | Description |
|---|---|---|
source | number | The player who played it |
proof | string | What StartHack returned on the client |
expect | table? | { game?, difficulty? }: insist on that game, and at least that difficulty |
Returns { game, difficulty, elapsed } for a good proof, or false.
Example
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))
endSystem 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
exports['sd-computers']:AddLog(computer, level, source, message, data)| Parameter | Type | Description |
|---|---|---|
computer | string | A computer's id (a location computer, or a placed one: placed_<n>), or '<id>@x,y,z' for one prop of a model computer |
level | string | 'information', 'warning', 'error', 'success' or 'failure' |
source | string? | The Source column, e.g. your resource's name. Default: the resource calling it |
message | string | The entry (512 characters at most) |
data | table? | Extra details, shown in the entry's detail pane |
Example
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
local result = exports['sd-computers']:SendMail(data)| Field | Type | Description |
|---|---|---|
to | string | string[] | One address, several separated by commas, or a list (20 at most). An address with no @ gets @lsmail.com (Domain) |
subject | string? | 200 characters at most |
body | string? | 10,000 characters at most |
from | table? | { name, email }. email with no @ gets the domain. Default: System, no-reply@lsmail.com |
Returns { success = boolean, delivered = string[] }: the addresses it reached.
Example
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
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
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
local computers = exports['sd-computers']:GetComputers()Returns a list of:
| Field | Type | Description |
|---|---|---|
id | string | The computer's id (placed_<n> for one from the panel) |
label | string | Its name |
hostname | string | Its machine name |
coords | vector3? | A location computer's or a placed computer's position |
model | string | string[]? | A model computer's prop model(s) |
placed | boolean? | true = made in the admin panel |
prop | string? | The prop a placed computer is |
world | boolean? | 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):
| Field | Type | Description |
|---|---|---|
title | string | The page's title (120 characters) |
kind | string? | The paper it is on: 'mail', 'statement' (letterhead), 'logs' (green-bar listing paper). Default 'custom', plain paper |
letterhead | string? | A letterhead line across the top |
subhead | string? | A line under the title |
fields | table? | { { label, value } }, up to 24 rows |
body | string? | The text (MaxChars, 20,000 by default) |
table | table? | { head = { ... }, rows = { { ... } } }, up to 8 columns and 200 rows |
image | string? | A picture address (https://...) |
footer | string? | A line at the bottom |
GetPrinters
Syntax
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
local ok, why = exports['sd-computers']:PrintAt(printerId, page, opts)| Parameter | Type | Description |
|---|---|---|
printerId | number | A printer's id, from GetPrinters |
page | table | The page (above) |
opts | table? | { 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
local ok, why = exports['sd-computers']:GivePrintout(source, page, opts)| Parameter | Type | Description |
|---|---|---|
source | number | The player's server id |
page | table | The page (above) |
opts | table? | { copies?, by?, from? }. by defaults to the player's name |
Returns true, or false and why: 'disabled', 'bad_page', 'inventory_full' or 'failed'.
Example
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.
AddEventHandler('sd-computers:server:breachCompleted', function(source, info)
-- info = { target = 'fleeca_ledger', computer = 'public_pc', instance = 'public_pc@123,-456,30' }
end)| Field | Description |
|---|---|
info.target | The target's id |
info.computer | The computer's id |
info.instance | The exact computer: for a model computer, '<id>@x,y,z' of the prop |
