Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help count down

slave Bode
Registered User
Join date: 4 Feb 2007
Posts: 5
10-07-2007 11:08
Greetings everyone!!

Im an newbie scripter verry newbie, hope someone can help me whit this

I need an timer that counts down..but it must onely listen to the owner.
I must be able to set the time to count down in the chat line whit an comand like this "set time 60" for 60 minutes and when has count down to 0 it will say in the chat "time is over"

and it will allso be good if ite timer shows the count down time in an floating text..

Hope ther are some good scripter that can do this for me , i will be werry thankfull for it

and sorry for my bad spelling :)
Siann Beck
Beauty & Braiiiiinsss!
Join date: 14 Jul 2007
Posts: 140
10-07-2007 14:36
integer intTimer = 0;
integer intListenHandle;

default
{
state_entry() {
llSetText("Touch to set the time.", <1.0,1.0,1.0>, 1.0);
}

listen (integer intChannel, string strName, key keySpeaker, string strMessage) {
list lstTokens = llParseString2List(strMessage, [" "], []);

if (llList2String(lstTokens, 0) == "time";) {
intTimer = llList2Integer(lstTokens, 1);
llSetText("Time Remaining: " + (string)intTimer, <1.0,1.0,1.0>, 1.0);
llSetTimerEvent(1.0);
}

llListenRemove(intListenHandle);
}

touch_start(integer intDetected) {
if (llDetectedKey(0) != llGetOwner()) { return; }

llInstantMessage(llGetOwner(), "Enter /5time X in chat to start the timer.";);
intListenHandle = llListen(5, "", llGetOwner(), "";);
llSetTimerEvent(30.0);
}

timer () {
if (intListenHandle > 0) {
intListenHandle = 0;
llListenRemove(intListenHandle);
if (intTimer < 1) { return; }
}

if (intTimer-- < 1) {
llSetText("Touch to set the time.", <1.0,1.0,1.0>, 1.0);
llInstantMessage(llGetOwner(), "Time is over";);
llSetTimerEvent(0.0);
}

else {
llSetText("Time Remaining: " + (string)intTimer, <1.0,1.0,1.0>, 1.0);
}
}
}
slave Bode
Registered User
Join date: 4 Feb 2007
Posts: 5
10-08-2007 07:05
Thanks .. this is just waht i need ..
slave Bode
Registered User
Join date: 4 Feb 2007
Posts: 5
10-09-2007 07:10
From: Siann Beck
integer intTimer = 0;
integer intListenHandle;

default
{
state_entry() {
llSetText("Touch to set the time.", <1.0,1.0,1.0>, 1.0);
}

listen (integer intChannel, string strName, key keySpeaker, string strMessage) {
list lstTokens = llParseString2List(strMessage, [" "], []);

if (llList2String(lstTokens, 0) == "time";) {
intTimer = llList2Integer(lstTokens, 1);
llSetText("Time Remaining: " + (string)intTimer, <1.0,1.0,1.0>, 1.0);
llSetTimerEvent(1.0);
}

llListenRemove(intListenHandle);
}

touch_start(integer intDetected) {
if (llDetectedKey(0) != llGetOwner()) { return; }

llInstantMessage(llGetOwner(), "Enter /5time X in chat to start the timer.";);
intListenHandle = llListen(5, "", llGetOwner(), "";);
llSetTimerEvent(30.0);
}

timer () {
if (intListenHandle > 0) {
intListenHandle = 0;
llListenRemove(intListenHandle);
if (intTimer < 1) { return; }
}

if (intTimer-- < 1) {
llSetText("Touch to set the time.", <1.0,1.0,1.0>, 1.0);
llInstantMessage(llGetOwner(), "Time is over";);
llSetTimerEvent(0.0);
}

else {
llSetText("Time Remaining: " + (string)intTimer, <1.0,1.0,1.0>, 1.0);
}
}
}



Oki this script works werry well.. but
what if i want to pause and reset the timer whit an command in the chat line how can i add that to the script ?