I have the following problem. I am creating all vehicles server side using CreateObject Native.
However many natives don’t exist server side. So I am trying to send the vehicle network to id to the desired client in order to modify is. This is where the problems start. I send the network id and after that to the client I run local vehicle = NetworkGetEntityFromNetworkId(netId).
Vehicle object it’s like existing in bugged mode , because natives such as NetworkGetNetworkIdFromEntity(vehicle) or TaskWrapPedIntoVehicle(…,vehicle) etc dont work.
As far I as know this is happenig because I don’t have the ownership of the specific vehicle because server decided to give the ownership to another player (perhaps a close one). So the thing is what can I do to get the ownership for myself? NetworkRequestControlOfEntity doesn’t work
1 Like
You can either use NetworkGetEntityOwner on server side and trigger it on that player only after the entity exists or use entity state bags and have a handler on client side that checks if the player is the entity owner and then just executes all functions if he is.
The latter seems more reliable to me.
I’m not sure I clearly understand what you are trying to do but you can create a client event that uses the CreateVehicle native and then trigger that client event in your server script.
Ok let’s say that he is not the entity owner… now what? I delete and recreate is until he is?
- You create the vehicle on server side
- Wait til it exists
- Wait until it has a entity owner
- Trigger the event that does the client side stuff on that entity owner
The only quirk of that is that the entity owner could change in the time it takes the event to arrive on the client.
That’s why I suggested state bags as well. They are replicated to every single client and using a state bag change handler you can “find” the client that is the entity owner and do everything there.
The problem is that I need to make sure that the ownership belongs to the client that triggered the server side event that starts the object creation…
I want to use the above ideas for creating a non cheater-object-spawner free server. I have already implemented a "good’ anti trigger system. So know I want to redirect all my client side spawns to the server in order to activate a strict
SetRoutingBucketEntityLockdownMode
I know that I could change all my scripts to server side spawning… however this would be almost impossible considering that my server has more that 200 scripts (many of them are escrowed as well)
Then I can only suggest that you leave a feature request / suggestion ( Platform Suggestions - Cfx.re Community ) to be able to change an entity owner on server side. If that’s even possible from a networking point.
NetworkRequestControlOfEntity perhaps?
not working in this specific case
There’s a really cool project called Serpent that allows for server sided entity management.
Here - take this
Shoutout @silverman of course!