Search code examples
linden-scripting-language

Getting the result of llGiveInventory


I have an LSL script that gives an object to a user using llGiveInventory(). Is there a way for my script to know if the user accepted or rejected the object?

In my viewer (Firestorm), when I accept the object being given I can see a message:

"Grid: Primitive owned by Test User gave you Pizza. Primitive is located at MyRegion <107.7737, 137.6579, 23.5>.

That message even shows up on the Conversation log, so it seems to appear as a message. I tried listening on channel 0 and DEBUG_CHANNEL, but both didn't hear the message.

Here's the current script:

string objName = "Pizza";
default {
    state_entry() {
        llListen(DEBUG_CHANNEL, "", NULL_KEY, "");
    }

    touch_start(integer num_detected) {
        llGiveInventory(llDetectedKey(0), objName);
    }

    listen (integer channel, string name, key id, string message) {
        llOwnerSay("Did you hear that?  I heard " + message);
    }
}

Solution

  • There is no way to know if the transaction failed. Unless you send a message when inventory is given to a prim and prim's script checks its inventory and sends a message back using llRegionSay. - LSL Wiki

    Unfortunately you cannot see whether the transaction was successful or not

    http://wiki.secondlife.com/wiki/LlGiveInventory