Get featured

FiveM server event security: source checks, fake payouts and heavy loops

Guide · checked against the docs on

A FiveM server that trusts the client for money, items or distance is one modified client away from a free payout. This guide walks through what the official Cfx docs say about events, source, waits and the profiler, plus practical review steps for AI-written resources.

This is a documentation review. Sources are docs.fivem.net pages whose titles were confirmed 2026-10-16, and native names matched in static.cfx.re data on the same date. It does not report a runtime test of any server or resource. No named resource or server is called vulnerable here.

FiveM, RedM, Rockstar Games and Cfx.re are named for identification only. ShipWithAI is not affiliated with, endorsed by or sponsored by Cfx.re, Rockstar Games or Take-Two Interactive.

For invented natives and framework exports, see AI invented a FiveM native? How to check it. For a broader scripting walkthrough, see How to make a FiveM script with AI.

Official pages used (titles confirmed 2026-10-16)

LinkPage title
https://docs.fivem.net/docs/scripting-manual/working-with-events/triggering-events/Triggering Events - Cfx Documentation
https://docs.fivem.net/docs/scripting-manual/working-with-events/listening-for-events/Listening for Events - Cfx Documentation
https://docs.fivem.net/docs/scripting-reference/events/server-events/Server Events - Cfx Documentation
https://docs.fivem.net/docs/scripting-reference/runtimes/lua/functions/Citizen.Wait/Citizen.Wait - Cfx Documentation
https://docs.fivem.net/docs/scripting-manual/debugging/using-profiler/Using the Profiler - Cfx Documentation

Docs.fivem.net can return HTTP 200 for missing pages. Do not trust the status code alone; confirm the page title before you cite a URL. The path /docs/scripting-manual/networking/events/ is an example that is not a real events guide.

Natives named in this guide

Client and server versions can share a display name but are different natives. That mix-up is a common AI mistake.

NativeHashSide
GET_PLAYER_PED (CFX)0x6E31E993server
GET_ENTITY_COORDS (CFX)0x1647F1CBserver (OneSync needed for reliable use, per pack notes)
GET_PLAYER_NAME (CFX)0x406B4B20server
DROP_PLAYER0xBA0613E1server
CANCEL_EVENT0xFA29D35Dshared
GET_INVOKING_RESOURCE0x4D52FE5Bshared
GET_PLAYER_PED (game)0x43A66C31C68491C0client
GET_ENTITY_COORDS (game)0x3FEF770D40960D5Aclient

The problem: the client can send anything

On the client, TriggerServerEvent sends an event to the server. On the server (or client), RegisterNetEvent marks an event as a network event you can listen for. (Triggering Events, Listening for Events, checked 2026-10-16)

Our advice, not a doc quote: a modified client can fire any registered net event with any arguments. A handler that trusts a client-sent amount is a free payout. Illustrative pattern only (not from a named resource):

-- BAD pattern (illustrative): amount comes from the client
RegisterNetEvent('shop:pay', function(amount)
    -- giving money or items from a client-chosen amount
end)

The fix is not "hide the event name". The fix is server-side validation of source and every argument.

Validate source on the server

The Listening for Events page states that in Lua the global source holds the player ID that triggered the event. Save it to a local variable, because after Wait the global source is reset. (source, checked 2026-10-16)

A practical pattern (our advice, built on that doc note):

  1. local src = source at the top of the handler
  2. Confirm the player still exists via your framework
  3. Type-check and range-check every argument
  4. Look up prices and item definitions on the server, never from the client payload
  5. Check distance with server GetPlayerPed and GetEntityCoords when the action is location-bound (OneSync)
  6. Add a cooldown so the same player cannot spam the event

DropPlayer is available for clear abuse. Treat kicking as a design choice for your server rules, not as a claimed best practice. (DROP_PLAYER)

This maps to FiveM prompt 06 Harden every server net event (free sample) and 07 Server-authoritative purchase (paid): the client sends only an item key; the server validates, looks up the price, checks balance, removes money, then gives the item, refunding if the give fails.

Review AI-written or third-party resources (guidance)

No official Cfx docs page on "backdoors" was located when this guide was checked (2026-10-16). The steps below are practical review guidance, not quotes from Cfx documentation.

  1. Read fxmanifest.lua and every file it lists
  2. Flag hardcoded webhook URLs, tokens and admin identifiers
  3. Flag obfuscated or remote-loaded code
  4. Check every net event the resource registers, using the source-validation pattern above

That review loop maps to FiveM prompt 10 Review an AI-written resource before you install it (paid): a GO/NO-GO gate with file:line findings.

Heavy loops and the profiler

The Citizen.Wait page shows a thread whose sleep defaults to 0 (per-frame) and increases when work is not needed, including an example that waits 1000 when idle. (source, checked 2026-10-16)

To measure hitch risk, the profiler docs describe profiler record with a frame count (500 is suggested there), then profiler status. Spikes in the recording are hitch candidates. (source, checked 2026-10-16)

Do not treat example millisecond numbers from prompts or forum posts as benchmarks. Use the profiler on your own resources.

This maps to FiveM prompt 12 Find and fix wasteful per-frame loops (paid), which uses client GetPlayerPed and GetEntityCoords for distance-based waits.

Free prompts for event hardening

The free FiveM Server Pack sample (prompts 01, 03 and 06, no email) includes 06 Harden every server net event, which is the showcase loop for this guide. Prompt 01 is the name-check loop from the invented natives guide. Prompt 03 audits fxmanifest.lua.

Docs links and native hashes checked 2026-10-16. Docs change, so re-check before relying on a signature or page path.

FiveM, RedM, Rockstar Games and Cfx.re are named for identification only. ShipWithAI is not affiliated with, endorsed by or sponsored by Cfx.re, Rockstar Games or Take-Two Interactive.