Hi,
I feel dumb asking this but I did search and try everything I saw first. Couldn't get it working.
What I'm trying to do is simple, play a custom sound to all players.
Basically I check if it is the first death and if it is, restart the game and play the sound also after teams are swapped.
PHP Code:
.
.
.
public OnPluginStart()
{
sm_DMHTSwap_version = CreateConVar("sm_DMHTSwap_version", "1.0.5", "DM Half Time Swap Version.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
HookEvent("player_death", event_player_death);
PrecacheSound("sinsic/getready.mp3", true);
}
public OnConfigsExecuted()
{
AddFileToDownloadsTable("sound/sinsic/getready.mp3");
}
public Action:event_player_death(Handle:event, const String:name[], bool:dontBroadcast)
{
if (g_bFirstDeath)
{
ServerCommand("sm plugins reload sm_spawning");
ServerCommand("mp_restartgame 1");
g_bFirstDeath = false;
EmitSoundToAll("sinsic/getready.mp3");
.
.
.
It downloads the sound to the client side but still prints to console "Failed to load sound "sinsic\getready.mp3", file probably missing from disk/repository" when it should play.
File locations:
Server Side
cstrike/sound/sinsic/getready.mp3
Fast DL
steam/sound/sinsic/getready.mp3.bz2
And when client connects, file is downloaded to
cstrike\download\sound\sinsic\getready.mp3
I also tried
adding the sound at server side to cstrike/custom/my_custom_staff/sound/sinsic/getready.mp3
PreCaching at OnConfigsExecuted()
using wav instead of mp3
If you need the full plugin here it is:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <sdktools_sound>
new Handle:sm_DMHTSwap_version;
new bool:g_bSwapped;
new bool:g_bFirstDeath;
public Plugin:myinfo =
{
name = "DM Half Time Swap",
author = "Sinsic",
description = "Half time team swap for DM Maps",
version = "1.0.5",
url = ""
};
public OnMapStart(){
g_bSwapped = false;
g_bFirstDeath = true;
}
public OnPluginStart()
{
sm_DMHTSwap_version = CreateConVar("sm_DMHTSwap_version", "1.0.5", "DM Half Time Swap Version.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
HookEvent("player_death", event_player_death);
PrecacheSound("sinsic/getready.mp3", true);
}
public OnConfigsExecuted()
{
AddFileToDownloadsTable("sound/sinsic/getready.mp3");
}
public Action:event_player_death(Handle:event, const String:name[], bool:dontBroadcast)
{
if (g_bFirstDeath)
{
ServerCommand("sm plugins reload sm_spawning");
ServerCommand("mp_restartgame 1");
g_bFirstDeath = false;
EmitSoundToAll("sinsic/getready.mp3");
}
new timeleft;
GetMapTimeLeft(timeleft);
new timelimit=GetConVarInt(FindConVar("mp_timelimit"));
if (!g_bSwapped)
{
new frag = GetClientFrags(GetClientOfUserId(GetEventInt(event, "attacker")));
frag = (frag + 1) * 2;
new fraglimit=GetConVarInt(FindConVar("mp_fraglimit"));
if ( ((frag >= fraglimit) && (fraglimit != 0)) || (((timeleft*2) < (timelimit*60)) && (timeleft > 0)) )
{
g_bSwapped = true;
for(new i = 1; i <= MaxClients; ++i)
{
if(IsClientInGame(i) && (!IsFakeClient(i)))
{
if (GetClientTeam(i) == 2)
{
CS_SwitchTeam(i, 3);
} else if (GetClientTeam(i) == 3){
CS_SwitchTeam(i, 2);
}
}
}
ServerCommand("mp_restartgame 1");
EmitSoundToAll("sinsic/getready.mp3");
new limitervalue;
limitervalue = RoundToNearest(fraglimit / 2.0);
CreateTimer(10.0, fraglimiterdelay, limitervalue);
limitervalue = RoundToNearest(timelimit / 2.0);
CreateTimer(10.0, timelimiterdelay, limitervalue);
}
} else if((timeleft < 1) && (timelimit > 0)){
ServerCommand("mp_fraglimit 1");
}
}
public Action:fraglimiterdelay(Handle:timer, any:limitervalue){
new String:limiter[64];
Format(limiter, sizeof(limiter), "mp_fraglimit %d", limitervalue);
ServerCommand(limiter);
}
public Action:timelimiterdelay(Handle:timer, any:limitervalue){
new String:limiter[64];
Format(limiter, sizeof(limiter), "mp_timelimit %d", limitervalue);
ServerCommand(limiter);
}
__________________