Bridge.Entities is the sanctioned way to spawn networked entities from a resource. It spawns server-side, tracks every entity in a registry, and automatically deletes a player’s entities when they disconnect. You get back a data-only view keyed by netId, which is what you use to reach the entity on clients.
This is a server-only surface.
Why server-side spawning
A client-spawned networked entity is owned by the spawning client. That client controls its network state — it can teleport it, modify it, give it god mode, or delete it at will. It is one of the most exploited attack surfaces on FiveM. Spawning server-side makes the server authoritative over the entity’s creation and lifecycle. A client may request a spawn overBridge.Net (validate the request first), but the server performs the spawn through Bridge.Entities.Spawn.
Spawn
Spec fields
What to spawn. Invalid kinds return
nil, 'bad_kind'.Model name (hashed for you) or a precomputed hash.
Spawn position; the
w component is the heading (defaults to 0 if omitted).If set, the entity is filed under this player and auto-deleted when they disconnect.
Free-form tag stored on the record and returned in the view.
Arbitrary data stored on the record and returned in the view.
Vehicle class for the server setter (default
'automobile'). Use e.g. 'bike', 'heli', 'boat' for other classes.Ped type for
CreatePed (default 4).Return — a data-only view
Spawn returns a view, not the raw entity handle. The raw handle stays server-side; consumers reach the entity through netId.
Track & retrieve
| Method | Returns |
|---|---|
Bridge.Entities.Get(id) | The view for a registry id, or nil. |
Bridge.Entities.GetByNet(netId) | The view for a network id, or nil. |
Despawn & cleanup
owner = src is despawned for you. You only call ReleaseOwner if you want to drop a player’s entities early (e.g. on a job change).
| Method | Effect |
|---|---|
Bridge.Entities.Despawn(id) | Delete the entity and remove it from the registry. |
Bridge.Entities.ReleaseOwner(src) | Despawn every entity owned by src. |
Auto-cleanup on disconnect runs regardless —
ReleaseOwner is only for releasing early. An entity spawned without an owner is tracked but is never auto-deleted; despawn it yourself.Protected statebags
Attach tamper-revert state to any networked entity. If a client edits the statebag, the bridge reverts it to your value — use it for server-authoritative entity data (fuel, lock state, ownership).| Method | Effect |
|---|---|
Bridge.Entities.ProtectState(netId, key, value) | Set a tamper-revert statebag value on the entity. |
Bridge.Entities.ClearState(netId, key) | Remove a protected statebag value. |
Attach props to a player
Attach (and later clear) decorative props on a player ped — handled server-side so every client sees them.Request-then-spawn pattern
The full secure flow: client requests, server validates, server spawns, client gets thenetId to use.
Networking
Validate and rate-limit the spawn request before you act on it.
World
Interaction prompts, zones, and blips for the entities you spawn.
