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);
}
}
}