Jump to content
  • 0

1 second delay after click?


Currently

Question


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.04
  • Content Count:  313
  • Reputation:   1
  • Joined:  01/22/12
  • Last Seen:  

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?

Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

like this ?

sleep2 1000;
makeitem.........

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  41
  • Topics Per Day:  0.01
  • Content Count:  137
  • Reputation:   1
  • Joined:  02/02/13
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.04
  • Content Count:  313
  • Reputation:   1
  • Joined:  01/22/12
  • Last Seen:  

I tried sleep, but when I still keep clicking it. After the second sleep it kept spawning after.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  12
  • Reputation:   1
  • Joined:  03/22/13
  • Last Seen:  


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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.04
  • Content Count:  313
  • Reputation:   1
  • Joined:  01/22/12
  • Last Seen:  

Just to ask, what's the @HD on this script for?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

It's just a temporary variable that is attached to your character.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.04
  • Content Count:  313
  • Reputation:   1
  • Joined:  01/22/12
  • Last Seen:  

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!

Link to comment
Share on other sites

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.

×
×
  • Create New...