You will have to change two functions.
The one you copied is when you run the "change level" command in an event.
The second is just above it, where you "change exp".
You can add do something like
@exp = [[exp, 9999999].min, 0].max
# Level up
while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
@level += 1
# Learn skill
for j in $data_classes[@class_id].learnings
if j.level == @level
@hp = self.maxhp
@sp = self.maxsp
# Level down
while @exp < @exp_list[@level]
@level -= 1
# Correction if exceeding current max HP and max SP
@hp = [@hp, self.maxhp].min
@sp = [@sp, self.maxsp].min
And similarly add those two new lines to the other function as well.
You may want to keep the "correction" cause it handles cases where hp/sp goes down upon exp change, such as negative HP/SP curve per level up.