Skip to main content
Server events are messages that Zyra Store scripts emit in the FiveM server environment. Unlike client events, these are processed on your server and allow you to react to player actions, data synchronizations, or administrative events from your server’s central logic. To subscribe to any Zyra Store server event, use AddEventHandler from a server-side file in your resource. The event name always follows the pattern zyra:sv_eventName. An important particularity of server events in FiveM is the global source variable, which is automatically available inside the callback and contains the server ID of the player who originated the event. Always use it to identify and validate the involved player.
other-resource/server.lua

Event reference

Fires when a player’s data has been correctly registered on the server by the script. It is the right time to initialize information for that player in your own systems.Parameters
number
required
The FiveM server ID of the player who connected. Use it to identify the player in all native server calls.
string
required
The player’s unique license identifier (for example, license:a1b2c3d4...). Use it to associate the player with records in your database.
Example
other-resource/server.lua
Fires on the server every time a player performs an action tracked by the script. Use it to log actions, validate operations, or apply server-side business logic.Parameters
number
required
The FiveM server ID of the player who performed the action.
string
required
The name of the performed action, for example "purchase", "interact", or "use_item".
table
required
A table with information specific to the action. The content varies depending on the action value.
Example
other-resource/server.lua
Fires when an administrator executes a privileged command through the script. Ideal for building audit systems or logging sensitive administrative actions.Parameters
number
required
The server ID of the administrator who executed the command.
string
required
The name of the executed administrative command (for example, "kick", "ban", "give_item").
number | nil
The server ID of the player target of the command, if applicable. Will be nil if the command has no player target.
Example
other-resource/server.lua
Fires when the script synchronizes a player’s data across the server. You can use this event to keep your own systems updated with the player’s most recent data.Parameters
number
required
The FiveM server ID of the player whose data is being synchronized.
table
required
The synchronized data object. Contains the updated player information as managed internally by the script.
Example
other-resource/server.lua
Fires when the Zyra Store script resource starts correctly. It is the ideal time to initialize database connections, caches, or data structures that your integration needs.ParametersThis event receives no action parameters. In the context of server events without an originating player, source will have the value 0 (which represents the server itself).Example
other-resource/server.lua
Fires when the Zyra Store script resource is about to stop. Take advantage of this event to save pending data, clean up active timers, and release resources correctly.ParametersThis event receives no parameters. Like zyra:sv_onResourceStart, source will be 0.Example
other-resource/server.lua

Security in server events

Server events are the core of your application’s logic and must be handled with care. Follow these practices to keep your server secure: Always validate source. Never blindly trust the player ID you receive. Verify that the player exists and has the necessary permissions before processing any action.
other-resource/server.lua
Never trust data coming from the client. Although Zyra Store server events are emitted internally by the script, any data that eventually comes from the client must be validated and sanitized before being used in database queries or other critical operations. Verify permissions before processing administrative actions. Even if the zyra:sv_onAdminAction event was fired by the script, check that the player indicated in source really has administrator permissions in your systems.
Important: Always verify the administrator’s permissions on the server before processing or confirming an administrative action. It is not enough that the event is fired by the script; a malicious actor could attempt to manipulate the flow through other resources. Your server is the last line of defense.

  • See the Client Events for events emitted in the player environment.
  • Review the Server Exports for functions you can call directly from your resource without needing to listen to events.