Finally, i get it. Thanks you , Tarot_Redhand
That is the way to script it
void main()
{
object oSpawn;
object oPC = GetLastKiller();
int iRandomLoot = d3();
while(GetIsObjectValid(GetMaster(oPC)))
{
oPC = GetMaster(oPC);
}
if(GetIsPC(oPC))
{
object oTarget;
object oSpawn;
location lTarget;
oTarget = OBJECT_SELF;
lTarget = GetLocation(oTarget);
switch(iRandomLoot) // give random loot
{
case 1:
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "goldpile", lTarget);
break;
case 2:
oSpawn = CreateObject(OBJECT_TYPE_ITEM, "potion", lTarget);
break;
case 3:
oSpawn = CreateObject(OBJECT_TYPE_ITEM, "scroll", lTarget);
break;
}
}
}