Jump to content

Funky countdown timer issue


xxQUAKExx
 Share

You are about to reply to a thread that has been inactive for 1527 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello and thanks for your time,

 

I have been following along clipping and cutting parts of scripts and pasting them in, what might turn out to be a decent turnout.

With that said I have an issue with an pay script that pays person when touched. I pasted into it a countdown timer to pay after time reaches 0 and it does just that! it works in that sense. My problem now is that after it pays out i want it to become functional again for another person to touch it. My problem is after it is touched once the counter counts ... 10, -01, -02, -03, ect.

i had placed a call to reset the script but it then asks me for debt permission.

Any ideas would be helpful,

 

integer giCountDownTime = 10;
float gfCountDownIncrements = 1;
integer giStartTime;
integer giRounds;
integer limit = 4; //in meters
key id;
integer amount = 1; // amount to give

default
{
    on_rez( integer param )
    {
        llResetScript();
    }
    
    state_entry()
    {
    llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
    }
touch_start(integer total_number) {
        id = llDetectedKey(0);
        integer number = 0;
        vector mypos = llGetPos();
        vector yourpos = llList2Vector(llGetObjectDetails(llDetectedKey(0), [OBJECT_POS]), 0);
        if (llVecDist(mypos,yourpos)>(float)limit)
        {
            //avatar is too far away
            llInstantMessage(llDetectedKey(0), "You are too far away.  Move closer and touch again.");
       } else  {
        llSetText((string)giCountDownTime + " ...", <1.0, 1.0, 1.0>, 1.0);
        llSetTimerEvent(gfCountDownIncrements);
        giStartTime = llGetUnixTime();
    }}
    
    timer() {
        if (llGetUnixTime() >= giStartTime +giCountDownTime) {
            llGiveMoney(id, amount);
            llSetTimerEvent(0);
            llSleep(1.0);
            // llDie(); might go here //
            } else  {
            giRounds++;
            llSetText((string)(giCountDownTime -  giRounds) + " ...", <1.0, 1.0, 1.0>, 1.0);;


        }
    }
}

Link to comment
Share on other sites

Your countdown is continuing into the negatives because you never reset the giRounds variable to 0 when the game ends.

Edit: and it jumps from 10 to -1 because on the touch event, you set the hovertext to giCountDowntime, which is always 10, but then when the timer event fires, the text is set to (giCountDowntime - giRounds) which at that point is (10-11) or -1

Edited by Fenix Eldritch
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1527 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...