EN · $ USD
FiveM and Roleplay Servers

How to Set Up FiveM Discord Logs with Webhooks

7 min read Updated: OyunBulut technical team

In short

A FiveM Discord log system sends server-side events (joins and leaves, deaths, money transfers, admin commands) as JSON to Discord webhook URLs and keeps a record in separate channels. In a solid setup, webhooks are stored only server-side in convars defined with set, messages are queued and sent in batches, and the script backs off when it gets an HTTP 429 response.

In this guide
  1. What is a webhook, and why is it ideal for logging?
  2. Step 1: Create the webhooks in Discord
  3. Step 2: Store the URLs securely
  4. Step 3: A queued logging script
  5. Step 4: Hook up death, money and admin events
  6. Performance and scale
  7. What should a good log message include?
  8. Common mistakes
  9. Next step

A FiveM Discord log system automatically posts important events on your server as messages in Discord channels. Setup is simple: you create a webhook in Discord for each log channel, and a server-side Lua script sends JSON to that webhook URL whenever an event happens. In this guide, we build a system that logs joins and leaves, deaths, money transfers and admin commands to separate channels, stays under Discord's rate limit and doesn't leak your webhook URLs.

What is a webhook, and why is it ideal for logging?

A webhook is a unique URL Discord gives you so outside services can post messages to a channel. It doesn't need a bot account, a token or a persistent connection; the FiveM server posts a message with a single HTTP POST request. That makes it the lightest way to log.

Recommended channel layout:

  • #log-giris: players who connect and disconnect, plus the disconnect reason
  • #log-olum: deaths and the killer
  • #log-para: money transfers, bank transactions, large purchases
  • #log-admin: staff commands, bans and kicks

Put these channels in a category that only staff roles can see. Logs contain player identifiers and should not be public.

Step 1: Create the webhooks in Discord

  1. Open the log channel's settings and go to Integrations > Webhooks.
  2. Click New Webhook, give it a name (for example “Server Log”) and click Copy Webhook URL.
  3. Repeat for each channel. Four channels means four separate URLs.

Step 2: Store the URLs securely

A webhook URL works like a password: anyone who has it can post whatever they want to that channel, fake logs or flood the channel with spam. So instead of hardcoding the URLs in the script file, define them with set in server.cfg:

set log_webhook_giris "https://discord.com/api/webhooks/..."
set log_webhook_olum  "https://discord.com/api/webhooks/..."
set log_webhook_para  "https://discord.com/api/webhooks/..."
set log_webhook_admin "https://discord.com/api/webhooks/..."
ensure sunucu_log
  • Don't use setr; it replicates the variable to players.
  • Never put a webhook in a client script. Client files are downloaded to the player's PC and can be read.
  • If a URL leaks, delete the webhook in Discord and create a new one; the old URL stops working immediately.
  • Don't push your server.cfg file to a public Git repository.

Step 3: A queued logging script

