Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-Side CreatePed doesn't trigger entityCreated/entityCreating #2658

Open
Abasalt-yar opened this issue Jul 21, 2024 · 4 comments
Open
Labels
bug triage Needs a preliminary assessment to determine the urgency and required action

Comments

@Abasalt-yar
Copy link

Abasalt-yar commented Jul 21, 2024

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 Abasalt-yar added bug triage Needs a preliminary assessment to determine the urgency and required action labels Jul 21, 2024
@AvarianKnight
Copy link
Contributor

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

@Abasalt-yar
Copy link
Author

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

@visibait
Copy link

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.

@Abasalt-yar
Copy link
Author

I see, So we have to wait. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Needs a preliminary assessment to determine the urgency and required action
Projects
None yet
Development

No branches or pull requests

3 participants