GamesLauncherNewsDocsCommunityMy accountMy serversDownload Launcher
DocsLua scripting

Net events

Send events between the players' game and your server - and why you never trust the client.

#Client to server

A client can only call events that a resource has registered:

lua
RegisterNetEvent('shop:buy', function(item, amount)
  local player = source                  -- the player's id
  print(GetPlayerName(player) .. ' buys ' .. amount .. 'x ' .. item)
end)
  • RegisterServerEvent is an alias for RegisterNetEvent.
  • RegisterNetEvent('name') without a function, plus AddEventHandler('name', fn), works too.

In the client (Blueprint): Vantix Menu Subsystem → Trigger Server Event with EventName = "shop:buy" and JsonArgs = ["sword", 2] (a JSON array).

#Server to client

lua
TriggerClientEvent('shop:bought', source, 'sword')   -- one player
TriggerClientEvent('weather:set', -1, 'rain')        -- all players

In the client, bind On Server Event (EventName, JsonArgs) and parse JsonArgs.

#Messages

lua
SendMessage(id, 'Hello!')                         -- one player
SendMessage(-1, 'Server restarts in 5 minutes')   -- all players

The client gets them in On Server Message. If that isn't bound, the message is shown on screen. (Internally it's the client event vantix:message.)

#Limits

  • Max 60 events per second per player. The rest are dropped.
  • Max 16 KB per event. Event names max 64 characters.

#Never trust the client

Anything from a client can be faked. Always check types and values, and let the server decide prices, money, positions and so on.

lua
RegisterNetEvent('bank:withdraw', function(amount)
  if type(amount) ~= 'number' or amount <= 0 or amount > 10000 then return end
  -- check the balance on the server, not what the client says ...
end)
Warning

A net event without checks is an open door. Validate every argument before you use it.

Last updated 2026-12-06