|
@@ -12,7 +12,7 @@
|
|
#pragma newdecls required
|
|
#pragma newdecls required
|
|
#include <round_end_music>
|
|
#include <round_end_music>
|
|
|
|
|
|
-#define PLUGIN_VERSION "0.2.0"
|
|
+#define PLUGIN_VERSION "0.3.0"
|
|
public Plugin myinfo = {
|
|
public Plugin myinfo = {
|
|
name = "[CSRD] Round End Music",
|
|
name = "[CSRD] Round End Music",
|
|
author = "nosoop",
|
|
author = "nosoop",
|
|
@@ -28,6 +28,8 @@ ConVar g_ConVarMaxActiveSongs, g_ConVarEnabled;
|
|
|
|
|
|
Handle g_RequestSongForward;
|
|
Handle g_RequestSongForward;
|
|
|
|
|
|
|
|
+Handle g_OnREMPlayedForward, g_OnREMPostPlayedForward;
|
|
|
|
+
|
|
int g_nMaxActiveSongs = 5;
|
|
int g_nMaxActiveSongs = 5;
|
|
bool g_bRoundEndMusicActive;
|
|
bool g_bRoundEndMusicActive;
|
|
|
|
|
|
@@ -38,6 +40,10 @@ public void OnPluginStart() {
|
|
|
|
|
|
g_RequestSongForward = CreateForward(ET_Ignore);
|
|
g_RequestSongForward = CreateForward(ET_Ignore);
|
|
|
|
|
|
|
|
+ g_OnREMPlayedForward = CreateGlobalForward("OnRoundEndMusicWillPlay", ET_Event, Param_Cell);
|
|
|
|
+ g_OnREMPostPlayedForward = CreateGlobalForward("OnRoundEndMusicPlayed", ET_Ignore,
|
|
|
|
+ Param_Cell);
|
|
|
|
+
|
|
HookEvent("teamplay_round_win", OnRoundEnd, EventHookMode_PostNoCopy);
|
|
HookEvent("teamplay_round_win", OnRoundEnd, EventHookMode_PostNoCopy);
|
|
|
|
|
|
RegAdminCmd("sm_playsong", AdminCmd_PlaySong, ADMFLAG_ROOT);
|
|
RegAdminCmd("sm_playsong", AdminCmd_PlaySong, ADMFLAG_ROOT);
|
|
@@ -209,26 +215,44 @@ void PlayRoundEndMusic() {
|
|
}
|
|
}
|
|
|
|
|
|
void EmitRoundEndMusic(MusicEntry song) {
|
|
void EmitRoundEndMusic(MusicEntry song) {
|
|
- char filePath[PLATFORM_MAX_PATH];
|
|
+ Action result = FireOnRoundEndMusicPlayedEvent(song);
|
|
- song.GetFilePath(filePath, sizeof(filePath));
|
|
|
|
-
|
|
|
|
- PrintToServer("mock play song %s", filePath);
|
|
|
|
- EmitSoundToAll(filePath);
|
|
|
|
|
|
|
|
- // TODO create new forward OnRoundEndMusicPlayed(MusicEntry song) ?
|
|
+ if (result == Plugin_Continue) {
|
|
- // - Plugin_Continue uses default handling
|
|
+ char filePath[PLATFORM_MAX_PATH];
|
|
- // - Plugin_Handled does not
|
|
+ song.GetFilePath(filePath, sizeof(filePath));
|
|
- // - Plugin_Stop doesn't either, but the implication is that the entire endround is canceled
|
|
+
|
|
- // (i.e., it shouldn't move it to the played list)
|
|
+ PrintToServer("mock play song %s", filePath);
|
|
|
|
+ EmitSoundToAll(filePath);
|
|
|
|
+ }
|
|
|
|
|
|
- if (g_PlayedSongs.FindValue(song) == -1) {
|
|
+ if (result != Plugin_Stop) {
|
|
- g_PlayedSongs.Push(song);
|
|
+ if (g_PlayedSongs.FindValue(song) == -1) {
|
|
|
|
+ g_PlayedSongs.Push(song);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ g_ActiveSongs.Erase(0);
|
|
|
|
+
|
|
|
|
+ FireOnREMPlayedPostEvent(song);
|
|
}
|
|
}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+Action FireOnRoundEndMusicPlayedEvent(MusicEntry song) {
|
|
|
|
+ Action result;
|
|
|
|
+ Call_StartForward(g_OnREMPlayedForward);
|
|
|
|
+ Call_PushCell(song);
|
|
|
|
+ Call_Finish(result);
|
|
|
|
|
|
- g_ActiveSongs.Erase(0);
|
|
+ return result;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void FireOnREMPlayedPostEvent(MusicEntry song) {
|
|
|
|
+ Call_StartForward(g_OnREMPostPlayedForward);
|
|
|
|
+ Call_PushCell(song);
|
|
|
|
+ Call_Finish();
|
|
}
|
|
}
|
|
|
|
|
|
public void OnRoundEnd(Event event, const char[] name, bool dontBroadcast) {
|
|
public void OnRoundEnd(Event event, const char[] name, bool dontBroadcast) {
|
|
|
|
+ // TODO timer
|
|
PlayRoundEndMusic();
|
|
PlayRoundEndMusic();
|
|
}
|
|
}
|
|
|
|
|