How to make this shorter
#1

Im too tired right now, anyone got idea how to make this script abit shorter?

pawn Код:
new id;
if(i == 0 || i == 1) { id = 0; }
else if(i == 2 || i == 3) { id = 1; }
else if(i == 4 || i == 5) { id = 2; }
else if(i == 6 || i == 7) { id = 3; }
else if(i == 8 || i == 9) { id = 4; }
else if(i == 10 || i == 11) { id = 5; }
else if(i == 12 || i == 13) { id = 6; }
else if(i == 14 || i == 15) { id = 7; }
else if(i == 16 || i == 17) { id = 8; }
else if(i == 18 || i == 19) { id = 9; }
else if(i == 20 || i == 21) { id = 10; }
else if(i == 22 || i == 23) { id = 11; }
Reply
#2

You can do that in one very short line.

id = i/2

I guess i is an integer. Dividing one integer by another one will cut off any decimal digits. 6/2=3, 3/2=1, 1/2=0 and so on.
Reply
#3

Didnt though about that, yes, I guess it did so, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)