fivem icon indicating copy to clipboard operation
fivem copied to clipboard

feat(server/state): add `NETWORK_SET_FIRST_ENTITY_OWNER` for server created entites

Open AvarianKnight opened this issue 6 months ago • 3 comments

Goal of this PR

Possibly fix ownership bouncing between different clients

How is this PR achieving the goal

This allows the server to set the first owner of the entity when it is spawned (along with forcing the entity to be owned by them), forcing that client (and that client only) to be in charge of the server created entity.

This is mainly useful for vehicles, where you can typically expect a certain client to be close to the vehicle that it is spawning, but we need it to be server spawned for persistence and to ensure vehicles aren't created by modders.

This is only meant for testing, this needs a proper way to tell if a vehicle, ped or object can be relevant to a client. Since it's currently possible that you set the entity owner and then the client never actually syncs the vehicle.

This mainly relies on hasSynced relevancy checks to stop this from ever migrating the vehicle until we've properly synchronized the vehicle, since before this could just bounce between multiple different clients.

This PR applies to the following area(s)

FiveM

Successfully tested on

Checklist

  • [ ] Code compiles and has been tested successfully.
  • [x] Code explains itself well and/or is documented.
  • [x] My commit message explains what the changes do and what they are for.
  • [x] No extra compilation warnings are added by these changes.

Fixes issues

AvarianKnight avatar May 28 '26 20:05 AvarianKnight

😍 beautiful

AngeloneISL avatar May 28 '26 22:05 AngeloneISL

merge!

Whisperisgod avatar May 29 '26 11:05 Whisperisgod

This is hot 🔥🔥

jrgrimshaw avatar May 29 '26 12:05 jrgrimshaw