Abit of help please.
#5

Ill try to explain you with very easy words what you did wrong.
For example we have this code.
pawn Код:
new num = 4;
if (num >= 0) print("Our number is higher or equal to 0");
else if (num >= 1) print("Our number is higher or equal to 1");
else if (num >= 2) print("Our number is higher or equal to 2");
else if (num >= 3) print("Our number is higher or equal to 3");
else if (num >= 4) print("Our number is higher or equal to 4");
else if (num >= 5) print("Our number is higher or equal to 5");
This will return:
Код:
Our number is higher or equal to 0
In this case, pawn will first check if our number is higher or equal than 0, which is true since 5 >= 0, and it will SKIP all other checks.

In a second example we have
pawn Код:
new num = 4;
if (num >= 0) print("Our number is higher or equal to 0");
if (num >= 1) print("Our number is higher or equal to 1");
if (num >= 2) print("Our number is higher or equal to 2");
if (num >= 3) print("Our number is higher or equal to 3");
if (num >= 4) print("Our number is higher or equal to 4");
if (num >= 5) print("Our number is higher or equal to 5");
This will return:
Код:
Our number is higher or equal to 0
Our number is higher or equal to 1
Our number is higher or equal to 2
Our number is higher or equal to 3
Our number is higher or equal to 4
In this case, pawn will check our number with all 6 if() statements, and it will not skip anything. (Which is still not what you want)

BUT!
pawn Код:
new num = 4;
if (num >= 5) print("Our number is higher or equal to 5");
else if (num >= 4) print("Our number is higher or equal to 4");
else if (num >= 3) print("Our number is higher or equal to 3");
else if (num >= 2) print("Our number is higher or equal to 2");
else if (num >= 1) print("Our number is higher or equal to 1");
else if (num >= 0) print("Our number is higher or equal to 0");
This will return:
Код:
Our number is higher or equal to 4
In this case, it will first check our number with 4 >= 5, which is false, it will then try 4 >= 4, which is true, and it will SKIP all others...

Which is exactly what you need
Reply


Messages In This Thread
Abit of help please. - by Tye Huntley - 04.10.2011, 05:34
Re: Abit of help please. - by Tye Huntley - 04.10.2011, 13:17
Re: Abit of help please. - by hittt - 04.10.2011, 13:22
Re: Abit of help please. - by Tye Huntley - 04.10.2011, 22:11
Re: Abit of help please. - by hittt - 05.10.2011, 10:52

Forum Jump:


Users browsing this thread: 2 Guest(s)