22.09.2010, 08:57
You can use this function, to detect where there is a free seat in the car, so no one gets kicked, if there are other passengers:
(Still did not test it, even i posted it sometimes already )
It is used like this:
pawn Код:
GetVehiclePassengers(vehicleid, passengers[4])
{
for(new i = 0; i < 4; i ++)
passengers[i] = -1;
for(new i = 0; i < MAX_PLAYERS; i ++)
if(GetPlayerVehicleID(i) == vehicleid)
passengers[GetPlayerVehicleSeat(i)] = i;
}
It is used like this:
pawn Код:
if(IsPlayerInAnyVehicle(player_tele_target)) //To detect if the target is in a vehicle
{
new passengers[4];
GetVehiclePassengers(GetPlayerVehicleID(player_tele_target), passengers);
//GetVehicePassengers fills the array with the playerid at the specific seat (passengers[0] is the driver etc)
//and with -1 if it is free, so check for -1 with a loop
for(new i = 0; i < 4; i ++)
{
if(passengers[i] == -1) PutPlayerInVehicle(playerid, GetPlayerVehicleID(player_tele_target), i);
//This will put the player on the first free seat
}
}