Skip to content

Add unreliable (UDP) event support#253

Open
cocorico8 wants to merge 2 commits into
BeamMP:masterfrom
cocorico8:unreliable-events
Open

Add unreliable (UDP) event support#253
cocorico8 wants to merge 2 commits into
BeamMP:masterfrom
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-Server#493, BeamMP/BeamMP#892

Fix Zp packet detection to use exact prefix match (compare(0,2) instead
of find()) to avoid false positives mid-payload.

Exclude 'e' packets from the >1024-byte-compressed TCP upgrade threshold
so unreliable events stay on UDP regardless of payload size.
Comment thread src/Network/GlobalHandler.cpp Outdated
@cocorico8 cocorico8 requested a review from WiserTixx June 18, 2026 17:56
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.

2 participants