Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSetTimerEvent. Can't use it. "invalid key passed to instant message"

Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
01-10-2007 07:16
Hi everybody...

my intention is to avoid that my terminal will be blocked forever, so i added the setTimerEvent AFTER a resident touches my terminal(object). in case he forgets to finish his play the script resets itself after some minutes..that works very well

but before he can play he has to pay (pie-menu "pay";). then i recognized, if you pay but do not touch the terminal will also be blocked forever. so i thought just add another timerEvent after he payed and reset the script in case he just leaves. but then i get this error

"invalid key passed to instant message". what the hell ? how is that related to any IM ???

CODE


touched()
{
if (currentUser == llDetectedKey(0) || currentUser == NULL_KEY)
{
llSetTimerEvent(0);
llInstantMessage(llDetectedKey(0),"You are the current user of this terminal");
currentUser = llDetectedKey(0);
llSetTimerEvent(60);
name = llDetectedName(0);
integer ch = ChannelFromName(name);


llListen(ch,"",currentUser,"");
llDialog(llDetectedKey(0), "Pick a Number. Use the navigation buttons for different numbers! ", PC__01_09, ch);
}

else
{
llInstantMessage(llDetectedKey(0),"This system is already in use. Please use another terminal.");
}

}



default
{


state_entry()
{
llSetPayPrice(PAY_HIDE,[10,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
}


money(key giver, integer amount)
{

state payed;
}



state_exit()
{
llSetTimerEvent(30); //
llMessageLinked(LINK_ALL_CHILDREN, 0, "PAYED", NULL_KEY);
llSay(0,"Please TOUCH the keyboard to pick your numbers.");
}


}//default



state payed
{

state_entry()
{

currentUser = NULL_KEY;

}


touch_start(integer total_number)
{
touched();
}


listen(integer channel, string name, key id, string message)
{
integer ch = ChannelFromName(name);
listening(ch,name,id,message);
}



timer()
{
integer ch = ChannelFromName(name);
llInstantMessage(currentUser,"Time is up. You were logged off");


currentUser = NULL_KEY;
llResetScript();

}


state_exit()
{

}

}


thx so much for your help.....


regards...

PS: this is just a tiny part of my script...i think i got all relevant in here.... :)
Atashi Toshihiko
Frequently Befuddled
Join date: 7 Dec 2006
Posts: 1,423
01-10-2007 07:43
Hmm I could be wrong but I don't see anywhere that you are setting currentUser to anything but NULL_KEY. The first llSetTimerEvent in your touched() routine might be triggering the timer() event in state payed which is sending an IM to currentUser but if currentUser is still NULL_KEY then the IM can't go anywhere. Hence the error.

What is llSetTimerEvent(0) supposed to do? I don't think that cancels any current timers, I think it sets the timer inteval to zero.

-Atashi
Lexi Foley
Registered User
Join date: 1 Mar 2006
Posts: 43
01-10-2007 07:49
Hai as far as i see so quike you have

in state payed on state entry currentuser = nullkey
so if somebody payed,, the current user is set to be null key,,,
as long as the user dont touch it after paying it stays nullkey
and if the time is over it wants to sent a im to the null key what gives you the error,,,

i think you have to simplefy the script more,, and i also think you dont have to work whit somanny states,, you can also use switches,,

did not realy looked it trew but like i think its in the ....state payed / state entry
Lexi Foley
Registered User
Join date: 1 Mar 2006
Posts: 43
01-10-2007 07:56
From: Atashi Toshihiko

What is llSetTimerEvent(0) supposed to do? I don't think that cancels any current timers, I think it sets the timer inteval to zero.

-Atashi

this is a way of not letting the timer events to accure,
if i got it right its becouse its exely an error to set it on 0 that you use to stop it from happening
Idont know what the impact is on anny time delay or computing power,,, only know the timer event does not accure, i always try to avoid the 0 timer on default, but i realy dont know if that is posseble
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
01-10-2007 08:17
From: Lexi Foley
this is a way of not letting the timer events to accure,
if i got it right its becouse its exely an error to set it on 0 that you use to stop it from happening
Idont know what the impact is on anny time delay or computing power,,, only know the timer event does not accure, i always try to avoid the 0 timer on default, but i realy dont know if that is posseble


From the wiki:

From: someone

llSetTimerEvent(float sec)

Sets the timer event to be triggered every sec seconds. Passing 0.0 (or just 0) stops further timer events.
_____________________
Moonshine Herbst
none
Join date: 19 Jun 2004
Posts: 483
01-10-2007 09:02
Your problem is that llDetectedKey only works within the event.

Change your touched() function to: touched(key toucher)and use the toucher variable instead of llDetectedKey inside the function.
Then just call your touched function like this: touched(llDetectedKey(0));
_____________________

Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-10-2007 12:26
One question, why ar eyou bothering with the pay then touch operation?
if they have just paid you and no one else is using then just start the system at that point.
Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
01-10-2007 13:32
hmm what do u mean newgate? could u help me out with code ?
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
01-10-2007 13:40
Add:
CODE
currentUser = giver;

To your money() event :)
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
01-10-2007 13:54
THX...worked....now i can go to bed relieved :)

wish everyone a nice day