25.03.2016, 17:10
Is there any way to check that how many players are in a vehicle? OR to check that if there is only 1 player in a car.
//The function you need:
stock GetVehiclePassengers(vehicleid)
{
new passengers[MAX_VEHICLES];
for(new i;i<MAX_PLAYERS;i++)
{
if(!IsPlayerConnected(i) || IsPlayerNPC(i))continue;
if(GetPlayerVehicleID(i) == vehicleid)
{
passengers[vehicleid] ++;
}
}
return passengers[vehicleid];
}
//How many passengers are in this vehicle?
printf("Passengers in vehicleid %i: %i",vehicleid,GetVehiclePassengers(vehicleid));
//When you want to check wheather there is only one person in this vehicleid:
if(GetVehiclePassengers(vehicleid) == 1)printf("in vehicleid %i is only one passenger!",vehicleid);
new VehicleOccupants[MAX_VEHICLES][10];