Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
11-14-2005 08:44
Is this even possible? Basically I have object which people can drop items onto, but I want it to delete items not owned by a particular person. However, I can't see to retrieve the owner key of an inventory item, only the creator key which isn't quite what I wanted (as in theory a malicious user could copy a notecard by the owner in question, change it's contents and drop it onto my object, and it would be accepted quite happily even though it reads "Haravikk Mistral is a poo!" I tried doing: key id = llGetOwnerKey(llGetInventoryKey("Notecard Name"  ); But it returns the object's id and not it's owner's (presumably because the object isn't rezzed, but placed in another object's inventory). Is there a way to tell who owns or gave an object without resorting to sensors to try and keep tabs on who's nearby? This seems like a fairly obvious thing missed out =(
|
Harris Hare
Second Life Resident
Join date: 5 Nov 2004
Posts: 301
|
11-14-2005 09:01
The following code from Strife Onizuka has the best solution available for detecting who dropped an item. It requires users to click the object first. Not perfect but it's currently the best way at guessing who dropped an item. string user_name; key user_key;
default { state_entry() { llSetTimerEvent(0.1); } touch_start(integer a) { user_name = llDetectedName(0); user_key = llDetectedKey(0); llAllowInventoryDrop(1); llSetTimerEvent(20); llSetText("Please drop inventory "+user_name,<1.0,1.0,1.0>,1.0); } changed(integer a) { if(a & CHANGED_ALLOWED_DROP) { //was "user" } else if(a & CHANGED_INVENTORY) { //was the owner or another user with mod rights to your objects } llSetTimerEvent(1.0);//this is so they can drop multiple items without it loosing the setting. } timer() { llSetText("Please click object first before dropping inventory",<1.0,1.0,1.0>,1.0); llAllowInventoryDrop(0); llSetTimerEvent(0.0); user_key = user_name = ""; } }
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
11-14-2005 09:48
Hmm, not particularly elegant =( I think I've decided to go for a sensor based method combined with the creator key. Since the objects are custom textures (for an advertisment) and optionally a landmark and/or notecard, all these items should be created by the ad's 'owner' anyway. So what I think I will do is have it cast out a sensor to find if the creator is in range, if so then fine, if not then it's an item copied by someone and potential maliciously altered. It only has to look for one key so that's okay, and it actually has the side-effect of breaking up my inventory code a bit (it's messy but there's no clear way to break it down into functions). Thanks for posting that code though! But I don't think it's quite perfect either, as anyone could drop an item in after it's been touched. A minor concern I know since the owner would have to be there, but still a potential exploit. Here's the format of the code I'll be using: changed(integer type) { if (type & CHANGED_ALLOWED_DROP) { sensor ("",owner,AGENT,96.0,PI); } sensor (integer x) { // It was our owner, go through the items removing any created by someone else } no_sensor () { // Our owner wasn't nearby! Destroy all new items } } Just in case that's useful to anyone!
|
Gaz Hornpipe
Registered User
Join date: 29 Sep 2005
Posts: 36
|
11-14-2005 10:45
Provided the object/notecards that are being dropped into the object were created by the person you are trying to check for, you could try using the key llGetInventoryCreator(string item) function call. Though in the past there have been some issues concerning NULL creators, where it says the creator = (none). Worth a try though.
|