feat(server/state): add `NETWORK_SET_FIRST_ENTITY_OWNER` for server created entites
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
😍 beautiful
merge!
This is hot 🔥🔥