Server-Side CreatePed doesn't trigger entityCreated/entityCreating
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))
Expected result
it should log Creating New Entity or New Entity Created
Reproduction steps
- Add the code above in a server-side script
- 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
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
I don't think server-created entities should trigger
entityCreatingat all because the server expects it to 'just exist'.iirc the reason this wasn't fixed before for
entityCreatedis that there was the off chance that it would break compatibility existing usages ofentityCreatedwhich might expectentityCreatedto 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
I don't think server-created entities should trigger
entityCreatingat all because the server expects it to 'just exist'. iirc the reason this wasn't fixed before forentityCreatedis that there was the off chance that it would break compatibility existing usages ofentityCreatedwhich might expectentityCreatedto have a valid owner and could break/error out if it doesn'tOh 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.
I see, So we have to wait. Thank you