class Net
package fivem.server.core
Sending events from the server to clients.
Receiving is environment-agnostic and lives in fivem.shared.core.Events;
only the sending direction is server-specific.
Net.emitClient("hud:update", player.source, cash, bank);
Net.emitAll("weather:changed", "RAIN");
Net.emitNear(explosionPoint, 200.0, "effects:explosion", explosionPoint);
Every payload is msgpack-serialised, so send plain data. Broadcasting is
cheap per call but not free per client — emitNear exists because sending
a local effect to all 64 players wastes bandwidth on the 60 who can't
see it.
Static methods
staticinlineemitAll(eventName:String, args:Rest<Dynamic>):Void
Sends an event to every connected player.
Uses the -1 broadcast target the runtime understands, so this costs
one call rather than one per player.
staticemitAllExcept(excluded:Int, eventName:String, args:Rest<Dynamic>):Void
Sends an event to every player except excluded.
staticinlineemitClient(eventName:String, target:Int, args:Rest<Dynamic>):Void
Sends an event to one player.
staticinlineemitClientLatent(eventName:String, target:Int, bytesPerSecond:Int, args:Rest<Dynamic>):Void
Sends an event to one player at a limited rate, for payloads large enough that one packet would stall their connection.
Parameters:
bytesPerSecond | A sensible ceiling is around 128000. |
|---|
staticemitNear(position:Vector3, radius:Float, eventName:String, args:Rest<Dynamic>):Void
Sends an event to every player within radius of position.
staticinlineonClient(eventName:String, handler:Function):EventSubscription
Handles an event sent by a client.
A convenience alias for Events.onNet. Read the sender with
Events.source() and validate everything it sent — a client can
trigger any registered net event with any arguments.