altmp / altv-issues

Issues and roadmap for alt:V project
92 stars 17 forks source link

Ped newOwner natives problem #2241

Open dGxxxx opened 4 months ago

dGxxxx commented 4 months ago

Description of the problem

I encounter this strange issues when applying some natives on a Ped, using its netOwner. The problem is that the natives don't always apply to the Ped, without using a timeout. When using a timeout for 5 seconds, the natives apply correctly. The scriptID also is correct with / without the timeout.

Reproduction steps

  alt.onServer("testEvent", (animalPed: alt.Ped) => {
    alt.log(animalPed.scriptID);
    native.setEntityAsMissionEntity(animalPed.scriptID, true, false);
    native.freezeEntityPosition(animalPed.scriptID, false);
    native.setPedCanRagdoll(animalPed.scriptID, false);
    native.taskSetBlockingOfNonTemporaryEvents(animalPed.scriptID, true);
    native.setBlockingOfNonTemporaryEvents(animalPed.scriptID, true);
    native.setPedFleeAttributes(animalPed.scriptID, 0, false);
    native.setPedCombatAttributes(animalPed.scriptID, 17, true);
    native.setEntityInvincible(animalPed.scriptID, false);
    native.setPedSeeingRange(animalPed.scriptID, 0);
    native.taskStartScenarioInPlace(animalPed.scriptID, 'WORLD_DEER_GRAZING', -1, true);
});
alt.on('netOwnerChange', (animalPed: alt.Entity, pedOwner: alt.Player | null, oldPedOwner: alt.Player | null) => {
    pedOwner.emitRaw('testEvent', animalPed);
});

Expected behaviour

The natives should work without applying a timeout.

Additional context

https://discord.com/channels/371265202378899476/1208762717754753074

Operating system

Windows

Version

release & latest dev (16.0.0-dev.247)

Crashdump ID

No response

Confirmation of issue's presence