Advertisement
HalestormXV

BlockPlayRandomSound

Oct 28th, 2017
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function init(event)
  2. {
  3. event.block.timers.stop(2);
  4. event.block.timers.start(2, 300, true);
  5. event.block.setModel("minecraft:planks");
  6. }
  7.  
  8. function randomGenWhole()
  9. {
  10. return Math.floor(Math.random() * 20);
  11. }
  12.  
  13. function randomIntFromInterval(min,max)
  14. {
  15.     return Math.floor(Math.random()*(max-min+1)+min);
  16. }
  17.  
  18. function timer(event)
  19. {    
  20.     if(event.id == 2)
  21.     {
  22.         var randomNumberGen = randomGenWhole();
  23.         if (randomNumberGen <= 8)
  24.         {
  25.             var selection = randomIntFromInterval(1, 4);  
  26.             switch(selection)
  27.             {
  28.             case 1:
  29.             event.block.executeCommand("/execute @a[r=64] ~ ~ ~ playsound CantSeeMe voice @a ~ ~ ~");
  30.             break;
  31.             case 2:
  32.             event.block.executeCommand("/execute @a[r=64] ~ ~ ~ playsound CreepyLaLa voice @a ~ ~ ~");
  33.             break;
  34.             case 3:
  35.             event.block.executeCommand("/execute @a[r=64] ~ ~ ~ playsound CreepyHum voice @a ~ ~ ~");
  36.             break;
  37.             default:
  38.             break;
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement