The title is enough: Getting an unoccupied slot in a vehicle using .Occupant causes a crash
Ah yes, that was clearly a sh!tty choice https://github.com/iSLC/VCMP-SqMod/blob/41e04e5167efd765e25af6e52073f545932bec95/source/Entity/Vehicle.cpp#L262
Not checking whether the returned value is negative or out of bounds. Gonna fix it as soon as I can.
In the mean time, if this is critical, you can validate the ID manually before using the actual thing:
if (vehicle.OccupantID(slot) >= 0)
{
vehicle.Occupant(slot).stuff...
}
If you need this to be even stricter:
local oid = vehicle.OccupantID(slot);
if (oid >= 0 && oid < SqPlayer.MaxID)
{
vehicle.Occupant(slot).stuff...
}
Should be fixed now.