Use this code -- comments should explain what is happening:
void RewardPartyXP(int XP, object oPC, int bAllParty=TRUE)
{
// Make sure we're meant to give it to the whole party
if (bAllParty)
{
// Find the area of the party member who is the target
object oArea = GetArea(oPC);
// Get the first object in our loop
object oPartyMember = GetFirstFactionMember(oPC, TRUE);
while (GetIsObjectValid(oPartyMember) == TRUE)
{
// If the areas match...
if(oArea == GetArea(oPartyMember))
{
// Give the XP
GiveXPToCreature(oPartyMember, XP);
}
// Get the next party member
oPartyMember = GetNextFactionMember(oPC, TRUE);
}
}
// Otherwise we just give the XP to the original PC
else
{
GiveXPToCreature(oPC, XP);
}
}
Modifié par MagicalMaster, 21 novembre 2013 - 07:03 .