[Fixed] Getting an unoccupied slot in a vehicle using .Occupant causes a crash

EK.IceFlake

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,761

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,804
[Bug] Re: Getting an unoccupied slot in a vehicle using .Occupant causes a crash
« Reply #2, on May 25th, 2017, 07:49 PM »Last edited on May 25th, 2017, 07:51 PM
In the mean time, if this is critical, you can validate the ID manually before using the actual thing:

Code: [Select]
if (vehicle.OccupantID(slot) >= 0)
{
    vehicle.Occupant(slot).stuff...
}

If you need this to be even stricter:

Code: [Select]
local oid = vehicle.OccupantID(slot);

if (oid >= 0 && oid < SqPlayer.MaxID)
{
    vehicle.Occupant(slot).stuff...
}
.