Author Topic: Pfft this script is irritating me....  (Read 4882 times)

Ser Red Ronnet Connington

  • Guest
Pfft this script is irritating me....
« on: July 31, 2006, 09:54:37 AM »
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.
« Last Edit: July 31, 2006, 10:01:33 AM by Ser Red Ronnet Connington »

Offline Elessar Telrunya

  • Hero Member
  • *****
  • Posts: 2095
    • View Profile
Pfft this script is irritating me....
« Reply #1 on: July 31, 2006, 11:04:29 AM »
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

  • Guest
Pfft this script is irritating me....
« Reply #2 on: July 31, 2006, 11:13:30 AM »
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]

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.

Offline 420

  • Hero Member
  • *****
  • Posts: 4087
    • View Profile
    • Email
Pfft this script is irritating me....
« Reply #3 on: July 31, 2006, 12:48:16 PM »
Here you go, I included comments for all the changes I made so you can see what I did:

Code: [Select]
//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);
    }
}

-420

Ser Red Ronnet Connington

  • Guest
Pfft this script is irritating me....
« Reply #4 on: July 31, 2006, 03:13:13 PM »
Quote
Here you go, I included comments for all the changes I made so you can see what I did:

Code: [Select]
//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);
    }
}

-420
[snapback]30700[/snapback]


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.