Graf_Spee

[INC] gRandomMusic

Oct 6th, 2013
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.00 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. forward StopMusic(playerid);
  4. forward StartAnother(playerid);
  5.  
  6. new TimerContinuous[MAX_PLAYERS];
  7.  
  8. // Links sem o goo.gl
  9. /*new gPop1[15][] =
  10. {
  11.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=quxzO3oxOfI&r=cnRzcDovL3IxLS0tc24tbzA5N3p1ZXouYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUW55T1RGNk8zUHNxaE1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Don"}, // Don't You Worry Child
  12.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=AEh3zEMYKzA&r=cnRzcDovL3I3LS0tc24tamM0N2V1N2QuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUWt3S3hoRHpIZElBQk1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Feel%20So%20Close%20-%20Calvin%20Harris%20[OFFICIAL%20LYRICS]&t=218"}, //Feel So Close
  13.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=zm3lUhxzxL8&r=cnRzcDovL3I4LS0tc24tbzA5N3p1ZXouYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUW1feEhNY1V1VnR6aE1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Make%20It%20Bun%20Dem%20-%20Skrillex%20ft.%20Damian%20Jr%20Gong%20Marley%20-%20Lyrics%20[HQ/HD]&t=214"}, //Make It Bun Dem
  14.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=CXwY5HxYC3k&r=cnRzcDovL3I2LS0tc24tamM0N2V1N2QuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUWw1QzFoODVCaDhDUk1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Pitbull%20ft%20Christina%20Aguilera%20-%20Feel%20This%20Moment%20(Lyrics)&t=231"}, //Feel This Moment
  15.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=1m8bBP1l1_c&r=cnRzcDovL3IxLS0tc24tbzA5N3p1ZXouYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUW4zMTJYOUJCdHYxaE1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Skrillex%20-%20\%22First%20of%20the%20Year%20(Equinox)\%22"}, // First of The Year (Equinox)
  16.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=NnIzbukJOHQ&r=cnRzcDovL3I0LS0tc24tbzA5N3p1ZWwuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUWwwT0FucGJqTnlOaE1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Calvin%20Harris%20ft.%20Florence%20Welch-%20Sweet%20Nothing%20LYRICS&t=209"}, // Sweet Nothing
  17.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=ohNoKZNh__8&r=cnRzcDovL3I3LS0tc24tamM0N2V1NzYuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUW5fXzJHVEtXZ1RvaE1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Just%20One%20Last%20Time%20-%20Lyrics&t=230"}, // Just One Last Time
  18.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=bKFmLwjLp8s&r=cnRzcDovL3IyLS0tc24tbzA5N3p1ZXMuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUW5McDhzSUwyYWhiQk1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Swedish%20House%20Mafia%20-%20Save%20The%20World%20(Tonight)"}, // Save The World
  19.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=R6Pn0BCK5GE&r=cnRzcDovL3I1LS0tc24tbzA5N3p1ZWUuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUWxoNUlvUTBPZWpSeE1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Afrojack%20-%20Can"}, // Can't Stop Me
  20.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=T3553DGF71g&r=cnRzcDovL3I3LS0tc24tamM0N2V1NzYuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUWxZNzRVeDNIbC1UeE1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Give%20Me%20Everything%20(Tonight)%20-%20Pitbull%20ft.%20Neyo, %20Nayer%20&t=247"}, // Give Me Everything
  21.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=SHO3dE-IDWk&r=cnRzcDovL3IyLS0tc24tbzA5N3p1ZXMuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUWxwRFloUGRMZHpTQk1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Calvin%20Harris%20feat.%20Example%20-%20We"}, //We'll Be Coming Back
  22.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=pz4Gd_u98ok&r=cnRzcDovL3I0LS0tc24tamM0N2V1N2QuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUW1KOHIzN2R3WS1weE1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=\%22Don"}, // Don't Stop The Party
  23.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=khVcJLLPPwA&r=cnRzcDovL3IyLS0tc24tbzA5N3p1ZXMuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUWtBUDgteUpGd1ZraE1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Swedish%20House%20Mafia%20-%20Miami%202%20Ibiza%20(lyrics%20video)&t=147"}, // Miami 2 Ibiza
  24.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=7gSW5J8kbuI&r=cnRzcDovL3I3LS0tc24tamM0N2V1NzYuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUW5pYmlTZjVKWUU3aE1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Avicii%20feat.%20Aloe%20Blacc%20-%20Wake%20Me%20Up%20(Official%20Video%20%20%20Lyrics)&t=252"}, // Wake Me Up
  25.     {"http://baixar.mixmusicas.com.br/alternativa.php?id=h5EofwRzit0&r=cnRzcDovL3I1LS0tc24tamM0N2V1N3IuYy55b3V0dWJlLmNvbS9DaUlMRU55NzN3SWFHUW5kaW5NRWZ5aVJoeE1ZRVNBUkZFZ0dVZ1oyYVdSbGIzTU0vMC8wLzAvdmlkZW8uM2dw&n=Daft%20Punk%20-%20Get%20Lucky%20(Full%20Video)&t=248"} // Get Lucky
  26. };*/
  27.  
  28. // Links com o goo.gl
  29. new gPop[15][] =
  30. {
  31.     {"http://goo.gl/RoKy2k"}, // Don't You Worry Child
  32.     {"http://goo.gl/MzPVgK"}, //Feel So Close
  33.     {"http://goo.gl/ZboC0d"}, //Make It Bun Dem
  34.     {"http://goo.gl/Ghuq6o"}, //Feel This Moment
  35.     {"http://goo.gl/T3BuUl"}, // First of The Year (Equinox)
  36.     {"http://goo.gl/sJAX52"}, // Sweet Nothing
  37.     {"http://goo.gl/c6X6VQ"}, // Just One Last Time
  38.     {"http://goo.gl/hdR3cm"}, // Save The World
  39.     {"http://goo.gl/7iDB4g"}, // Can't Stop Me
  40.     {"http://goo.gl/GSevOX"}, // Give Me Everything
  41.     {"http://goo.gl/auMKTC"}, //We'll Be Coming Back
  42.     {"http://goo.gl/nBIxrC"}, // Don't Stop The Party
  43.     {"http://goo.gl/NUeyO2"}, // Miami 2 Ibiza
  44.     {"http://goo.gl/SPxV34"}, // Wake Me Up
  45.     {"http://goo.gl/ybplgZ"} // Get Lucky
  46. };
  47.  
  48. new gPopDuration[15] =
  49. {
  50.     208,
  51.     217,
  52.     214,
  53.     230,
  54.     262,
  55.     208,
  56.     229,
  57.     194,
  58.     382,
  59.     247,
  60.     232,
  61.     205,
  62.     147,
  63.     165,
  64.     248
  65. };
  66.  
  67. new gPopNames[15][] =
  68. {
  69.     {"Don't You Worry Child"},
  70.     {"Feel So Close"},
  71.     {"Make It Bun Dem"},
  72.     {"Feel This Moment"},
  73.     {"First of The Year (Equinox)"},
  74.     {"Sweet Nothing"},
  75.     {"Just One Last Time"},
  76.     {"Save The World"},
  77.     {"Can't Stop Me"},
  78.     {"Give Me Everything"},
  79.     {"We'll Be Coming Back"},
  80.     {"Don't Stop The Party"},
  81.     {"Miami 2 Ibiza"},
  82.     {"Wake Me Up"},
  83.     {"Get Lucky"}
  84. };
  85.  
  86. public StopMusic(playerid)
  87. {
  88.     StopAudioStreamForPlayer(playerid);
  89.     SendClientMessage(playerid, -1, "Parou");
  90.     if(TimerContinuous[playerid] != 0)
  91.     {
  92.         KillTimer(TimerContinuous[playerid]);
  93.         TimerContinuous[playerid] = 0;
  94.     }
  95.     return 1;
  96. }
  97.  
  98. public StartAnother(playerid)
  99. {
  100.     ContinuousMusicForPlayer(playerid);
  101.     return 1;
  102. }
  103.  
  104. stock IsNumeric(const string[])
  105. {
  106.     for (new i = 0, j = strlen(string); i < j; i++)
  107.     {
  108.         if (string[i] > '9' || string[i] < '0') return 0;
  109.     }
  110.     return 1;
  111. }
  112.  
  113. stock PlayMusic(playerid, musicid[])
  114. {
  115.     if(IsNumeric(musicid))
  116.     {
  117.         new musicid1 = strval(musicid);
  118.         if(musicid1 > sizeof(gPop)) return 0;
  119.         PlayAudioStreamForPlayer(playerid, gPop[musicid1], 0, 0, 0, 0, 0);
  120.         new Music[56];
  121.         format(Music, 256, "Você está ouvindo: {FF0000}%s", gPopNames[musicid1]);
  122.         SendClientMessage(playerid, -1, Music);
  123.         SendClientMessage(playerid, -1, "Talvez a música possa demorar a começar. Isto vai depender da sua Internet [...]");
  124.         SendClientMessage(playerid, -1, "[...] E da disponibilidade do Servidor onde elas esão hospedadas/são convertidas.");
  125.     }
  126.     else
  127.     {
  128.         new num;
  129.         for(new i = 0; i < sizeof(gPop); i++)
  130.         {
  131.             if(num != 0) return 0;
  132.             if(strcmp(musicid, gPopNames[i], true) == 0)
  133.             {
  134.                 num++;
  135.                 PlayAudioStreamForPlayer(playerid, gPop[i], 0, 0, 0, 0, 0);
  136.                 new Music[56];
  137.                 format(Music, 256, "Você está ouvindo: {FF0000}%s", gPopNames[i]);
  138.                 SendClientMessage(playerid, -1, Music);
  139.                 SendClientMessage(playerid, -1, "Talvez a música possa demorar a começar. Isto vai depender da sua Internet [...]");
  140.                 SendClientMessage(playerid, -1, "[...] E da disponibilidade do Servidor onde elas esão hospedadas/são convertidas.");
  141.             }
  142.         }
  143.     }
  144.     return 1;
  145. }
  146.  
  147. stock RandomMusic(playerid, Duration, Float:X, Float:Y, Float:Z, Float:Distance, bool:UsePos)
  148. {
  149.     new gRand = random(sizeof(gPop));
  150.     if(UsePos == true)
  151.     {
  152.             PlayAudioStreamForPlayer(playerid, gPop[gRand], X, Y, Z, Distance, true);
  153.     }
  154.     else
  155.     {
  156.         PlayAudioStreamForPlayer(playerid, gPop[gRand], 0, 0, 0, 0, 0);
  157.     }
  158.     if(Duration > 0)
  159.     {
  160.         Duration *= 1000;
  161.         SetTimerEx("StopMusic", Duration, false, "i", playerid);
  162.     }
  163.     new Music[56];
  164.     format(Music, 256, "Você está ouvindo: {FF0000}%s", gPopNames[gRand]);
  165.     SendClientMessage(playerid, -1, Music);
  166.     SendClientMessage(playerid, -1, "Talvez a música possa demorar a começar. Isto vai depender da sua Internet [...]");
  167.     SendClientMessage(playerid, -1, "[...] E da disponibilidade do Servidor onde elas esão hospedadas/são convertidas.");
  168.     return 1;
  169. }
  170.  
  171. stock ContinuousMusicForPlayer(playerid)
  172. {
  173.     new gRand = random(sizeof(gPop));
  174.     PlayAudioStreamForPlayer(playerid, gPop[gRand], 0, 0, 0, 0, 0);
  175.     TimerContinuous[playerid] = SetTimerEx("StartAnother", 1000 * gPopDuration[gRand], false, "i", playerid);
  176.     //
  177.     new Music[56];
  178.     format(Music, 256, "Você está ouvindo: {FF0000}%s", gPopNames[gRand]);
  179.     SendClientMessage(playerid, -1, Music);
  180.     SendClientMessage(playerid, -1, "Talvez a música possa demorar a começar. Isto vai depender da sua Internet [...]");
  181.     SendClientMessage(playerid, -1, "[...] E da disponibilidade do Servidor onde elas esão hospedadas/são convertidas.");
  182.     return 1;
  183. }
  184.  
  185. stock StopContinuousMusicForPlayer(playerid)
  186. {
  187.     if(TimerContinuous[playerid] == 0) return 0;
  188.     SetTimerEx("StopMusic", 500, false, "i", playerid);
  189.     return 1;
  190. }
Advertisement
Add Comment
Please, Sign In to add comment