round_end_music_sample_provider.sp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.1"
  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. };
  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 could not be queued.", SONGS[i][2]);
  31. }
  32. delete entry;
  33. }
  34. PrintToServer("[rem-sample] %d songs requested", REM_GetActiveSongCount());
  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. public void OnRoundEndMusicPlayed(MusicEntry song) {
  44. char title[64], source[64];
  45. song.GetTitle(title, sizeof(title));
  46. song.GetSource(source, sizeof(source));
  47. PrintToChatAll("You're now listening to: %s from %s!", title, source);
  48. }
  49. void OnRoundEndMusicAvailable() {
  50. REM_RegisterSource(HardcodedArrayMusicSource);
  51. }
  52. public void OnAllPluginsLoaded() {
  53. if (LibraryExists("round-end-music")) {
  54. OnRoundEndMusicAvailable();
  55. }
  56. }
  57. public void OnLibraryAdded(const char[] name) {
  58. if (StrEqual(name, "round-end-music")) {
  59. OnRoundEndMusicAvailable();
  60. }
  61. }