01.06.2009, 17:15
i wasn't busy so I decided making a function. this function counts how many passengers are there in vehice id including or excluding driver.
Hope you enjoy it. It's simple, but useful. Especially for roleplay bussing system... Where i'll use it.
pawn Code:
public GetPeopleInVehicle(vehicleid, bool:count_driver)
{
new people_count = 0;
switch count_driver
{
case true:
{
for(new i = 0; i < MAX_PLAYERS; i++;)
{
if(IsPlayerInVehicle(i, vehicleid))
{
people_count++;
}
}
}
case false:
{
for(new i = 0; i < MAX_PLAYERS; i++;)
{
if(IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) != PLAYER_STATE_DRIVER)
{
people_count++;
}
}
}
}
return people_count;
}