Skip to content

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

Open
AvarianKnight wants to merge 1 commit into
citizenfx:masterfrom
AvarianKnight:feat/set-first-owner-tests
Open

feat(server/state): add NETWORK_SET_FIRST_ENTITY_OWNER for server created entites#4007
AvarianKnight wants to merge 1 commit into
citizenfx:masterfrom
AvarianKnight:feat/set-first-owner-tests

Conversation

@AvarianKnight

Copy link
Copy Markdown
Contributor

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.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

@AvarianKnight
AvarianKnight force-pushed the feat/set-first-owner-tests branch from 37ce96c to 6ad6c97 Compare May 28, 2026 20:50
@github-actions github-actions Bot added triage Needs a preliminary assessment to determine the urgency and required action invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels May 28, 2026
@AngeloneISL

Copy link
Copy Markdown

😍 beautiful

@Whisperisgod

Copy link
Copy Markdown

merge!

@jrgrimshaw

Copy link
Copy Markdown
Contributor

This is hot 🔥🔥

…reated entitys

This allows the server to set the `firstOwner` of the entity when it is
spawned, 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 persistance 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid Requires changes before it's considered valid and can be (re)triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants