Will Spawning Peds on the Server Side Automatically Sync them on OneSync?

Hello I’m new to fivem modding my question is if I spawn a ped on the server side [OneSync] using CreatePed will it automatically sync to all clients or do I need to do additional stuff?

 if currentPedCount < MIN_PEDS_AROUND_PLAYER then
        local pedCountToSpawn = math.min(MAX_PEDS_TO_SPAWN - currentPedCount, MIN_PEDS_AROUND_PLAYER - currentPedCount)
        for i = 1, pedCountToSpawn do
            local offsetX = getRandomOffset(50, 75)
            local offsetY = getRandomOffset(50, 75)
			local finalPlayerCoords = vector3(playerCoords.x + offsetX, playerCoords.y + offsetY, playerCoords.z)
			
			local pedModel = GetRandomPedModel()
            local ped = CreatePed(1, pedModel, finalPlayerCoords.x, finalPlayerCoords.y, finalPlayerCoords.z, 0.0, true, false)
            while not DoesEntityExist(ped) do
                Wait(1)
            end
        end
    end

It spawns additional ped around the player and it works. but I do not have another computer to test if it is syncing. Will get my friend to test it with me this weekend.

In the meantime can anyone confirm if you spawn create a ped server side it will sync?
Or do I have to do additional things to make it sync with other players.

My goal is just to mostly spawn a bunch of npcs around the players and make sure they sync. And if my friend shoot or do something with them will they sync also on my end?

1 Like

Yes, server side CreatePed should sync the ped to other players automatically. If you yourself can see it, then it should be synced :slight_smile:
If you would have used it on client side you must make sure to set the isNetwork param to true and it should also be synced.

3 Likes

Thanks for the clarification :+1:, much appreciated.
Yes I can see the Peds created on the server on my end.

1 Like