altmp / altv-issues

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

setIntoVehicle Broken (C# + JS) #1174

Open juztim opened 2 years ago

juztim commented 2 years ago

Description of the problem

When using player.setIntoVehicle a weird bug sometimes occures -> https://youtu.be/JsP-yVlKAVk as you can see in the video, the player gets teleported into the vehicle but doesn't get control over the vehicle (also tested with planes). It seems to always happen when the player is in the air, and sometimes when the player is on the ground too (rarely).

EDIT: sometimes you can control the wheels as in the video, sometimes you can't

Reproduction steps

Use setIntoVehicle function on a player that is in the air

Expected behaviour

Player should get control of the vehicle

Additional context

No response

Operating system

Windows 10 + Ubuntu 20.04

Version

Release 6.4 + Dev 7.0-Dev9

FabianTerhorst commented 2 years ago

it only happens when you are close to 0 point or?

C0kkie commented 2 years ago

It can happen everywhere

juztim commented 2 years ago

^ small addition @FabianTerhorst, the warning "Cannot set player into vehicle, vehicle doesn't exists! Waiting for creation." also is visible when not using debug mode

FabianTerhorst commented 2 years ago

^ small addition @FabianTerhorst, the warning "Cannot set player into vehicle, vehicle doesn't exists! Waiting for creation." also is visible when not using debug mode

that warning is gone for none debug mode in next release.

xxshady commented 2 years ago

As an alternative you can use this:

serverside:

player.emit("setIntoVehicle", vehicle, 1) // set player into driver seat

clientside:

alt.onServer("setIntoVehicle", async (vehicle, seat) => {
  if (!vehicle) return // it was destroyed

  if (!vehicle.isSpawned) {
    alt.log("[setIntoVehicle] vehicle is not spawned, waiting...")

     // adjust timeout value for your needs
    await alt.Utils.waitFor(() => vehicle.isSpawned, 5000)
      .catch(e => alt.log('[setIntoVehicle] vehicle is either destroyed or did not spawn (destreamed by server?)', e.message))

    // check again because of `await`
    if (!(vehicle.valid && vehicle.isSpawned)) return
  }

  native.setPedIntoVehicle(
    alt.Player.local,
    vehicle,
    seat - 2, // altv and game natives seat offset
  )
})
yannbcf commented 1 year ago

Why did you close it ? Its still an issue happening

juztim commented 1 year ago

@yannbcf missclicked idk how that happened lol