• Create Account

### #ActualBeerNutts

Posted 17 February 2012 - 06:06 PM

No. You have an array with 99 element, and the index 99 refers to the 100th element. It is outside the array, so it's not a valid array element.

But ignoring that; yes, the logic is otherwise OK, as long as you index the array properly. You probably want this instead though:

if(exp>=exptilnextlevel[level])
{
++level;
}


To slam home the point, you might should check you're not outside the bounds of the array 1st
// if you're below level 98, then you're good to go
// if you're at level 98, the array only goes up to exptilnextlevel[98], so don't increase the level any more
if (level < 98) {
if(exp>=exptilnextlevel[level])
{
++level;
}
}


(Edit Beaten)

### #1BeerNutts

Posted 17 February 2012 - 06:06 PM

No. You have an array with 99 element, and the index 99 refers to the 100th element. It is outside the array, so it's not a valid array element.

But ignoring that; yes, the logic is otherwise OK, as long as you index the array properly. You probably want this instead though:

if(exp>=exptilnextlevel[level])
{
++level;
}


To slam home the point, you might should check you're not outside the bounds of the array 1st
[source]
// if you're below level 98, then you're good to go
// if you're at level 98, the array only goes up to exptilnextlevel[98], so don't increase the level any more
if (level < 98) {
if(exp>=exptilnextlevel[level])
{
++level;
}
}

PARTNERS