i need just one code please any one help!

06/04/2017 01:33 empirewar#1
C#
-
the effect of new level didn't appear when player get new lvl put the effect didn't missed , i found it appear when i lvl up supclass , i tried to make it but didn't work can any one help me !
-
Code:
 byte lvl = client.Entity.Level;
            int newlevel = client.Entity.Level + 1;
            if (client.Entity.Level >= 1)
                for (int i = newlevel; i < lvl; i++)
                {
                    client.Entity.Update(_String.Effect, "lighbo", true);
                    client.MessageBox("hi");
                }
that's for test only
Code:
 client.Entity.Update(_String.Effect, "lighbo", true);
                    client.MessageBox("hi");
06/04/2017 02:42 JaniQ#2
It's obviously because your loop doesn't execute.

You assign the value of the level in the variable lvl let's assume it's 1.
Now you assign the value of the newlevel in i which is the level +1 so 2.

Here
Code:
for (int i = newlevel; i < lvl; i++)
You check if i (2) is less than lvl(1) which is obviously false
thus the loop doesn't execute.

also the loop useless since two lines above you add only 1 which is not
a variable so the loop will always execute once.

I strongly recommend learning simple math before trying to code.
06/04/2017 02:47 empirewar#3
Quote:
Originally Posted by JaniQ View Post
It's obviously because your loop doesn't execute.

You assign the value of the level in the variable lvl let's assume it's 1.
Now you assign the value of the newlevel in i which is the level +1 so 2.

Here
Code:
for (int i = newlevel; i < lvl; i++)
You check if i (2) is less than lvl(1) which is obviously false
thus the loop doesn't execute.

also the loop useless since two lines above you add only 1 which is not
a variable so the loop will always execute once.

I strongly recommend learning simple math before trying to code.
:"D so what is the the right way of this code :rolleyes:
06/04/2017 05:43 Nyorai#4
Quote:
Originally Posted by empirewar View Post
:"D so what is the the right way of this code :rolleyes:
He literally just gave you the answer... Your loop will never be executed because the number on the left "newlevel" will never be higher than the one on the right "lvl"...
I mean, you say newlevel = lvl + 1, and then you write a loop thats supposed to be executed when lvl > newlevel... It's the other way around...

Let me make this easier for you:
A = 1;
B = A + 1;

You're basically telling it to run something when A > B ... Now ask yourself, if B = A + 1, when will A ever be > B?
This is 4th grade math..

And as JaniQ said, what's even the point of having a loop there when you add only 1? With the loop it would only be executed once so no point having the loop there
06/04/2017 07:01 empirewar#5
Quote:
Originally Posted by Nyorai View Post
He literally just gave you the answer... Your loop will never be executed because the number on the left "newlevel" will never be higher than the one on the right "lvl"...
I mean, you say newlevel = lvl + 1, and then you write a loop thats supposed to be executed when lvl > newlevel... It's the other way around...

Let me make this easier for you:
A = 1;
B = A + 1;

You're basically telling it to run something when A > B ... Now ask yourself, if B = A + 1, when will A ever be > B?
This is 4th grade math..

And as JaniQ said, what's even the point of having a loop there when you add only 1? With the loop it would only be executed once so no point having the loop there
Solved thanks :"D