Skip to content

Add unreliable (UDP) event support#493

Open
cocorico8 wants to merge 1 commit into
BeamMP:minorfrom
cocorico8:unreliable-events
Open

Add unreliable (UDP) event support#493
cocorico8 wants to merge 1 commit into
BeamMP:minorfrom
cocorico8:unreliable-events

Conversation

@cocorico8

@cocorico8 cocorico8 commented Jun 14, 2026

Copy link
Copy Markdown

Adds an unreliable counterpart to the existing reliable event system, allowing mods to send events over UDP instead of TCP.

New API

Server-side Lua:

  • MP.TriggerClientEventUnreliable(PlayerID, EventName, Data) — UDP delivery
  • MP.TriggerClientEventJsonUnreliable(PlayerID, EventName, Data) — JSON variant

Client-side Lua:

  • TriggerServerEventUnreliable(EventName, Data) — sends e:EventName:Data to server

How it works

Reliable events use E (uppercase) as the packet prefix, unreliable use e (lowercase). Both follow the same code path — the only difference is TCP vs UDP transport.

The launcher skips the >1KB compressed-size TCP upgrade for e packets so they stay on UDP regardless of payload size.

Why

The existing event system only supports reliable delivery. This forces TCP retransmission for every event, which is unnecessary overhead for data that doesn't need guaranteed delivery. This adds the option to opt into UDP where appropriate.

See also: BeamMP/BeamMP-Launcher#253, BeamMP/BeamMP#892

Add MP.TriggerClientEventUnreliable and MP.TriggerClientEventJsonUnreliable
Lua bindings, mirror of the reliable versions using UDP transport ('e' packets
instead of 'E'). InternalTriggerClientEvent now takes a Rel flag to select
between TCP and UDP delivery.

'E' and 'e' packets both route through the same HandleEvent handler.
Client events reach Lua handlers identically regardless of transport
reliability.

Use case: high-frequency loss-tolerant data where TCP retransmission of
stale data is actively harmful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant