#include "inc_mod_constant"
void main()
    {
    object oUser = GetLastUsedBy();
    object oScales = OBJECT_SELF;
    if (GetFactionLeader(oUser) == oUser)
        {
        int iPot,iGold,iSplit;
        int i,j;
        object oPC = GetFirstFactionMember(oUser);
        while (GetIsObjectValid(oPC))
            {
            j += 1;
            iGold = GetGold(oPC);
            iPot += iGold;
            TakeGoldFromCreature(iGold,oPC,TRUE);
            oPC = GetNextFactionMember(oUser);
            }
        iSplit = iPot/j;
        oPC = GetFirstFactionMember(oUser);
        while (GetIsObjectValid(oPC))
            {
            GiveGoldToCreature(oPC,iSplit);
            oPC = GetNextFactionMember(oUser);
            }
        if (EXPORT_CHARACTERS)
            ExportAllCharacters();
        }
    else
        AssignCommand(oUser,ActionExamine(oScales));
    }
