natives icon indicating copy to clipboard operation
natives copied to clipboard

Issue with GetVehicleModelNumberOfSeats

Open darektion opened this issue 1 year ago • 3 comments

Details on replicating the bug:

  1. Spawn in kamacho.

  2. Call the GetVehicleModelNumberOfSeats(vehicleModel) function, where vehicleModel = GetHashKey('kamacho'), the value returned is 4 - correct.

  3. Despawn the vehicle.

  4. Redo step 2, the value returned is 2 - incorrect.

darektion avatar Feb 10 '24 18:02 darektion

Just tested it, and I have the same result. However, testing with the neon gives me the correct result both times.

MonsieurBibo avatar Apr 21 '24 17:04 MonsieurBibo

This seems like it would be somewhat expected behavior, if the model is in memory then it can get reliable information based on the actual model info, but if its not then it has to use the meta files which might be incorrect in some cases.

const model = GetHashKey('kamacho');

setImmediate(async () => {
  // will output 2, the model hasn't been loaded into memory
  console.log(GetVehicleModelNumberOfSeats(model)); 

  RequestModel(model)
  while (!HasModelLoaded(model)) {
    await Delay(0);
  }

  // will output 4, the model has been loaded into memory
  console.log(GetVehicleModelNumberOfSeats(model));
  SetModelAsNoLongerNeeded(model);

  while (HasModelLoaded(model)) {
    await Delay(0);
  }

  // will output 2, model is no longer in memory.
  console.log(GetVehicleModelNumberOfSeats(model));
})

AvarianKnight avatar Aug 02 '24 19:08 AvarianKnight

If the model seat data is in memory, it returns the valid number of seats; otherwise it will fall back to the number of seats in the vehicle model's layout. Similar behavior to natives like GetModelDimensions which will also only work properly if the model is loaded.

coalaura avatar Aug 28 '24 16:08 coalaura