Basically, I needed a script that would hand out a one use demo item. But I didn't want people to just "load up" with bunches of demos, rather eliminating the need to buy an item with unlimited uses. So, I wrote the following, which also demonstrates basic use of lists.
CODE
list givelist;
integer delay=3600;//timer in seconds between clearing the list of people who received a demo; here it is an hour.
default
{
state_entry()
{
llSetTimerEvent(delay);
}
touch_start(integer total_number)
{
list receiver=[llDetectedKey(0)];
// to give a different inventory item type,
// replace "INVENTORY_OBJECT" with "INVENTORY_NOTECARD", etc.
if(llListFindList(givelist, receiver)== -1)
{
llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_OBJECT, 0));
llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_NOTECARD, 0));
llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_LANDMARK, 0));
llWhisper(0,"Look for 'Demo' in your inventory");
givelist=givelist+receiver;
}
else llWhisper(0,"Sorry, only one demo an hour per person");
}
timer()
{
givelist=[];
}
}
If anyone sees any gaps in this, do let me know
Happy demoing!