fivem icon indicating copy to clipboard operation
fivem copied to clipboard

Server-Side CreatePed doesn't trigger entityCreated/entityCreating

Open Abasalt-yar opened this issue 1 year ago • 4 comments

What happened?

Hi, When I execute this code, only entityRemoved is being triggered

let JOB_PED
let INT
AddEventHandler("onResourceStart",res => {
    if (res != GetCurrentResourceName()) return
    let [x,y,z,heading] = [142.48,-871.71,30.62,207]
    JOB_PED = CreatePed(26,GetHashKey("s_m_y_airworker"),x,y,z - 1,heading,true,true)
    console.log(`Entity ID: `,JOB_PED)
    INT = setInterval(() => {
        if (DoesEntityExist(JOB_PED)) console.log("Ped Exists")
        if (NetworkGetNetworkIdFromEntity(JOB_PED)) {
            console.log("Ped Net ID Exists",NetworkGetNetworkIdFromEntity(JOB_PED))
            clearInterval(INT)
        }
    }, 1000);
    setTimeout(DeleteEntity,10000,JOB_PED)
})
AddEventHandler("entityCreated",en => console.log(`New Entity Created`,en))
AddEventHandler("entityCreating",en => console.log(`Creating New Entity`,en))
AddEventHandler("entityRemoved",en => console.log(`Entity Removed`,en))

image

Expected result

it should log Creating New Entity or New Entity Created

Reproduction steps

  1. Add the code above in a server-side script
  2. start the resource

Importancy

Slight inconvenience

Area(s)

FiveM, FXServer, OneSync

Specific version(s)

FXServer-master SERVER v1.0.0.8695 win32 Client: b2802 Canary

Additional information

No response

Abasalt-yar avatar Jul 21 '24 11:07 Abasalt-yar

I don't think server-created entities should trigger entityCreating at all because the server expects it to 'just exist'.

iirc the reason this wasn't fixed before for entityCreated is that there was the off chance that it would break compatibility existing usages of entityCreated which might expect entityCreated to have a valid owner and could break/error out if it doesn't

AvarianKnight avatar Jul 21 '24 13:07 AvarianKnight

I don't think server-created entities should trigger entityCreating at all because the server expects it to 'just exist'.

iirc the reason this wasn't fixed before for entityCreated is that there was the off chance that it would break compatibility existing usages of entityCreated which might expect entityCreated to have a valid owner and could break/error out if it doesn't

Oh I see, So it won't be fixed ? Or is there a chance it could be fixed in future

Abasalt-yar avatar Jul 21 '24 13:07 Abasalt-yar

I don't think server-created entities should trigger entityCreating at all because the server expects it to 'just exist'. iirc the reason this wasn't fixed before for entityCreated is that there was the off chance that it would break compatibility existing usages of entityCreated which might expect entityCreated to have a valid owner and could break/error out if it doesn't

Oh I see, So it won't be fixed ? Or is there a chance it could be fixed in future

Unless they create another game event (e.g., serverEntityCreated) for server-created entities, I don't think this issue is fixable, as it would break compatibility for many resources.

visibait avatar Jul 23 '24 23:07 visibait

I see, So we have to wait. Thank you

Abasalt-yar avatar Jul 24 '24 13:07 Abasalt-yar