Jump to content
  • 0

1 second delay after click?


Question

Posted
lunar01,219,180,4    script    Dreamworks Coins    807,5,5,{
            
            
            makeitem 1022, 10, "lunar01", rand(214, 217),rand(177,184);
            end;
    
    
OnTouch:
        makeitem 1022, 10, "lunar01", rand(214, 217),rand(177,184);
        end;
 
    }

 

How to enable a 1 second delay before the player can click again to prevent spamming or flood?

8 answers to this question

Recommended Posts

Posted (edited)

Little optimized

lunar01,219,180,4 script Dreamworks Coins 807,5,5,{
OnTouch:
    if ( @HD > gettimetick(2) ) end;
    makeitem 1022, 10, "lunar01", rand(214, 217),rand(177,184);
    set .@Delay,1;    // In Seconds
    if ( .@Delay ) set @HD, gettimetick(2)+.@Delay;
    end;
}

 

 

or

lunar01,219,180,4 script Dreamworks Coins 807,5,5,{
OnTouch:
	if ( @delay_item ) end;
	@delay_item = 1;
	makeitem 1022, 10, "lunar01", rand(214, 217),rand(177,184);
    sleep2 1000; // 1000 = 1 sec of delay
	@delay_item = 0; // automatically reset the variable
	end;
}
Edited by Capuche
  • Upvote 1
Posted (edited)

nar01,219,180,4 script Dreamworks Coins 807,5,5,{

if(gettimetick(2) < #delay) {
mes "you have to wait a minute.";
close;

makeitem 1022, 10, "lunar01", rand(214, 217),rand(177,184);
set #delay,gettimetick(2) + 60;
end;


OnTouch:
makeitem 1022, 10, "lunar01", rand(214, 217),rand(177,184);
set #delay,gettimetick(2) + 60;
end;
}

 

EDIT:

oh you wanted just a second...

so sir emistry is right^^

Edited by leertaste
  • Upvote 1
Posted (edited)


lunar01,219,180,4 script Dreamworks Coins 807,5,5,{

set .@Delay,1;    // In Seconds

​if (@HD > gettimetick(2)) end;

makeitem 1022, 10, "lunar01", rand(214, 217),rand(177,184);

end;

OnTouch:

makeitem 1022, 10, "lunar01", rand(214, 217),rand(177,184);

    if (.@Delay) set @HD, gettimetick(2)+.@Delay;

end;

}

Edited by Bipolar Bear
  • Upvote 1
Posted

Little optimized

lunar01,219,180,4 script Dreamworks Coins 807,5,5,{
OnTouch:
    if ( @HD > gettimetick(2) ) end;
    makeitem 1022, 10, "lunar01", rand(214, 217),rand(177,184);
    set .@Delay,1;    // In Seconds
    if ( .@Delay ) set @HD, gettimetick(2)+.@Delay;
    end;
}

 

 

or

lunar01,219,180,4 script Dreamworks Coins 807,5,5,{
OnTouch:
	if ( @delay_item ) end;
	@delay_item = 1;
	makeitem 1022, 10, "lunar01", rand(214, 217),rand(177,184);
    sleep2 1000; // 1000 = 1 sec of delay
	@delay_item = 0; // automatically reset the variable
	end;
}

Thank you! Works like a charm!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...