23.08.2013, 15:51
pawn Код:
new payment = (weight > 9 && weight <= 50) ? 100 : (weight > 50 && weight <= 100) ? 150 : (weight > 100 && weight <= 150) ? 200 : (weight > 150 && weight <= 200) ? 250 : 0;
new payment = (weight > 9 && weight <= 50) ? 100 : (weight > 50 && weight <= 100) ? 150 : (weight > 100 && weight <= 150) ? 200 : (weight > 150 && weight <= 200) ? 250 : 0;
new payment = (9 < weight && 50 => weight) ? 100 : (50 < weight && 100 => weight) ? 150 : (100 < weight && 150 => weight) ? 200 : (150 < weight && 200 => weight) ? 250 : 0;
new payment = (weight > 9 && weight <= 50) ? 100 : ((weight > 50 && weight <= 100) ? 150 : ((weight > 100 && weight <= 150) ? 200 : ((weight > 150 && weight <= 200) ? 250 : 0)));
new
payment
;
if( weight > 9 && weight <= 50 ) payment = 100;
else if( weight > 50 && weight <= 100 ) payment = 150;
else if( weight > 100 && weight <= 150 ) payment = 200;
else if( weight > 150 && weight <= 200 ) payment = 250;
else payment = 0;
// -- OR --
new
payment
;
switch( weight )
{
case 10 .. 50: payment = 100;
case 51 .. 100: payment = 150;
case 101 .. 150: payment = 200;
case 151 .. 200: payment = 250;
default: payment = 0;
}
Have you tried?
pawn Код:
|
The reason I posted the above is not because I doubt if you knew it or not. Does it actually work without the ternary operator method?
|