Ask coding questions

← Back to all posts
Another C++ function error :/
LoveFromSkyy (137)

I'm trying to make XP go to 0 after the player levels up but I don't know how to do that.

Here is what I have:

int XpClear(int XP, int Lvl){
	int XpClear;
	if(/* something here...*/){	

		XP = 0;
		return (XpClear);
	}
	return (XpClear);
}
// LvlUpReq here

int LvlUp(int XP, int Lvl){
    Lvl += XP / LvlUpReq(XP, Lvl);
    return Lvl;
		
}
Comments
hotnewtop
LoveFromSkyy (137)

Because the repl includes 400+ lines of code which would make the question harder to read.
@Coder100

Coder100 (18915)

no it won't if you attach the repl we will be able to actually see all your code which will be beneficial @LoveFromSkyy

Coder100 (18915)

wait could you invite me and I can add the level up for you? @LoveFromSkyy

Baconman321 (1104)

Maybe store the last level that the player achieved and check if that is less than the current level. If so, then clear the XP.