Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with gifts script

Abdullah Lemon
Lemons Estates
Join date: 2 Oct 2008
Posts: 56
11-23-2008 20:33
Good day SLers...

i've written this script.. but for some reason it do wanna give inentory... i mean.. it works find everything goes as expected... but it does not give inventory... i cant figure out whast seems to be the problem..

so can anyone help me with it.. and explaining the error is highly appreciated... :-)



From: someone
list gifts = ["Human - Shirt", "Muffin - Shirt", "Cupcake - Shirt"];
string msg = "Please select your gift.";

key ToucherID;
integer channel;
integer listen_id;
default{
state_entry() {
channel = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
}

touch_start(integer total_number) {
llSay(0,"Please note that you have 30 seconds to make your message!";);
ToucherID = llDetectedKey(0);
llDialog(ToucherID, msg,gifts, channel);
listen_id = llListen( channel, "", ToucherID, "";);
llSetTimerEvent(30);
}


listen(integer channel, string name, key id, string message) {
if (message == "Human - Shirt";) {
llGiveInventory(llDetectedKey(0),"Human";);
llSay(0, "Thank you " + name +", your gift '" + message + "' will be delivered shortly";);
}
else if (message == "Muffin - Shirt";) {
llGiveInventory(llDetectedKey(0),"Muffin";);
llSay(0, "Thank you " + name +", your gift '" + message + "' will be delivered shortly";);
}
else{
llGiveInventory(llDetectedKey(0),"cupcake";);
llSay(0, "Thank you " + name +", your gift '" + message + "' will be delivered shortly";);
}
llListenRemove(listen_id);
}

timer() { //TIME!
llListenRemove(listen_id);
llWhisper(0, "We are sorry, you took too long to select your gift";);
llResetScript();
}
}
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-23-2008 21:00
Does it say the Thank You message, or does it hang before it gets to the listen event? Are the items named "Human," "Muffin," and "cupcake" all in the object's inventory and spelled exactly that way, and are they all transferrable items?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-23-2008 21:46
ps
if you turn off "enhanced interface" (user cp --> edit option) the forum wont try to reformat your indents for code (basic editor works best, doesn't reformat img tags for linking while editing either)

btw, interesting method of random channel selection
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Abdullah Lemon
Lemons Estates
Join date: 2 Oct 2008
Posts: 56
11-23-2008 22:02
Rolig Loon->
it does say thank you... everything works great.. but the objects are not givin.... and yes the names are exactly as they are described in the script.

Void Singer->
thank you sir for the tip :)

and thank you again for the compliment... i got this method from lsl :)
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
11-23-2008 22:28
a common problem i see people do. you can't use llDetectedKey in a listen event. llDtected* functions only work in touch, collision, and sensor events. in your script in the listen event you simply need to change llDetectedKey(0) to id
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Abdullah Lemon
Lemons Estates
Join date: 2 Oct 2008
Posts: 56
11-23-2008 23:01
From: Ruthven Willenov
a common problem i see people do. you can't use llDetectedKey in a listen event. llDtected* functions only work in touch, collision, and sensor events. in your script in the listen event you simply need to change llDetectedKey(0) to id


what do you mean? i'm sorry sir.. i'm just absent minded.. lol
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
11-23-2008 23:21
this should work

From: someone

list gifts = ["Human - Shirt", "Muffin - Shirt", "Cupcake - Shirt"];
string msg = "Please select your gift.";

key ToucherID;
integer channel;
integer listen_id;
default{
state_entry() {
channel = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
}

on_rez(integer start_param)
{
llResetScript();//added this so it resets the script on rez
}

touch_start(integer total_number) {
llSay(0,"Please note that you have 30 seconds to make your message!";);
ToucherID = llDetectedKey(0);
llDialog(ToucherID, msg,gifts, channel);
listen_id = llListen( channel, "", ToucherID, "";);
llSetTimerEvent(30);
}


listen(integer channel, string name, key id, string message) {
if (message == "Human - Shirt";) {
llGiveInventory(id,"Human";);
llSay(0, "Thank you " + name +", your gift '" + message + "' will be delivered shortly";);
}
else if (message == "Muffin - Shirt";) {
llGiveInventory(id,"Muffin";);
llSay(0, "Thank you " + name +", your gift '" + message + "' will be delivered shortly";);
}
else{
llGiveInventory(id,"cupcake";);
llSay(0, "Thank you " + name +", your gift '" + message + "' will be delivered shortly";);
}
llListenRemove(listen_id);
}

timer() { //TIME!
llListenRemove(listen_id);
llWhisper(0, "We are sorry, you took too long to select your gift";);
llResetScript();
}
}
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-23-2008 23:57
heh I got called sir... hehe

ya know I looked right at that and didn't even notice it... R's right of course, listen gets one source at a time, unlike touches and sensors which get stacked references.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Abdullah Lemon
Lemons Estates
Join date: 2 Oct 2008
Posts: 56
11-24-2008 00:04
From: Void Singer
heh I got called sir... hehe

ya know I looked right at that and didn't even notice it... R's right of course, listen gets one source at a time, unlike touches and sensors which get stacked references.



OMG.. i'm so sorry.. i didnt even think of that.. i'm at work.. and i'm sooo sleeeepy right now..

and thank you guys for the help... i really appreciate it.