Aller au contenu

Photo

Inventory Modification script help needed :)


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
DarkAnya

DarkAnya
  • Members
  • 83 messages
Hi guys!
I need a little help with a script which would cycle through six players and:
 a. delete all items worth less than 20K gold
 b. transfer all the rest of the items to a chest with a specific tag

I can do the "while" functions for selecting and cycling through players, but I don't know how to do inventory things like deleting the items worth less than 20k or transferring the others to another object.

Help? :)

#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Well, i haven't teseted this and I wasnt sure how you meant to only loop through six players, but this will loop through all the players on the server and do what you need. If i did it right:whistle:.
This is probably going to be a lag monster and not something you want to do all the time. Two loops inside a loop can't be good. But anyway:


void main()
{
    object oChest = GetObjectByTag("Tag of chest here");//put your chest's tag here
    object oPC = GetFirstPC();
    while (GetIsObjectValid(oPC))
    {
        object oItem;
        int iValue;
        oItem = GetFirstItemInInventory(oPC);
        while (GetIsObjectValid(oItem))
        {
            iValue = GetGoldPieceValue(oItem);
            if (iValue < 20000)
                DestroyObject(oItem);
            else
            {
                CopyItem(oItem, oChest, TRUE);
                DestroyObject(oItem);
            }
            oItem = GetNextItemInInventory(oPC);
        }

        int iSlot;
        for (iSlot=0; iSlot<NUM_INVENTORY_SLOTS; iSlot++)
        {
            oItem = GetItemInSlot(iSlot, oPC);
            iValue = GetGoldPieceValue(oItem);
            if (iValue < 20000)
                DestroyObject(oItem);
            else
            {
                CopyItem(oItem, oChest, TRUE);
                DestroyObject(oItem);
            }
        }
        oPC = GetNextPC();
    }
}


This also gets equipped items. Not sure if you wanted to get those as well.

Hope this helps.

NOTE: This will also destroy plot items. And when checking the gold cost value of an item that is not identified, it will get it's base value...not its idendified value. If these things need to be taken into consideration then let me know so we can update the script above.

Modifié par GhostOfGod, 03 novembre 2010 - 08:12 .


#3
DarkAnya

DarkAnya
  • Members
  • 83 messages
Thanks a lot! I'll try to test it and report back. :)

#4
DarkAnya

DarkAnya
  • Members
  • 83 messages
There is one other thing I thought of. Instead of putting everything in one chest, is it possible to split it between four chests, AT RANDOM? Like each item goes randomly into one of the four chests. That way the players have to find all four chests to retrieve their stuff?

#5
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Maybe something like so:

void main()
{
    object oChest1 = GetObjectByTag("Tag of chest1 here");
    object oChest2 = GetObjectByTag("Tag of chest2 here");
    object oChest3 = GetObjectByTag("Tag of chest3 here");
    object oChest4 = GetObjectByTag("Tag of chest4 here");
    object oPC = GetFirstPC();
    while (GetIsObjectValid(oPC))
    {
        object oItem;
        int iValue;
        int iRandom;
        oItem = GetFirstItemInInventory(oPC);
        while (GetIsObjectValid(oItem))
        {
            iValue = GetGoldPieceValue(oItem);
            if (iValue < 20000)
                DestroyObject(oItem);
            else
            {
                iRandom = d4();
                switch (iRandom)
                {
                    case 1: CopyItem(oItem, oChest1, TRUE); break;
                    case 2: CopyItem(oItem, oChest2, TRUE); break;
                    case 3: CopyItem(oItem, oChest3, TRUE); break;
                    case 4: CopyItem(oItem, oChest4, TRUE); break;
                }
                DestroyObject(oItem);
            }
            oItem = GetNextItemInInventory(oPC);
        }

        int iSlot;
        for (iSlot=0; iSlot<NUM_INVENTORY_SLOTS; iSlot++)
        {
            oItem = GetItemInSlot(iSlot, oPC);
            iValue = GetGoldPieceValue(oItem);
            if (iValue < 20000)
                DestroyObject(oItem);
            else
            {
                iRandom = d4();
                switch (iRandom)
                {
                    case 1: CopyItem(oItem, oChest1, TRUE); break;
                    case 2: CopyItem(oItem, oChest2, TRUE); break;
                    case 3: CopyItem(oItem, oChest3, TRUE); break;
                    case 4: CopyItem(oItem, oChest4, TRUE); break;
                }
                DestroyObject(oItem);
            }
        }
        oPC = GetNextPC();
    }
}

#6
DarkAnya

DarkAnya
  • Members
  • 83 messages
It seems to compile alright. But does it also take into consideration the objects that are equipped?

#7
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Yes it does.