redundant test: constant expression is non-zero -
Blademaster680 - 16.01.2014
I have the error:
Код:
(10531) : warning 206: redundant test: constant expression is non-zero
Код:
stock IsAMotorcycle(carid)
{
if(carid == 586, 581, 523, 522, 521, 471, 468, 463, 462, 461, 448) return 1;
return 0;
}
Код:
Line 10531 == if(carid == 586, 581, 523, 522, 521, 471, 468, 463, 462, 461, 448) return 1;
Re: redundant test: constant expression is non-zero -
Konstantinos - 16.01.2014
You cannot compare like that. You would've to check if the carid is N everytime BUT.. switch is faster:
pawn Код:
stock IsAMotorcycle(carid)
{
switch (carid)
{
case 448, 461 .. 463, 468, 471, 521 .. 523, 581, 586: return 1;
}
return 0;
}
Make sure that when you use that function, you use GetVehicleModel.
pawn Код:
if (IsAMotorcycle(GetVehicleModel(vehicleid))) ...
Re: redundant test: constant expression is non-zero -
Blademaster680 - 16.01.2014
Why do you have the dots (..) between some of the numbers?
Re: redundant test: constant expression is non-zero -
iZN - 16.01.2014
Quote:
Originally Posted by Blademaster680
Why do you have the dots (..) between some of the numbers?
|
.. works like, if you want numbers 1 to 10, you can simply do 1 .. 10
Re: redundant test: constant expression is non-zero -
Konstantinos - 16.01.2014
Let's say you want to check if the carid is one of these:
pawn Код:
case 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410:
{
// code..
}
Instead of writing all those numbers, you could just do:
pawn Код:
case 400 .. 410:
{
// code..
}
and any number in between will be valid.
Re: redundant test: constant expression is non-zero -
Blademaster680 - 16.01.2014
Ahhh ok thanks, shortcut instead of typing them all out