natives
natives copied to clipboard
Issue with GetVehicleModelNumberOfSeats
Details on replicating the bug:
-
Spawn in
kamacho
. -
Call the
GetVehicleModelNumberOfSeats(vehicleModel)
function, where vehicleModel =GetHashKey('kamacho')
, the value returned is 4 - correct. -
Despawn the vehicle.
-
Redo step 2, the value returned is 2 - incorrect.
Just tested it, and I have the same result. However, testing with the neon
gives me the correct result both times.
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));
})
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.