Skip to main content

FiveM event validation: review the action before the reward

Written by FiveMCoach · AI-assisted editorial guide; official sources checked

Last updated

FiveM event validation: a developer review checklist

An evergreen developer checklist for reviewing one networked action from input to final write, checked against official Cfx.re documentation.

Quick answer

Review a FiveM server event by following one requested action from its inputs to its final write. Establish who may call it, validate the relevant state on the server, and test invalid and repeated requests. A hidden client menu is not an authorization boundary.

On this page

What does the official event guidance establish?

This is an evergreen engineering checklist, checked against Cfx.re documentation on 11 September 2026. It does not announce a new vulnerability or claim that a particular resource is exploitable.

Cfx.re distinguishes local handlers from networked events and recommends server-side checks for valuable actions. Client-controlled input should not determine permissions, inventory changes or a payout without validation. Read Secure Your Events.

The event-listening reference also warns that the global source value is only reliable for the initial event call. In Lua or JavaScript, keep the caller in a local variable before a wait or asynchronous continuation. Read Listening for Events.

Where should a developer start the review?

Choose one valuable action, such as completing a delivery. Write its intended result in a sentence before reading every handler in the resource. An example contract is: an eligible player can complete an active delivery once and receive the reward assigned to that delivery.

Next, trace the actual call path. Name the client input, the server lookup, the decision and the final data change. Mark which values come from the caller and which come from state your server controls. If a helper hides the final inventory or account write, follow that helper too. This is a proposed review method, not a description of a specific framework API.

Do not begin by adding checks at random. First identify which business rule each check protects, then give it a rejection case. A numeric field being well formed does not establish that its value is allowed for the requested action.

How do you test rejection without risking a live economy?

Use an isolated development server and disposable test records. Write down the initial balance or inventory state and the result expected from each test. Exercise missing fields, wrong types, an ineligible player and an action that no longer exists. After rejection, check the stored state as well as the response.

Add a repeated-request case to your plan. Decide whether the second request should report that the action is complete or return a harmless rejection. The important observable result is that one completed action does not produce a second reward. Implement the state transition with the consistency guarantees your storage and framework provide.

Keep this testing limited to systems you own or have permission to assess. There is no need to probe someone else's server to evaluate your handler.

What changes when the handler waits for another service?

Preserving a caller variable is necessary for the documented source-lifetime issue, but it is not a complete transaction design. Our recommendation is to review whether the player session and action are still valid when the asynchronous work returns. A request that was eligible before a wait may no longer be eligible afterwards.

Document what happens when a lookup fails, a dependency times out or the caller disconnects. Do not report a successful reward until the authoritative write succeeds. If your framework splits inventory and payment across separate operations, review partial failure explicitly rather than assuming both completed.

What should go in the release review?

Attach a small result table to the change: scenario, expected state, actual state and the version tested. Keep unresolved cases visible. This article is a review plan; it does not supply a production handler or claim that these tests have already run on your resource.

Use the framework comparison to keep framework assumptions explicit, and the server fix order when an event problem is part of a wider operational issue.

Checklist
  • Name the action and its allowed final state.
  • Trace the caller's input to the authoritative write.
  • Identify the permission and current-state checks.
  • Preserve caller context before asynchronous work.
  • Test rejection, repetition and partial failure on an isolated server.
  • Record actual results before claiming the resource passed.
Review case Result to verify
Valid action by an eligible test player Exactly the intended state change
Wrong type or missing required input Rejection with no data change
Action already completed No second reward
Dependency failure No false success and a defined recovery path
Caller disconnects during a wait No result attributed to another session
Common mistakes

A check can be present and still protect the wrong rule. For example, accepting a positive number does not show that it is the configured reward for this action. Another mistake is testing only the message shown to the player while never inspecting the stored balance, inventory or completion record after a rejected request.

FiveMCoach perspective

For a small resource, a review of one complete action is often easier to reason about than a long list of unrelated guard clauses. Keep the contract, state transition and rejection evidence together. Expand the review to the next valuable action only when the first one has an understandable success path and recovery behavior.

Does hiding a menu make a server event safe?
No. The server still needs to decide whether the caller is allowed to perform the action and whether the current state permits it.
Why copy source before a Lua wait or JavaScript await?
Cfx.re documents the global source value as valid for the initial event call. Keep a local reference before asynchronous work and review session validity separately.
Is this a copy-and-paste secure reward handler?
No. It is a review checklist. The final implementation depends on your framework, storage guarantees and the action's rules.

Ready for the next step?

Stop guessing. Get a concrete plan for your server and move with confidence.

Written by
FiveMCoach · AI-assisted editorial guide; official sources checked
A FiveMCoach contributor responsible for this guide's visible content.