Trying to understand how Network works for entities

I have no idea. But this is things I’d look into.

I thought this code was interesting last night. Never seen it used before.

RequestCollisionAtCoord(spawn.x, spawn.y, spawn.z)
while not HasCollisionLoadedAroundEntity(ped) do
Citizen.Wait(0)
end

Seems to be related to this

There is a collision for models native. HAS_COLLISION_FOR_MODEL_LOADED(Any p0) // 22CCA434E368F03A 41A094F8

It seems clear that something hasn’t finished sync’ing or updating, and there seem to be natives to check on that. HasModelLoaded is local for the client. SetVehicleOnGroundProperly is also local, it just burns through that and updates the server. But the client never waits back for a valid response about what it’s creating.

Some random FiveM dev post in 2015

“also: don’t use LOAD_ALL_OBJECTS_NOW, use LOAD_SCENE or REQUEST_COLLISION_AT_COORD and wait for the streamer to load the scene at runtime (especially important if networked, since various subsystems won’t get serviced during a regular LOAD_SCENE - original scripts use an unknown native (formerly START_LOAD_SCENE) combined with NETWORK_UPDATE_LOAD_SCENE and call a bunch of servicing funcs in the middle, but you typically don’t have access to the original script code)”

Basically making a vehicle is local on the clients side, it has nothing to do with multiplayer or the server. Somewhere after that gets updated/synced but there’s no check within createvehicle to stop/valid it. I’d guess your script isn’t waiting for everything to sync before it starts doing stuff with it or getting IDs. The reason the collision check is important I guess in order to do that it needs to sync with the network and that process validates some shit?

3 Likes