Neverwinter Nights > Script Request
Pfft this script is irritating me....
(1/1)
Ser Red Ronnet Connington:
Im trying to make a script that==> when you open a chest, the script makes all the items within the chest droppable and identified.
This is my feeble attempt so far.
void main()
{
object oPC = GetLastOpenedBy();
if (!GetIsPC(oPC)) return;
object oTarget;
oTarget = OBJECT_SELF;
int nInt;
nInt = GetObjectType(oTarget);
object oItem = GetFirstItemInInventory(oTarget);
if (GetIsObjectValid(oItem) == TRUE)
{
SetDroppableFlag(oItem, TRUE);
oItem = GetNextItemInInventory(oTarget);
}
}
I finally got it to compile, lol and now it does not work. Can anyone help me make this script do its purpose, or if anyone has a similar script that sets all items in a chest or object droppable and identified plz post it. The point being i dont want to loose the items i store in the chest.
Elessar Telrunya:
ahhh, ser, I think the root of the problem is that your script should deal with loop statements, not if statements when it comes to setting them. I can help a little bit, but not much, because my understanding of how to work loops is limited and this is usually where I go to 420 or throbble for help.
The only two changes I feel safe telling you to make is to remove the int nInt identifier from the script because as far as I can tell, it does nothing in there. pretty much other than that its okay until the end - you forgot to use a command to make the item identified. After that last if statement is where the loop I was talking about comes in. basically, if you get a loop in there properly it'll keep going through each item in the inventory of the object and setting it to droppable and identified until there are no more items in the inventory.
-Elessar
Ser Red Ronnet Connington:
--- Quote ---ahhh, ser, I think the root of the problem is that your script should deal with loop statements, not if statements when it comes to setting them. I can help a little bit, but not much, because my understanding of how to work loops is limited and this is usually where I go to 420 or throbble for help.
The only two changes I feel safe telling you to make is to remove the int nInt identifier from the script because as far as I can tell, it does nothing in there. pretty much other than that its okay until the end - you forgot to use a command to make the item identified. After that last if statement is where the loop I was talking about comes in. basically, if you get a loop in there properly it'll keep going through each item in the inventory of the object and setting it to droppable and identified until there are no more items in the inventory.
-Elessar
[snapback]30695[/snapback]
--- End quote ---
Thx looking at similar scripts i think your right. I cant script the *loop* for this script so if anyone can help it would be greatly appreciated.
420:
Here you go, I included comments for all the changes I made so you can see what I did:
--- Code: ---//Make all items in a container droppable and identified
//By: 420
//July 31, 2006
void main()
{
//These following 2 lines aren't needed since NPCs normally don't open containers
object oPC = GetLastOpenedBy();
if (!GetIsPC(oPC)) return;
//Consolodated 2 lines into 1, declaration and initialization together
object oTarget = OBJECT_SELF;
//Not needed
/*
int nInt;
nInt = GetObjectType(oTarget);
*/
object oItem = GetFirstItemInInventory(oTarget);
//Changed if statement to while so it will cycle through all items
while(GetIsObjectValid(oItem) == TRUE)
{
//added line to ID the item
SetIdentified(oItem, TRUE);
SetDroppableFlag(oItem, TRUE);
oItem = GetNextItemInInventory(oTarget);
}
}
--- End code ---
-420
Ser Red Ronnet Connington:
--- Quote ---Here you go, I included comments for all the changes I made so you can see what I did:
--- Code: ---//Make all items in a container droppable and identified
//By: 420
//July 31, 2006
void main()
{
//These following 2 lines aren't needed since NPCs normally don't open containers
object oPC = GetLastOpenedBy();
if (!GetIsPC(oPC)) return;
//Consolodated 2 lines into 1, declaration and initialization together
object oTarget = OBJECT_SELF;
//Not needed
/*
int nInt;
nInt = GetObjectType(oTarget);
*/
object oItem = GetFirstItemInInventory(oTarget);
//Changed if statement to while so it will cycle through all items
while(GetIsObjectValid(oItem) == TRUE)
{
//added line to ID the item
SetIdentified(oItem, TRUE);
SetDroppableFlag(oItem, TRUE);
oItem = GetNextItemInInventory(oTarget);
}
}
--- End code ---
-420
[snapback]30700[/snapback]
--- End quote ---
Thx for the help 420. Unfornately all the items still disappear before I am able to equip them. Perhaps this has to do with another setting. All covered however in my email.
Navigation
[0] Message Index
Go to full version