string CustomerListName = "*** PUT THE NAME OF THE NOTECARD WITH THE LIST OF CUSTOMERS HERE ***";
string GiveItem = "*** PUT THE NAME OF THE CONTENTS-ITEM TO GIVE THE CUSTOMERS HERE ***";
integer LineNo = 0;
key RequestID;
ReadCard()
{
if ((llGetInventoryType(CustomerListName) == INVENTORY_NOTECARD) && (llGetInventoryType(GiveItem) != INVENTORY_NONE))
{
LineNo = 0;
RequestID = llGetNotecardLine(CustomerListName, LineNo);
} else {
llSetText("Customer-list notecard '" + CustomerListName + "' or give-item '" + GiveItem + "' not in inventory, please check them", <1.0, 1.0, 1.0>, 1.0);
}
}
default
{
changed(integer Change)
{
if (Change & CHANGED_INVENTORY)
ReadCard();
}
dataserver(key ResponseID, string Data)
{
if (ResponseID == RequestID)
{
if (Data == EOF)
{
llSetText("Finished: gave to " + (string) LineNo + " customers", <1.0, 1.0, 1.0>, 1.0);
} else {
RequestID = llGetNotecardLine(CustomerListName, ++LineNo); // Requesting the next line before processing the current one speeds things up slightly
llSetText("Giving to customer #" + (string) LineNo + "; " + Data, <1.0, 1.0, 1.0>, 1.0);
llGiveInventory((key) Data, GiveItem);
}
}
}
state_entry()
{
ReadCard();
}
}