altv-issues icon indicating copy to clipboard operation
altv-issues copied to clipboard

taskEnterVehicle fails after calling another native

Open ChuckGod6 opened this issue 3 years ago • 1 comments

Description of the problem

I noticed the following problem while playing around with water related natives. After calling the testProbeAgainstWater native, the taskEnterVehicle native always fails.

[23:26:07][Error] Native call failed: taskEnterVehicle
[23:26:07][Error]   Exception offset: 0x12EAD6E
[23:26:07][Error]   Exception code: C0000005
[23:26:07][Error]   Error code: 0
[23:26:07] Error: Native call failed

Reproduction steps

Spawn a vehicle and use a script to call the testProbeAgainstWater and the taskEnterVehicle native to enter the vehicle. Example script:

alt.everyTick(() => {
  game.disableControlAction(0, 23, true);
  if (game.isDisabledControlJustPressed(0, 23)) {

    // call testProbeAgainstWater native
    const headPosition = game.getPedBoneCoords(alt.Player.local, 31086, 0, 0, 0);
    const offsetPosition = game.getOffsetFromEntityInWorldCoords(alt.Player.local, 0, 50, -15);
    const hit = game.testProbeAgainstWater(headPosition.x, headPosition.y, headPosition.z, offsetPosition.x, offsetPosition.y, offsetPosition.z);

    // try call taskEnterVehicle
    const vehicle = game.getClosestVehicle(alt.Player.local.pos.x, alt.Player.local.pos.y, alt.Player.local.pos.z, 10, 0, 2);
    try {
      game.taskEnterVehicle(alt.Player.local, vehicle, 5 * 1000, -1, 2, 1, 0);
    } catch(e) {
      alt.log(e);
    }
  }
});

Expected behaviour

taskEnterVehicle doesn't fail on call

Additional context

I think the error only occurs since the update to alt:V 10. It was quite difficult to find the source of the error, but it can be reproduced with the above script on a freeroam server.

Operating system

Windows 10, Debian 10

Version

release/10.9

ChuckGod6 avatar May 31 '22 21:05 ChuckGod6

Confirmed on release/10.10 & dev/10.0-dev5

deluvas1911 avatar Jun 01 '22 20:06 deluvas1911

Fixed in release/13.49

C0kkie avatar Mar 23 '23 18:03 C0kkie