round_end_music_sample_provider.sp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.0.1"
  11. public Plugin myinfo = {
  12. name = "Round End Music: Sample Source",
  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. };
  26. public void HardcodedArrayMusicSource() {
  27. for (int i = 0; i < sizeof(SONGS); i++) {
  28. MusicEntry entry = GenerateSong(SONGS[i][0], SONGS[i][1], SONGS[i][2]);
  29. if (!REM_AddSong(entry)) {
  30. PrintToServer("[rem-sample] Song %s is already queued.", SONGS[i][2]);
  31. }
  32. delete entry;
  33. }
  34. PrintToServer("Songs requested");
  35. }
  36. MusicEntry GenerateSong(const char[] title, const char[] source, const char[] filePath) {
  37. MusicEntry song = new MusicEntry();
  38. song.SetTitle(title);
  39. song.SetSource(source);
  40. song.SetFilePath(filePath);
  41. return song;
  42. }
  43. void OnRoundEndMusicAvailable() {
  44. REM_RegisterSource(HardcodedArrayMusicSource);
  45. }
  46. public void OnAllPluginsLoaded() {
  47. if (LibraryExists("round-end-music")) {
  48. OnRoundEndMusicAvailable();
  49. }
  50. }
  51. public void OnLibraryAdded(const char[] name) {
  52. if (StrEqual(name, "round-end-music")) {
  53. OnRoundEndMusicAvailable();
  54. }
  55. }