Help with GenerateNpcTreasure

Hi, im a bit confused about the GenerateNpcTreasure function.
I want to spawn a npc with loot but cant figure this one out. help appreciated!

Script:

oCreature=CreateObject(OBJECT_TYPE_CREATURE, CreatureRef, Spawnpoint, FALSE);
int nTreasureValue = 4;
object oTreasureGetter = oCreature;
object oKiller = OBJECT_SELF;
GenerateNPCTreasure(nTreasureValue, oTreasureGetter, oKiller)

Reading the Lexicon It would seem that the best place to call GenerateNPCTreasure() is in the OnSpawn event for that creature. This means that you are better off creating a custom version of that creature in the palette using edit copy and adding your script to it. So you would make a small script like -

#include "nw_o2_coninclude"

void main()
{
    GenerateNPCTreasure(4);
}

Call it whatever you want and on your custom creatures properties, under the scripts tab, find the OnSpawn event and click the button with … on it. Click that and select your little script. Now when you run -

    object oCreature = CreateObject(OBJECT_TYPE_CREATURE, CreatureRef, Spawnpoint, FALSE);

your NPC will spawn with the treasure on it.

TR