round_end_music_sample_provider.sp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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.4"
  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://git.csrd.science/"
  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 OnRoundEndSongsRequested() {
  30. // Load song data from array
  31. for (int i = 0; i < sizeof(SONGS); i++) {
  32. MusicEntry entry = GenerateSong(SONGS[i][0], SONGS[i][1], SONGS[i][2]);
  33. if (!REM_AddSong(entry)) {
  34. PrintToServer("[rem-sample] Song %s could not be queued.", SONGS[i][2]);
  35. }
  36. delete entry;
  37. }
  38. PrintToServer("[rem-sample] %d songs requested", REM_GetActiveSongCount());
  39. }
  40. MusicEntry GenerateSong(const char[] title, const char[] source, const char[] filePath) {
  41. MusicEntry song = new MusicEntry();
  42. song.SetTitle(title);
  43. song.SetSource(source);
  44. song.SetFilePath(filePath);
  45. return song;
  46. }
  47. public void OnRoundEndMusicPlayed(MusicEntry song) {
  48. char title[64], source[64], filePath[PLATFORM_MAX_PATH];
  49. song.GetTitle(title, sizeof(title));
  50. song.GetSource(source, sizeof(source));
  51. PrintToChatAll("You're now listening to: %s from %s!", title, source);
  52. song.GetFilePath(filePath, sizeof(filePath));
  53. PrintToServer("[rem-sample] Played %s (replay? %b)", filePath,
  54. REM_SongWasRecentlyPlayed(song));
  55. }