Quote:
Originally Posted by RogueDrifter
Aha thanks! i edited my post with that valid thing and i'll check your implementation once i get time but just a comment shouldn't this:
PHP код:
new bool:is_occupied = false;
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(!IsPlayerConnected(p)) continue; //Forgot this, foreach could be even better
if(IsPlayerInVehicle(p, i))
{
is_occupied = true;
break; //avoid any more useless loops, we know the vehicle is occupied
}
}
if(!is_occupied) //without any driver
be like this?
PHP код:
new bool:is_occupied[MAX_VEHICLES] = false;
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(!IsPlayerConnected(p)) continue; //Forgot this, foreach could be even better
if(IsPlayerInVehicle(p, i))
{
is_occupied[i] = true;
break; //avoid any more useless loops, we know the vehicle is occupied
}
}
if(!is_occupied[i]) //without any driver
|
Well, it would be really pointless to use an array for this case (loop through all the unoccupied vehicles), as the variable is_occupied only serves the purpose of telling you whether the vehicle with ID: i is occupied or not and if so it's value changes to true. This line:
PHP код:
if(!is_occupied)
Simply checks whether is_occupied was not changed for vehicle ID:
i
If you wanted to make an array of the unoccupied vehicles (can't find a use for that) then what you propose might be possible.