Advertisement
Gayngel

Jukebox play sound only once

Apr 28th, 2016
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. integer Touched;
  2. integer listen_handle;
  3. integer chan = -90;
  4. key Toucher;
  5.  
  6. Dialog()
  7. {
  8. llListenRemove(listen_handle);
  9. listen_handle = llListen(chan, "", Toucher, "");
  10. llSetTimerEvent(120.0);
  11. llDialog(Toucher,"\nSelect an option:",["Play","Stop"],chan);
  12.  
  13. }
  14.  
  15. default
  16. {
  17. touch_end(integer num)
  18. {
  19. Toucher = llDetectedKey(0);
  20. Dialog();
  21.  
  22. }
  23.  
  24.  
  25. listen(integer channel, string name, key id, string msg)
  26. {
  27.  
  28. if(channel == chan)
  29. {
  30.  
  31. if(msg == "Play")
  32. {
  33.  
  34.  
  35. if(!Touched)
  36. {
  37.  
  38. Touched = TRUE;
  39. llPlaySound(llGetInventoryName(INVENTORY_SOUND, 0), 1.0);
  40. Dialog();
  41. }
  42.  
  43. else
  44. {
  45.  
  46. Dialog();
  47.  
  48. }
  49.  
  50. }
  51.  
  52. else if(msg == "Stop")
  53. {
  54.  
  55. Touched = FALSE;
  56. llStopSound();
  57. llListenRemove(listen_handle);
  58. }
  59.  
  60. }
  61.  
  62. }
  63.  
  64. timer()
  65. {
  66.  
  67. llListenRemove(listen_handle);
  68.  
  69. }
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement