class Net
package fivem.client.core
Sending events from the client to the server.
Receiving is environment-agnostic and lives in fivem.shared.core.Events;
only the sending direction differs between client and server, which is why
it is split out here.
Net.emitServer("shop:buy", itemId, quantity);
Every payload is msgpack-serialised, so send plain data: numbers, strings, booleans, anonymous structures. A class instance arrives on the server as a bare table with no methods.
Nothing sent from a client can be trusted. The server must validate every argument — including things that "can't" be wrong, like a price the client calculated.
Static methods
staticinlineemitServerLatent(eventName:String, bytesPerSecond:Int, args:Rest<Dynamic>):Void
Sends an event to the server at a limited rate, for payloads large enough that sending them in one packet would stall the connection.
Parameters:
bytesPerSecond | A sensible ceiling is around 128000. |
|---|
staticinlineonServer(eventName:String, handler:Function):EventSubscription
Handles an event sent by the server.
A convenience alias for Events.onNet, so client code that only
imports Net still has both directions to hand.