Devices/Exports

Exports

Every server and client export and event.

Devices pages

See Apps for how they fit together, and Devices from Scripts for placing your own device.

Server Exports

ExportDescription
apiVersion()1
registerApp(def)true, or false, reason (printed once in the console). See the definition.
unregisterApp(id)Your own apps only.
appUser(source, appId)The gate for your server callbacks: ctx plus token and since while the player has your app open on a device or tablet now, else nil. Only the resource that registered the app gets an answer. A network app also gets nil while the player has no signal.
sendAppMessage(source, appId, message)Posts message (a table, at most 32 KB, 30 a second) into that player's app page; false, 'not_open' when it is not open.
notify(source, appId, notice)A notification for the player. See Notifications.
notifyDevice(deviceId, appId, notice)A notification for a laptop or computer.
closeApp(source, appId, reason)Closes your app for that player.
registerAccess(provider)Your own rule type in the panel's "who can use" editor. See your own rule type.
unregisterAccess(id)Removes your rule type.
accessChanged(providerId, value)Checks open windows again after a member list changed.
lookChanged()Asks again for the look of every terminal that shows one of your apps.
getApps()The registry, for debug.
devicesNear(coords, radius, kind)Placed devices near a point.
signalAt(coords, space)0 to 4 bars at a point (space 'b0' for the open world).
spawnDevice(def)Puts a laptop, computer or terminal into the world; id or nil, reason.
removeDevice(id)Takes away a device your resource placed.
moveDevice(id, coords, heading?)Moves a device your resource placed.
getDevice(id)What a device is, where it stands and who uses it now, or nil.
setOnlyApp(id, appId)Sets the one app of a laptop or computer your resource placed (nil clears it).
openTablet(source, { app, intent? })Lends the player the Evolent tablet for your app and opens it.
openAdmin(source, deviceId?)Opens the devices panel for that player, as /evdevices does; false when the player is not an admin or has no character loaded.

ctx

Lua
ctx = {
    app = 'hello',
    kind = 'laptop',
    device = { id = 12, label = 'Front desk', owner = 'ABC12345' }, -- nil on the tablet
    settings = {},                                                 -- what an admin set for your app on that device
    user = { source = 1, cid = 'ABC12345' },
}

cid is the character id of the framework: the citizenid on Qbox and QBCore, the identifier on ESX (up to 60 characters, with the multichar prefix such as char1:).

Server Events

Local only (AddEventHandler): clients cannot fake them.

EventArguments
evolent_devices:readyThe host started or restarted. Register your apps again.
evolent_devices:appOpenedsource, appId, ctx
evolent_devices:appClosedsource, appId, reason
evolent_devices:deviceOpenedsource, deviceId, info with info = { kind, label, temporary, resource, cid, name }
evolent_devices:deviceClosedsource, deviceId, reason

Client Exports

ExportDescription
sendAppMessage(appId, message)Into the open page of your app (at most 32 KB).
sendWatchMessage(deviceKey, appId, message)Into the watch copy a bystander is looking at (from appWatch).
isAppPost(appId, data)true when data came from your app page in this OS session.
answerAppPost(replyId, result)The answer to a relayed post.
isAppOpen(appId)Whether your app is open.
appSession(appId){ app, kind, device, token, context } or nil.
openApp(appId, intent)Opens your app on the device in use (or brings it up and sends the intent).
closeApp(appId)Closes your app.
leaveDevice()Leaves the device in use.
isUsingDevice()Whether the player is at a device.
openTablet({ app?, intent? })Takes the tablet out and opens an app. Use the server export to lend a tablet.
placeDevice({ kind, deviceId?, title?, accent? }, done)The admin placement camera for your script. See letting a player pick the spot.
studioCars(cars, paints)The cars your terminal page may show in the 3D studio.
placeItem, useTabletUsed by the inventory items. See Player Items.

Client Events

EventArguments
evolent_devices:appOpenedappId, session
evolent_devices:appClosedappId, reason
evolent_devices:appVisibleappId, visible (minimised, locked, no signal)
evolent_devices:appWatchappId, deviceKey, data: a bystander's screen shows your watch view
evolent_devices:appPostappId, name, data, replyId: a relayed post