Neve wrote:I can't seem to create a script for this, though it should be something really easy
I put the following in the OnActivateItem of the module :
Code: Select all
void main()
{
object oItem = GetItemActivated();
if(GetName(oItem) == "Berry")
DestroyObject(oItem);
}
But that doesn't work...
You're better off comparing to the Tag than the name, IMO, but it shouldn't matter that much. The thing you need to do in order to get this to be CALLED is to give the item the "unique power self only" spell ability. Thing is, why would someone use it if it gets destroyed the first time? You need to have it do something useful the first 5 times, and get destroyed only after the fifth, it seems.
Neve wrote:After that I put this in the OnRest, but that won't work either and is just plain inefficient...
Code: Select all
while (GetIsObjectValid(oItem) == TRUE){
if((GetName(oItem) == "Berry") && (GetItemCharges(oItem) == 0)){
SendMessageToPC(oPC, GetName(oItem));
SendMessageToPC(oPC, IntToString(GetItemCharges(oItem)));
DestroyObject(oItem);
}
oItem = GetNextItemInInventory(oPC);
}
I noticed that after using the item, which has 5 charges, the GetItemCharges(oItem) function still returns a 5 instead of a 0. Help with this would be greatly appreciated

Let's back up a step. What do you want the Berry to do exactly? Is it a necessary component to a player being able to Rest? If so, all you need to do is use your prior code block, with a couple additions.
Code: Select all
while (GetIsObjectValid(oItem) == TRUE){
if(GetName(oItem) == "Berry"){
if(GetItemCharges(oItem) <= 1)){ // if it's the last charge remaining, use it, and destroy it
SendMessageToPC(oPC, GetName(oItem));
SendMessageToPC(oPC, IntToString(GetItemCharges(oItem)));
DestroyObject(oItem);
} else { // decrement remaining charges
SetItemCharges(oItem,GetItemCharges(oItem)-1);
}
}
oItem = GetNextItemInInventory(oPC);
}
It seems that the reason it always had 5 charges is because none were getting used up? Does it have more than one power that has charges? I need more information to be more helpful.
Myk D'Vor