Currently Posted March 22, 2013 Posted March 22, 2013 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? Quote
Capuche Posted March 22, 2013 Posted March 22, 2013 (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 March 22, 2013 by Capuche 1 Quote
Emistry Posted March 22, 2013 Posted March 22, 2013 like this ? sleep2 1000; makeitem......... 1 Quote
leertaste Posted March 22, 2013 Posted March 22, 2013 (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 March 22, 2013 by leertaste 1 Quote
Currently Posted March 22, 2013 Author Posted March 22, 2013 I tried sleep, but when I still keep clicking it. After the second sleep it kept spawning after. Quote
Bipolar Bear Posted March 22, 2013 Posted March 22, 2013 (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 March 22, 2013 by Bipolar Bear 1 Quote
Currently Posted March 22, 2013 Author Posted March 22, 2013 Just to ask, what's the @HD on this script for? Quote
nanakiwurtz Posted March 22, 2013 Posted March 22, 2013 It's just a temporary variable that is attached to your character. Quote
Currently Posted March 23, 2013 Author Posted March 23, 2013 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! Quote
Question
Currently
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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.