I misunderstood what you were asking for, but I'm writing something up for you that should do what you want.
[edit]
This should do what you want:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
// Global Definitions
#define PLUGIN_VERSION "1.0.0"
new bool:isHooked = false;
new bool:playSound = false;
new Handle:cvarEnable;
new Handle:cvarSound;
new Handle:soundTimer = INVALID_HANDLE;
// Functions
public Plugin:myinfo =
{
name = "Champs +90 min win",
author = "IDK",
description = "Plays a song if the round last longer then 90 mins and is then won",
version = PLUGIN_VERSION,
url = "lol no"
};
public OnPluginStart()
{
cvarEnable = CreateConVar("sm_champs", "1", "Enables cmaps Finish", FCVAR_PLUGIN, true, 0.0, true, 1.0);
cvarSound = CreateConVar("sm_shampsfile", "champs.mp3", "File to play upon a camps Finish", FCVAR_PLUGIN);
CreateTimer(3.0, OnPluginStart_Delayed);
}
public Action:OnPluginStart_Delayed(Handle:timer)
{
if (GetConVarInt(cvarEnable))
{
isHooked = true;
HookEvent("teamplay_round_start", event_RoundStart);
HookEvent("teamplay_round_end", event_RoundEnd);
}
PrecacheChamps();
HookConVarChange(cvarEnable, CvarChange);
}
public CvarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
if (!GetConVarInt(cvarEnable))
{
if (isHooked)
{
isHooked = false;
UnhookEvent("teamplay_round_start", event_RoundStart);
UnhookEvent("teamplay_round_end", event_RoundEnd);
}
}
else if (!isHooked)
{
isHooked = true;
HookEvent("teamplay_round_start", event_RoundStart);
HookEvent("teamplay_round_end", event_RoundEnd);
}
}
public event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
playSound = false;
soundTimer = CreateTimer(5400.0, timer_Sound, _, TIMER_FLAG_NO_MAPCHANGE);
}
public Action:timer_Sound(Handle:timer)
playSound = true;
public event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
KillSoundTimer();
if (playSound)
{
decl String:soundFile[32];
GetConVarString(cvarSound, soundFile, sizeof(soundFile));
EmitSoundToAll(soundFile, _, _, SNDLEVEL_MINIBIKE);
PrintToChatAll("We are the Champions!");
}
}
stock PrecacheChamps()
{
decl String:soundFile[32], String:path[PLATFORM_MAX_PATH];
GetConVarString(cvarSound, soundFile, sizeof(soundFile));
Format(path, sizeof(path), "sound/%s", soundFile);
if (!PrecacheSound(soundFile))
SetFailState("Failed to precache sound file: %s", soundFile);
AddFileToDownloadsTable(path);
}
stock KillSoundTimer()
{
if (soundTimer != INVALID_HANDLE)
KillTimer(soundTimer);
}