Try it like this and see if that works for ya:
EDIT: I did change it slightly. No offense to Baragg intended.
#include "nw_i0_plot"
void main()
{
int nToTake = 1; // Number of items to take.
string sTag = "misc001"; // Tag of items to take.
int iReward = FALSE;//Set to TRUE to give reward items to players
string sResRef = "Place_ResRef_of_Reward_Here"; // ResRef of item to give.
object oPC = GetPCSpeaker();
object oItem = GetFirstItemInInventory(oPC);
int nAmount;
// First, abort if oPC does not have enough items.
if ( GetNumItems(oPC, sTag) < nToTake )
{
SpeakString("You do not have any proof.");
return;
}
// Loop through oPC's inventory until enough items are taken
// (i.e. while something still needs to be taken).
// Checking for OBJECT_INVALID should not be needed, but it's a good safety measure.
while ( oItem != OBJECT_INVALID )
{// Only deal with items with the desired tag.
if ( GetTag(oItem) == sTag )
{// Determine what to do based on stack size.
nAmount = nAmount + GetItemStackSize(oItem);
DestroyObject(oItem, 0.1);
}
// Update the loop.
oItem = GetNextItemInInventory(oPC);
}
GiveGoldToCreature(oPC, 20*nAmount);
GiveXPToCreature(oPC, 20*nAmount);
if (iReward == TRUE)
{
while(nAmount > 0)
{
CreateItemOnObject(sResRef, oPC);
nAmount--;
}
}
}
Modifié par GhostOfGod, 23 mars 2011 - 02:53 .