if statement
#2

This will never really work correctly, because there is only one possible case: All Windows are closed. But the vehicle cannot be both, Dynamic and non-Dynamic. Thus it will always fail/succeed, depending on the data in the arrays.

Код:
if(!IsBike(...) && ((IsDynamicVehicle && AllWindowsClosed) || (!IsDynamicVehicle && AllWindowsClosed)))
{
// Send to passenger(s)
}
else
{
// Send to all nearby
}
This should be the correct logic.

You must replace AllWindowsClosed etc. with your checks, but keep the brackets in place.

All your conditions were checked with AND, however some have to be put in brackets and checked with OR, since it cannot be both a Dynamic Vehicle and a non-Dynamic one, but it should consider both cases.

The brackets you put were not doing any difference, since AND statements have no particular order.


Btw why do you split the vehicles into two arrays? You could keep them in one and just make some "ownable".
Since you access both with vehicleid, it should work fine. That would probably simplify things like this a bit.
But I don't know if you have any reason for splitting them, so this is just an idea.
Reply


Messages In This Thread
if statement - by GoldenLion - 27.12.2016, 16:12
Re: if statement - by NaS - 27.12.2016, 16:41
Re: if statement - by GoldenLion - 27.12.2016, 19:13
Re: if statement - by NaS - 27.12.2016, 19:17
Re: if statement - by GoldenLion - 27.12.2016, 19:19
Re: if statement - by Konstantinos - 27.12.2016, 19:28

Forum Jump:


Users browsing this thread: 5 Guest(s)