Advertisement
Guest User

player_music.sqf

a guest
Nov 18th, 2013
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. private ["_sound","_length","_pause","_enableAmbient","_minWaitTime","_maxWaitTime","_musicArray","_waitTimeDifference","_randomWait"];
  2. /////////////////////////////////////////////
  3. //// Vampire's Better Ambient Music v1 //////
  4. /////////////////////////////////////////////
  5.  
  6. // Enable Ambient music? true/false
  7. _enableAmbient = true;
  8.  
  9. // Minimum amount of time before running the next track (in seconds)
  10. // Default for my script is 10 minutes. (600 seconds)
  11. // Must be less than the maximum wait time.
  12. _minWaitTime = 60;
  13.  
  14. // Maximum amount of time before running the next track (in seconds)
  15. // Default for my script is 30 minutes. (1800 seconds)
  16. // Must be more than the maximum wait time.
  17. _maxWaitTime = 120;
  18.  
  19. // The array of your ambient tracks. These must match the class of a
  20. // cfgMusic entry either in the default DayZ cfgMusic or Description.ext
  21. // In your Mission.pbo. (Example: class bombs)
  22. // It will choose a random track from this array.
  23. _musicArray = ["Track_1", "Track_2", "Track_3","Track_4","Track_5","Track_6","Track_7","Track_8","Track_9"];
  24.  
  25. while {!r_player_dead && _enableAmbient} do {
  26. // Pick a sound
  27. _sound = _musicArray select floor random count _musicArray;
  28.  
  29. // Get it's length from the cfgMusic/Description.ext
  30. _length = getNumber(configFile >> "cfgMusic" >> _sound >> "Duration");
  31.  
  32. // Lets figure out the random wait time
  33. _waitTimeDifference = ((_maxWaitTime) - (_minWaitTime));
  34. _randomWait = (random (_waitTimeDifference));
  35. _pause = (_randomWait) + (_length);
  36.  
  37. // Play the song
  38. if (!r_player_unconscious and !r_pitchWhine) then {
  39. playMusic _sound;
  40. };
  41.  
  42. // Let the script sleep the song length and the random amount of time
  43. sleep _pause;
  44. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement