FuriouZ Posted April 15, 2014 Share Posted April 15, 2014 Hello! Well, i have problem with level system, so if i get 100 xp then it doesn't set my level to 1 but if i have 101xp then it does The problem is probably here,but i don't have no idea how to fix it: if ( g_xp > 100 and g_xp < 500 ) then setElementData(source, "Level", "1") if i set if ( g_xp > 99 and g_xp < 499 ) then setElementData(source, "Level", "1") then it sets my level to 1 if i have xp 100 Link to comment
Vinctus Posted April 15, 2014 Share Posted April 15, 2014 if ( g_xp >= 100 and g_xp <= 500 ) then setElementData(source, "Level", "1") Link to comment
FuriouZ Posted April 15, 2014 Author Share Posted April 15, 2014 if ( g_xp >= 100 and g_xp <= 500 ) thensetElementData(source, "Level", "1") Thanks ! Link to comment
FuriouZ Posted April 15, 2014 Author Share Posted April 15, 2014 But now happens the same problem if i get level 2 if ( g_xp >= 50 and g_xp <= 100 ) then setElementData(source, "Level", "1") elseif ( g_xp >= 100 and g_xp <= 150 ) then setElementData(source, "Level", "2") Link to comment
Mr_Moose Posted April 15, 2014 Share Posted April 15, 2014 Change the order, all code is running from line to line, top to bottom basically: if ( g_xp >= 100 and g_xp <= 150 ) then setElementData(source, "Level", "2") elseif ( g_xp >= 50 and g_xp <= 100 ) then setElementData(source, "Level", "1") This will check if g_xp is bigger than 100 before it check if it's bigger than 50 which is pretty logic in a level up system. Link to comment
Vinctus Posted April 15, 2014 Share Posted April 15, 2014 Change the order, all code is running from line to line, top to bottom basically: if ( g_xp >= 100 and g_xp <= 150 ) then setElementData(source, "Level", "2") elseif ( g_xp >= 50 and g_xp <= 100 ) then setElementData(source, "Level", "1") This will check if g_xp is bigger than 100 before it check if it's bigger than 50 which is pretty logic in a level up system. also what you want to do is make the minimum XP for level 2 one higher than the max xp for level 100, as ">=" means "equal or bigger than", so for level 2 should be g_xp >= 101 Link to comment
FuriouZ Posted April 15, 2014 Author Share Posted April 15, 2014 Change the order, all code is running from line to line, top to bottom basically: if ( g_xp >= 100 and g_xp <= 150 ) then setElementData(source, "Level", "2") elseif ( g_xp >= 50 and g_xp <= 100 ) then setElementData(source, "Level", "1") This will check if g_xp is bigger than 100 before it check if it's bigger than 50 which is pretty logic in a level up system. Thanks ! All works perfectly now Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now