Skip to content

Compatibility ​

The shim works in any Lua 5.4 resource, np_* or not, framework or not. This page lists what it sees, what it can't see, and where the line goes.

np_* resources ​

Every Lua np_* resource can be shimmed, and npnet patch np_* does all of them at once. Worth starting with, because they are the ones that move the most data between client and server:

Resource Typical traffic
np_hud Status and vehicle updates
np_inventory Inventory and stash updates, item use
np_phone App sync, messages, calls
np_payments / np_banking Charges, terminals, balances
np_menu Server actions
np_admin Player lists, spectate, reports

np_net doesn't need any of them, and none of them needs np_net. np_net never shims itself.

Frameworks ​

np_net uses no framework. To see framework traffic, shim the framework itself.

  • ESX callbacks run in es_extended's Lua state: ESX.TriggerServerCallback sends esx:triggerServerCallback from es_extended, and the answer comes back there. Patch es_extended too (npnet patch es_extended) to see them. They then show up under resource="es_extended", not under the resource that asked.
  • Any function you get from another resource's export (a core object, QBCore.Functions.TriggerCallback) runs in that resource's Lua state. Its events are counted there, so patch that resource as well.
  • ox_lib callbacks run in the resource that uses them, because @ox_lib/init.lua loads into that resource's state. The shim of that resource counts them, as long as the shim line comes before @ox_lib/init.lua.

Load order ​

  • np_net first. ensure np_net before the resources you measure. A shim that starts before np_net still counts; it simply drops its deltas until np_net runs.
  • The shim line first in the manifest. It has to run before any file that does local TriggerClientEvent = TriggerClientEvent (or the same for the other wrapped globals), and before @ox_lib/init.lua. A local copy made earlier keeps the unwrapped function, and those sends are invisible.
  • Loaded twice in one state (two shim lines): the second is ignored.
  • Restart after patching. A manifest change only applies when the resource starts again.

What it can't see ​

Not covered Why / what to do
JS and C# resources The shim is Lua. Their events are invisible to the event metrics
Resources without the shim Invisible to the event metrics. Drops, tick, ping and state bags are measured by np_net itself and cover everything
Engine traffic Entity sync, voice, state bag replication and other OneSync traffic aren't events. The server tick and FXServer's own /perf/ numbers show their effect; state bag changes are counted separately
Local events TriggerEvent inside one side never touches the network and isn't counted
Sends to a table of targets Counted, but without bytes
Framing overhead Bytes are payload bytes. FiveM's event name and packet headers aren't included
Heatmaps without OneSync The server can't see player positions, so the position layers stay empty
Instances Players in housing shells or other routing buckets are counted where their ped really is, which can be under or above the map
Deaths of other frameworks Only esx:onPlayerDeath and baseevents are heard. Others can call AddHeat('death', source)

Client numbers are untrusted ​

Everything with side="client" comes from the players' own machines. A modified client can send any number. np_net limits what one client can do:

  • checks types, sizes, ranges and that names are valid UTF-8, and rejects the whole report when one is off;
  • accepts at most one report per player per max(5 s, interval / 2); rejected attempts count against the limit too;
  • only accepts resources that exist on the server;
  • caps resources and events per report, and gives client-reported events their own series budget, so they can't push server events into __other__;
  • counts every rejected report by reason (np_net_client_reports_rejected_total).

Use side="client" series to find problems in your resources, not as proof against a player. Server-side numbers (side="server", egress, broadcasts, drops, tick, state bags) are measured on the server and can be trusted.

To switch client reports off completely: setr np_net_client_report_ms 0.

Behaviour guarantees ​

np_net only measures. With the shim in place:

  • every event is sent to the same targets, in the same order, through the same natives;
  • handlers get the same arguments (nil holes included), the same source and the same return values;
  • errors in handlers are not caught and travel up exactly as before;
  • only handlers of net events are wrapped; every other handler goes to the scheduler untouched, so local events cost nothing and the profiler still names their own file;
  • AddEventHandler still returns the handle, so RemoveEventHandler keeps working, also for handlers that were registered before RegisterNetEvent and wrapped later;
  • if msgpack.pack_args or an *Internal native is missing, the original function is called.