|
Lo Jacobs
Awesome Possum
Join date: 28 May 2004
Posts: 2,734
|
04-21-2009 15:03
Hi guys, so I'm trying to do this simple info kiosk thing where the person clicks on the sign, and gets a landmark, notecard, and gift. I want it to then email me when it gets clicked, so I can have a record. I did up this script, it's kind of a Frankenstein between a free GiveAllInventory and just the email thing on the LSLwiki. It works -- but only for the owner -- and it doesn't tell you *who* clicked on the thing, I just get a bunch of zeroes in place of a name. Can someone tell me what I'm doing wrong or repair it? Much appreciated string email_address = "email@address.com"; // email address
default { on_rez(integer p) { // When the object is rezzed.. // First, prompt the user. llInstantMessage(llGetOwner(), ""); // Then, reset, to get rid of stale listen handler. llResetScript(); } state_entry() { } touch_start( integer num_detected ) { integer i = 0; if (llDetectedKey(0)==llGetOwner()) {
// The contents of the object. list inventory = [];
// A list of all the types of inventory there are. list INVENTORY_CONSTANTS = [ INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_OBJECT, INVENTORY_SCRIPT, INVENTORY_LANDMARK, INVENTORY_CLOTHING, INVENTORY_NOTECARD, INVENTORY_BODYPART];
integer i; integer j; integer len = llGetListLength(INVENTORY_CONSTANTS); for (i = 0; i < len; i++) { // For every type of inventory...
integer constant = (integer) llList2String(INVENTORY_CONSTANTS, i); integer num = llGetInventoryNumber(constant);
for (j = 0; j < num; j++) { // For every inventory item of the type...
string name = llGetInventoryName(constant, j);
if (name != llGetScriptName()) { // Add it to the list of the object's contents. inventory += name; } } } // Now, the script has the names of every inventory item in its list.
string folderName = llGetObjectName() + ""; // Name of the folder to give user.
llGiveInventoryList(llGetOwner(), folderName, inventory); // Give the user the contents of the object. llInstantMessage(llGetOwner(), "Thank you for your interest! You'll find your information in your inventory in a folder called " + "'" + folderName + "'" + "."); // Alert the user.
llEmail( email_address, "InfoHub Accessed", "InfoPack was accessed by: " + llDetectedName(i) + "\nKey: " + (string) llDetectedKey(i) ); while(++i < num_detected);
} else llWhisper(0, "this item does not belong to you."); } }
_____________________
http://churchofluxe.com/Luster 
|
|
Lo Jacobs
Awesome Possum
Join date: 28 May 2004
Posts: 2,734
|
04-21-2009 15:30
I got an answer. Thank you! *waves excitedly* Here's the repaired code if anyone is interested ... string email_address = "email@address.com"; // email address
default { on_rez(integer p) { // When the object is rezzed.. // First, prompt the user. llInstantMessage(llGetOwner(), ""); // Then, reset, to get rid of stale listen handler. llResetScript(); } state_entry() { } touch_start( integer num_detected ) { integer user; string report = "InfoHub was accessed by:\n"; for (user=0;user<num_detected;++user) { // The contents of the object. list inventory = [];
// A list of all the types of inventory there are. list INVENTORY_CONSTANTS = [ INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_OBJECT, INVENTORY_SCRIPT, INVENTORY_LANDMARK, INVENTORY_CLOTHING, INVENTORY_NOTECARD, INVENTORY_BODYPART];
integer i; integer j; integer len = llGetListLength(INVENTORY_CONSTANTS); for (i = 0; i < len; i++) { // For every type of inventory...
integer constant = (integer) llList2String(INVENTORY_CONSTANTS, i); integer num = llGetInventoryNumber(constant);
for (j = 0; j < num; j++) { // For every inventory item of the type...
string name = llGetInventoryName(constant, j);
if (name != llGetScriptName()) { // Add it to the list of the object's contents. inventory += name; } } } // Now, the script has the names of every inventory item in its list.
string folderName = llGetObjectName() + ""; // Name of the folder to give user.
llGiveInventoryList(llDetectedKey(user), folderName, inventory); // Give the user the contents of the object. llInstantMessage(llDetectedKey(user), "Thank you for your interest! You'll find your information in your inventory in a folder called " + "'" + folderName + "'" + "."); // Alert the user. report += "\t" + llDetectedName(user) + "\nKey: " + (string) llDetectedKey(user) + "\n"; }
llEmail( email_address, "InfoHub Accessed", report); } }
_____________________
http://churchofluxe.com/Luster 
|
|
Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
|
04-21-2009 16:56
By the way, you don't need to define a whole list of every inventory item type. Simply use the INVENTORY_ALL constant. 
_____________________
Life is a highway... And I just missed my exit.
|
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
llGiveInventory() tip:
04-21-2009 20:13
You might also want to check for owner's permissions to be at least COPY + TRANS before adding an item to the list for giving. If it's no copy, it would poof when given... if it's no trans it will stay and not be given, but you might as well filter that out too. In this case, your inner loop would look something like this (added lines have been highlighted): for (j = 0; j < num; j++) { // For every inventory item of the type...
string name = llGetInventoryName(constant, j);
if (name != llGetScriptName()) { // // make sure it's both copy AND trans integer allowed = PERM_COPY | PERM_TRANSFER; integer perms = llGetInventoryPermMask(name, MASK_OWNER); if ((perms & allowed) == allowed) // // Add it to the list of the object's contents. inventory += name; } }
This would help prevent any accidental (and often puzzling) loss of no-copy items. ~Boss
|