ZumeZero

[Function] Repeat PlayAudioStreamForPlayer

Jul 30th, 2014
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.35 KB | None | 0 0
  1. enum SongEnum
  2. {
  3.     LongSong,
  4.     Seconds,
  5.     UrlSong[128],
  6. };
  7. new SongInfo[MAX_PLAYERS][SongEnum];
  8.  
  9. stock StopMusicEx(playerid)
  10. {
  11.     SongInfo[playerid][LongSong] = -1;
  12.     StopAudioStreamForPlayer(playerid);
  13.     return 0;
  14. }
  15.  
  16. stock PlayMusicEx(playerid, str[], longsong)
  17. {
  18.     strmid(SongInfo[playerid][UrlSong], str, 0, 128, 128);
  19.     PlayAudioStreamForPlayer(playerid, SongInfo[playerid][UrlSong]);
  20.     SongInfo[playerid][Seconds] = longsong;
  21.     SongInfo[playerid][LongSong] = gettime()+SongInfo[playerid][Seconds];
  22.     return 1;
  23. }
  24.  
  25. forward RepeatSong(); public RepeatSong()
  26. {
  27.     for(new x = 0; x < MAX_PLAYERS; x++)
  28.     {
  29.         if(IsPlayerConnected(x))
  30.         {
  31.             if(SongInfo[x][LongSong] > 0)
  32.             {
  33.                 if(SongInfo[x][LongSong] < gettime())
  34.                 {
  35.                     SongInfo[x][LongSong] = gettime()+SongInfo[x][Seconds];
  36.                     PlayMusicEx(x, SongInfo[x][UrlSong], SongInfo[x][LongSong]);
  37.                 }
  38.             }
  39.         }
  40.     }
  41.     return 1;
  42. }
  43.  
  44. public OnGameModeInit()
  45. {
  46.     SetTimer("RepeatSong", 1000, true);
  47.     return 1;
  48. }
  49.  
  50. /* Example
  51.  
  52. public OnPlayerCommandText(playerid, cmdtext[])
  53. {
  54.     if (strcmp("/playsound", cmdtext, true, 10) == 0)
  55.     {
  56.         PlayMusicEx(playerid, "Url", Duration of the song);
  57.         return 1;
  58.     }
  59.     return 0;
  60. }
  61.  
  62. */
Add Comment
Please, Sign In to add comment