round_end_music_sample_provider.sp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Round End Music: Sample Sources
  3. *
  4. * An example plugin showing how to add songs to the Round End Music playlist.
  5. */
  6. #pragma semicolon 1
  7. #include <sourcemod>
  8. #pragma newdecls required
  9. #include <round_end_music>
  10. #define PLUGIN_VERSION "0.1.2"
  11. public Plugin myinfo = {
  12. name = "Round End Music: Sample Source and Handler",
  13. author = "nosoop",
  14. description = "Loads hard-coded music entries. Mostly for testing.",
  15. version = PLUGIN_VERSION,
  16. url = "https://pika.nom-nom-nom.us/"
  17. }
  18. char SONGS[][][] = {
  19. { "You're at the Party", "Lemon Demon", "nomnomnomsongs/pikapoo/attheparty.mp3" },
  20. { "Come on Down", "The Price is Right", "nomnomnomsongs/tpir.mp3" },
  21. { "1812 Overture", "Tchaikovsky", "nomnomnomsongs/1812.mp3" },
  22. { "Back to the Future", "The Outatime Orchestra", "nomnomnomsongs/bttf.mp3" },
  23. { "Blinded by Light", "Final Fantasy 13", "nomnomnomsongs/blindedbylight.mp3" },
  24. { "Yatta!", "Green Leaves", "nomnomnomsongs/yatta.mp3" },
  25. { "Hydroponics Lab", "Escape From Puppy Death Factory", "nomnomnomsongs/pikapoo/puppydeathfactory.mp3" },
  26. { "Theme", "Jackie Chan Adventures", "nomnomnomsongs/jchana.mp3" },
  27. { "Throwback Galaxy", "Super Mario Galaxy 2", "nomnomnomsongs/throwback.mp3" },
  28. };
  29. public void HardcodedArrayMusicSource() {
  30. for (int i = 0; i < sizeof(SONGS); i++) {
  31. MusicEntry entry = GenerateSong(SONGS[i][0], SONGS[i][1], SONGS[i][2]);
  32. if (!REM_AddSong(entry)) {
  33. PrintToServer("[rem-sample] Song %s could not be queued.", SONGS[i][2]);
  34. }
  35. delete entry;
  36. }
  37. PrintToServer("[rem-sample] %d songs requested", REM_GetActiveSongCount());
  38. }
  39. MusicEntry GenerateSong(const char[] title, const char[] source, const char[] filePath) {
  40. MusicEntry song = new MusicEntry();
  41. song.SetTitle(title);
  42. song.SetSource(source);
  43. song.SetFilePath(filePath);
  44. return song;
  45. }
  46. public void OnRoundEndMusicPlayed(MusicEntry song) {
  47. char title[64], source[64];
  48. song.GetTitle(title, sizeof(title));
  49. song.GetSource(source, sizeof(source));
  50. PrintToChatAll("You're now listening to: %s from %s!", title, source);
  51. }
  52. void OnRoundEndMusicAvailable() {
  53. REM_RegisterSource(HardcodedArrayMusicSource);
  54. }
  55. public void OnAllPluginsLoaded() {
  56. if (LibraryExists("round-end-music")) {
  57. OnRoundEndMusicAvailable();
  58. }
  59. }
  60. public void OnLibraryAdded(const char[] name) {
  61. if (StrEqual(name, "round-end-music")) {
  62. OnRoundEndMusicAvailable();
  63. }
  64. }