Advertisement
peacestorm

ModPE countdown

May 22nd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
  2. var seconds = 3;
  3.  
  4. function countdown() {
  5.     ctx.runOnUiThread(new java.lang.Runnable({
  6.         run: function() {
  7.             new android.os.Handler()
  8.                 .postDelayed(new java.lang.Runnable({
  9.                     run: function() {
  10.                         if(seconds > 0) {
  11.                             clientMessage(seconds + "...");
  12.                             seconds--;
  13.                             eval(countdown());
  14.                         } if(seconds == 0) {
  15.                             clientMessage(seconds + "...");
  16.                             afterCountdownHook();
  17.                         }
  18.                     }
  19.                 }), 1000);
  20.         }
  21.     }))
  22. };
  23.  
  24. //call countdown() whenever you want to start the countdown
  25.  
  26. function afterCountdownHook() {
  27.     //this hook will run when the countdown ends
  28.     //add your own code here
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement