Electron Documentation

Media Capture

Capture visual evidence from the player's perspective.

Exports need to always be invoked on ElectronAC, even if you renamed the resource.

Client-side

These exports are client-side only.

Taking Screenshots

Capture a screenshot of the player's screen and upload it to a specified endpoint.

exports["ElectronAC"]:screenshotPlayer(cb, url, field)

Prop

Type

Recording Player Gameplay

Record the player's screen for a specified duration and upload it to a specified endpoint.

exports["ElectronAC"]:recordPlayer(cb, url, field, duration)

Prop

Type

Recording Past Gameplay

Upload the last duration milliseconds of the player's gameplay, so you can capture what happened before something triggered your script (a report, a suspicious action, a death, ...).

exports["ElectronAC"]:recordPlayerPast(cb, url, field, duration)

Prop

Type

Requires Replays

Past recordings are taken from the replay buffer, so Replay must be enabled in your server settings on the panel. When replays are disabled, recordPlayerPast falls back to recordPlayer and records the next duration milliseconds instead.

A few things to keep in mind:

  • The clip always starts on a keyframe, so it can be up to ~10 seconds longer than the requested duration.
  • If the player hasn't been recording for duration yet (e.g. they just joined), you get everything recorded so far.
  • Replays are recorded at a maximum of 720p to keep the performance impact low.

Example Usage

Here is an example of how to use these exports to send media to a Discord webhook.

client.lua
-- Screenshot command
RegisterCommand("screenshot", function()
   exports["ElectronAC"]:screenshotPlayer( 
      function(data)
         print("Screenshot created, URL:", data.attachments[1].url)
      end,
      "YOUR_WEBHOOK_URL",
      "files[]"
   )
end, false)

-- Recording command (5 seconds)
RegisterCommand("recording", function()
   exports["ElectronAC"]:recordPlayer( 
      function(data)
         print("Recording created, URL:", data.attachments[1].url)
      end,
      "YOUR_WEBHOOK_URL",
      "files[]",
      5000
   )
end, false)

-- Past recording command (last 15 seconds)
RegisterCommand("clip", function()
   exports["ElectronAC"]:recordPlayerPast( 
      function(data)
         print("Clip created, URL:", data.attachments[1].url)
      end,
      "YOUR_WEBHOOK_URL",
      "files[]",
      15000
   )
end, false)

The callback is only invoked when the upload succeeds.

Discord Webhooks

When using Discord webhooks, ensure you use discordapp.com instead of discord.com.

https://discord.com/api/webhooks/... -> https://discordapp.com/api/webhooks/...

On this page