Limiting pc advancement based on criteria

What it does
This script will allow you to prevent a PC from advancing beyond a certain level in a class based on whatever criteria you choose. For the example I'll say that female Half-Orcs cannot advance beyond level 5 in wizard classes.

The Script
Put the script in the 'OnPlayerLevelUp' event in your module properties:

//::////////////////////////////////////////////// //:: Created By: Zephrym //:: Created On: 18 Aug 2002 //::////////////////////////////////////////////// void main {   object oPC = GetPCLevellingUp; int nClassLvl = GetLevelByClass(CLASS_TYPE_WIZARD, oPC); int nXP = GetXP(oPC); int nAdj = 0; int n; // Calculates the minimum XP needed for current level for(n=0;n 5){ AssignCommand(oPC, ClearAllActions); SetXP(oPC, nAdj - 500); DelayCommand(1.0, SetXP(oPC, nXP)); FloatingTextStringOnCreature("You cannot advance beyond wizard level "+ IntToString(nClassLvl)+" as a female Half-Orc.", oPC, FALSE); } }

Note
It works like a charm. Obviously, you have to change the ints to something you want to test for but it's all there and easily expandable to include anything you can query about the PC.

Update: You can use a number as small as 1 for the script if you want since the loop calculates the exact XP for the current HD.

For reference, the OnPlayerLevelUp script fires AFTER the player completes the level up selection process.