altmp / altv-issues

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

Vehicle passengers count server side is not correctly sometimes #2259

Closed JumpSpinn closed 3 months ago

JumpSpinn commented 3 months ago

Description of the problem

I check the vehicle.passengers serverside and return true if passengers.Count is higher then 0. Sometimes the count is wrong and says that are passengers in inside although there are none inside

Reproduction steps

public async Task HasVehiclePassengers(UndefinedVehicle vehicle) { try { if (!Helper.IsVehicleValid(vehicle)) return false; if (vehicle.Passengers is null) return false; if(vehicle.Passengers.Count > 0) return true; } catch (Exception e) { _ = Logger.Exception(e); } return false; }

Expected behaviour

That the count is zero if no players inside the vehicle

Additional context

No response

Operating system

Windows

Version

16.0.143-release

Crashdump ID

No response

Confirmation of issue's presence

litolax commented 3 months ago

Need more clean reproduction steps. I tried with js and c# and can not reproduce it. Feel free to reopen this issue if you will have video or more info about reproducion steps.

public bool HasVehiclePassengers(IVehicle vehicle)
{
     if (vehicle.Passengers is null) return false;
     if (vehicle.Passengers.Count > 0) return true;

     return false;
}
alt.Player.all.forEach(p => {
    p.spawn(100,100,80);
    player.model = 'mp_m_freemode_01';
})

if (globalThis.veh) {
    globalThis.veh.destroy();
}

globalThis.veh = new alt.Vehicle('sultan2', player.pos, player.rot, 200);

return alt.Vehicle.all[0].passengers;