Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Error w/ random Item Giver

Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
11-03-2009 20:40
OK, pretty much, this is a prize giver and it works most of the time. The issue is about every 6 or so times it will pop up a script error " Unable to give inventory list: No items passed filter". I have read and re-read the wiki on this and understand it needs the llGetInventoryPermMask. These are items I made and of course are full perm for me and not scripted.
I thought maybe one of the items had an issue with perms so I checked them all and all are set correctly. What I dont understand is why it will work fine part of the time but not the other. The code is listed below.


//PHP//
list inventory;


get_inv_list()
{
integer i;
string name;

inventory = [];
for (i = 0; i < llGetInventoryNumber(INVENTORY_ALL); i++)
{
name = llGetInventoryName(INVENTORY_ALL, i);
if (name != llGetScriptName()) inventory += [name];
}
llOwnerSay("The following items are set to be given out: " + llList2CSV(inventory) + ".";);
if (llGetListLength(inventory) > 1)
llOwnerSay("These items will be put into a folder named " + llGetObjectName() + " when purchased. Rename this object to rename the folder.";);
}

default {

state_entry() {
get_inv_list();
llListen(96321,"",NULL_KEY,"";);

}

listen(integer channel, string name, key id, string m) {

integer num_items = llGetListLength(inventory);
integer random_item = (integer)llFrand(num_items + 1);


if (num_items > 1)

llGetInventoryPermMask("Prize 1", MASK_NEXT) & PERM_COPY;
llGetInventoryPermMask("Prize 2", MASK_NEXT) & PERM_COPY;
llGetInventoryPermMask("Prize 3", MASK_NEXT) & PERM_COPY;
llGetInventoryPermMask("Prize 4", MASK_NEXT) & PERM_COPY;
llGiveInventoryList(m, llGetObjectName(), [llList2String(inventory, random_item)]);

}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
get_inv_list();
}
}
//PHP//

Thanks for any insite you may be able to offer me.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-03-2009 21:31
Lists are numbered starting with zero and ending at llGetListLength(list)-1. It looks like you are creating a variable named random_item that is potentially greater than the index of the last element in the list, depending on what llFrand(num_items + 1) delivers.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
11-03-2009 22:09
After reading your response Rolig I realized 2 things, with the way I had it set the llFraund could come up with a 4 and only four items(0-3), plus I realized I had it set for Inventory_ALL and it should have been INVENTORY_OBJECT, it was also seeing the script and that is what was causing the script error.