When a webhook gets too many requests in a short time, Discord returns HTTP 429 Too Many Requests, and logs sent during that window are lost. On a busy server this happens easily when dozens of players connect at once after a restart. The fix is to queue logs and send them in batches of up to 10 embeds per message (Discord's per-message limit).

resources/[yerel]/sunucu_log/fxmanifest.lua:

fx_version 'cerulean'
game 'gta5'

server_script 'server.lua'

server.lua:

local WEBHOOKS = {
  giris = GetConvar('log_webhook_giris', ''),
  olum  = GetConvar('log_webhook_olum', ''),
  para  = GetConvar('log_webhook_para', ''),
  admin = GetConvar('log_webhook_admin', ''),
}

local queues = {}

local function clean(text)
  -- neutralizes mentions like @everyone and markdown
  return (tostring(text):gsub('[@`*_~|]', ''))
end

function SendLog(channel, title, description, color)
  queues[channel] = queues[channel] or {}
  table.insert(queues[channel], {
    title = title,
    description = description,
    color = color or 3447003,
    timestamp = os.date('!%Y-%m-%dT%H:%M:%SZ'),
  })
end
exports('SendLog', SendLog)

CreateThread(function()
  while true do
    Wait(2500)
    for channel, list in pairs(queues) do
      local url = WEBHOOKS[channel]
      if url and url ~= '' and #list > 0 then
        local batch = {}
        for i = 1, math.min(10, #list) do
          batch[i] = table.remove(list, 1)
        end
        local payload = json.encode({
          username = 'Sunucu Log',
          embeds = batch,
          allowed_mentions = { parse = {} },
        })
        PerformHttpRequest(url, function(status)
          if status == 429 then
            for i = #batch, 1, -1 do
              table.insert(list, 1, batch[i])
            end
          end
        end, 'POST', payload, { ['Content-Type'] = 'application/json' })
      end
    end
  end
end)

local function ids(src)
  local out = {}
  for _, id in ipairs(GetPlayerIdentifiers(src)) do
    if id:sub(1, 3) ~= 'ip:' then
      out[#out + 1] = id
    end
  end
  return table.concat(out, ' | ')
end

AddEventHandler('playerJoining', function()
  local src = source
  SendLog('giris', 'Oyuncu bağlandı',
    ('%s (ID %d)  %s'):format(clean(GetPlayerName(src)), src, ids(src)), 3066993)
end)

AddEventHandler('playerDropped', function(reason)
  local src = source
  SendLog('giris', 'Oyuncu ayrıldı',
    ('%s (ID %d)  Sebep: %s'):format(clean(GetPlayerName(src)), src, clean(reason)), 15158332)
end)

The script includes two important safeguards: because allowed_mentions is left empty, a player with “@everyone” in their name can't ping the whole server, and ip: identifiers are filtered out. Posting IP addresses to Discord is unnecessary and risky from a personal data standpoint.

Step 4: Hook up death, money and admin events

Because the logging script exports the SendLog function, other resources can call it with a single line.

Money transfers

Add the money log inside the server-side function where the transaction actually happens, right after the balance changes. For example, in your bank transfer event:

exports['sunucu_log']:SendLog('para', 'Banka transferi',
  ('%s → %s: %d $'):format(GetPlayerName(src), GetPlayerName(hedef), miktar), 15844367)

Logging an event where the client claims “I sent money” is misleading; write the log only after server-side validation and after the balance has actually been deducted.

Deaths

The baseevents resource relays death information from the client to the server. Because this data comes from the client, a cheater can spoof it; treat death logs as a starting point for an investigation, not as proof. If your framework has a death event that it validates server-side, use that instead.

Admin commands

In staff commands you write yourself, add a log line after the permission check:

RegisterCommand('paraver', function(src, args)
  if not IsPlayerAceAllowed(src, 'komut.paraver') then return end
  local hedef, miktar = tonumber(args[1]), tonumber(args[2])
  -- ... give money logic ...
  exports['sunucu_log']:SendLog('admin', 'Para verildi',
    ('%s → ID %s: %s $'):format(GetPlayerName(src), args[1], args[2]), 10181046)
end, false)

For bans, kicks and warnings issued through txAdmin, you can also use txAdmin's own Discord bot integration and action history. For permission definitions, check out the ACE permissions guide.

Performance and scale

Thanks to the queue, the logging script doesn't fire a network request on every event; it sends a batch every few seconds and doesn't block the server thread. Still, monitor the script's time with resmon; for details, see the script optimization with resmon article. When log volume gets very large, for example if you want to record every inventory move, it's healthier to write logs to a database and send only critical events to Discord.

Some servers send logs to a separate Discord bot instead of straight to a webhook; the bot filters logs, offers a search command and archives to a database if needed. Running that kind of log bot on a Discord Bot VDS, independent of the game server, keeps your logging infrastructure up while the game server restarts.

What should a good log message include?

A log message is only as valuable as how quickly it answers questions when staff investigate a report. Include these four pieces of information in every log line:

  • Who: Player name, server ID and a permanent identifier (license: or discord:). Player names can be changed in-game; identifiers can't.
  • What: The type and amount of the action; for money logs, the source and destination accounts.
  • Where: Coordinates or an area name if needed. Very useful when you suspect teleporting.
  • When: The embed's timestamp field displays correctly in each viewer's own time zone in Discord.

Use colors meaningfully, too: a fixed scheme like green for joins, red for leaves, yellow for money and purple for admin actions makes a busy channel easy to scan. Setting a separate threshold for large transfers and also sending those to a “suspicious transactions” channel is a practical way to catch money duplication exploits early.

Common mistakes

  • No logs arrive: The convar name must match the name in GetConvar exactly, and the ensure sunucu_log line must come after the convars.
  • Some logs go missing: Scripts without a queue that send a request on every event drop the message when they get a 429 response.
  • Unknown messages in the channel: Your webhook URL has leaked; delete the webhook and create a new one.
  • The embed looks empty: The description field may be over Discord's limit; shorten long text.

Next step

The log system is the memory of a growing roleplay server, and it pays off most during peak hours when staff are working through reports. You can run your server on the OB-FIVEM-3 FiveM server at OyunBulut's Istanbul location with 4 CPU cores, 6 GB DDR5 RAM and DDoS protection, and move your log and application bots to a separate Discord Bot VDS to leave game resources for your players.

Frequently asked questions

Should I use a webhook or a bot for FiveM logs?

For simple logging, a webhook is enough and is the lightest option. If you want search, filtering or archiving, a log bot running on a separate server is more flexible.

My webhook URL leaked. What should I do?

Delete the webhook in the Discord channel settings and create a new one; the old URL stops working immediately. Define the new URL only in server.cfg with set.

Why don't some logs show up in Discord?

If Discord receives too many requests in a short time, it returns a 429 response, and scripts without a queue lose that message. Queuing logs and sending them in batches solves this.

Should I show player IP addresses in logs?

It's not recommended. An IP address is personal data, and posting it to a Discord channel creates unnecessary risk; the license or discord identifier is enough for investigations.

Can death logs be used as proof of cheating?

Client-sourced death events like baseevents can be spoofed, so they shouldn't count as proof on their own; use them as a starting point for an investigation.

For this guide

Recommended plans

For a roleplay server running log, whitelist and application systems, OB-FIVEM-3's 4 CPU cores and 6 GB DDR5 RAM give you a balanced foundation; keep your log bot independent of the game server on a Discord Bot VDS.

OB-FIVEM-3

Recommended

6 GB DDR5 RAM

$15.73/mo

+VAT

  • Processor4 CPU
  • Disk60 GB NVMe
  • LocationIstanbul
  • DDoS
  • Automatic Setup

2 GB RAM

$1.96/mo

+VAT

  • Processor2 vCPU
  • ModelAMD Ryzen / Intel
  • Disk30 GB NVMe
  • LocationIstanbul
  • Port: 1G Port
  • Traffic: Fair use
  • Virtualization: KVM
  • Multi-layer DDoS protection

3 GB RAM

$2.26/mo

+VAT

  • Processor4 vCPU
  • ModelAMD Ryzen / Intel
  • Disk35 GB NVMe
  • LocationIstanbul
  • Port: 1G Port
  • Traffic: Fair use
  • Virtualization: KVM
  • Multi-layer DDoS protection

FiveM — tüm paketler Discord Bot VDS — tüm paketler

Need help with setup?

Send questions about your service in a support ticket, and our technical team will walk you through it step by step.