Concerning your respawn code, a few things to mention: A respawn script usually does not only apply gold and xp penalties, it also removes bad effects, restores hit points etc... This is not performed in the OnEnter script of an area, but in the respawn script of the module.
That being said, I will still assume you need the code in the OnEnter script of an area:
void ApplyPenalty(object oPC)
{
int nXP = GetXP(oPC);
int nLv = GetHitDice(oPC);
int nPenalty = 100 * nLv; // set xp penalty formula here
// * You can not lose a level with this respawning
int nMin = ((nLv * (nLv - 1)) / 2) * 1000;
int nNewXP = nXP - nPenalty;
if(nNewXP < nMin) nNewXP = nMin;
SetXP(oPC, nNewXP);
int nGoldToTake = FloatToInt(0.10 * GetGold(oPC)); // set gold penalty formula here
// * a cap of 10 000gp taken from you
if(nGoldToTake > 10000) nGoldToTake = 10000; // modify cap here
AssignCommand(oPC, TakeGoldFromCreature(nGoldToTake, oPC, TRUE));
}
void main()
{
object oPC = GetEnteringObject();
if(GetIsDM(oPC) || GetIsDMPossessed(oPC) || !GetIsPC(oPC)) return;
ApplyPenalty(oPC);
}
Kato