Server side ped creation don't sync

Hi everyone. I found a method to clone a ped server side. It works fine except the other player can’t see the head feauture and the correct hair colour. Mabe it’s a sync problem but i don’t really know the cause.


1 Like

You probably want to share the code for this - I think this is an issue some people have faced and solved before, but it’s hard to just diagnose it off two pictures.

CLIENT:

QBCore.Functions.TriggerCallback('prt-perma:server:Creaeduplica', function(serverped, netserver)
        while (not NetworkDoesEntityExistWithNetworkId(netserver)) do
            Wait(0)
        end        
        local PedToNet = NetworkGetEntityFromNetworkId(netserver)
        SetEntityHealth(PedToNet, 0)
        SetNetworkIdCanMigrate(netserver, true)
        SetNetworkIdExistsOnAllMachines(netserver, true)
        etc...

SERVER:

QBCore.Functions.CreateCallback('prt-perma:server:Creaeduplica', function(source, cb, mascheraped, mascheraskin, bracciaped, bracciaskin, borsaped, borsaskin, pantaloniped, pantaloniskin, scarpeped, scarpeskin, accessoriped, accessoriskin, magliettaped, magliettaskin, giubbottoped, giubbottoskin, decalsped, decalsskin, torsoped, torsoskin, x,y,z)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    local result = exports.oxmysql:executeSync('SELECT * FROM skintable WHERE cid = ? AND active = ?', { Player.PlayerData.cid, 1 })
    data = json.decode(result[1].skin)
    local modello = json.decode(result[1].model)
    local serverped = CreatePed(4, modello, x, y, z, 0, true, true)

    --FACCIA
    SetPedHeadBlendData(serverped, data["face"].item, data["face"].item, data["face"].item, data["face"].texture, data["face"].texture, data["face"].texture, 1.0, 1.0, 1.0, true)