AgedAlchemist does bring up a good point though. I didn't figure in for players who still need to level and have more xp than required for leveling. If they trigger the above script it does in fact take the xp away.
However AgedAlchemists approach is slightly flawed as well. If someone is able to level their character and they repeatedly fire his script, they will keep getting 1,000 xp.
So a solution to both problems might be to do something like so:
void main()
{
object oPC = GetPCSpeaker();
int iLevel = GetHitDice(oPC);
int iXP = ((iLevel * (iLevel + 1)) / 2) * 1000;
if (iXP < GetXP(oPC))
SendMessageToPC(oPC, "You must first level up your character.");
else SetXP(oPC, iXP);
}
I think I thought it our right.
Modifié par GhostOfGod, 25 octobre 2010 - 08:43 .