28.12.2018, 04:07
Help with this...If the vehicle seat is not full,return seat ID or return -1
stock getSeatStatus(const vID, const seatID) { for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) { if(GetPlayerVehicleID(i) == vID && GetPlayerVehicleSeat(i) == seatID) return true; } return false; }
You could use a loop to check whoever in the vehicle, then using GetPlayerVehicleSeat function to check whether seats are full or not.
|
new const MaxVehicleSeats[212] =
{
4, 2, 2, 2, 4, 4, 1, 2, 2, 4, 2, 2, 2, 4, 2, 2, 4, 2, 4, 2, 4, 4, 2, 2, 2,
1, 4, 4, 4, 2, 1, 9, 1, 2, 2, 0, 2, 9, 4, 2, 4, 1, 2, 2, 2, 4, 1,
2, 1, 2, 0, 2, 1, 1, 1, 2, 2, 2, 4, 4, 2, 2, 1, 2, 1, 2, 4, 4, 2, 2, 4, 2, 1,
1, 2, 2, 1, 2, 2, 4, 2, 1, 4, 3, 1, 1, 1, 4, 4, 2, 4, 2, 4, 1, 2, 2, 2, 4, 4,
2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 1, 1, 2, 1, 1, 2, 2, 4, 2, 2, 1, 1, 2, 2, 2, 2,
2, 2, 2, 2, 4, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 4, 2, 2, 2, 2, 2, 4, 4, 2, 2, 4,
4, 2, 1, 2, 2, 2, 2, 2, 2, 4, 4, 2, 2, 1, 2, 4, 4, 1, 0, 0, 1, 1, 2,
1, 2, 2, 4, 2, 4, 4, 2, 4, 1, 0, 4, 2, 2, 2, 2, 0, 0, 2, 2, 1, 1,
4, 4, 4, 2, 2, 2, 2, 2, 4, 2, 0, 0, 0, 4, 0, 0
};
GetFreeSeat(vehicleid)
{
new vehiclemodel = GetVehicleModel(vehicleid);
if(vehiclemodel)
{
new
bool:seattaken[10],
playerseat = -1
;
foreach(new i : Player)
{
if(!IsPlayerInVehicle(i, vehicleid)) continue;
playerseat = GetPlayerVehicleSeat(i);
if(0 <= playerseat < 128)
seattaken[playerseat] = true;
}
for(new v = 0; v < MaxVehicleSeats[vehiclemodel - 400]; v++)
{
if(seattaken[v]) continue;
return v;
}
}
return -1;
}