Jump to content

Problem


FuriouZ

Recommended Posts

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

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
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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...