This snippet is mainly for sound files and playing them, but can be applied in theory to other files and actions.
Code:
#include <sourcemod>
#include <sdktools>
#include <sdktools_sound>
#define MAX_FILE_LEN 80
new Handle:g_CvarSoundName9 = INVALID_HANDLE;
new String:g_soundName9[MAX_FILE_LEN];
public OnPluginStart()
{
g_CvarSoundName9 = CreateConVar("sm_join_sound9", "t3clan_custom/end1.mp3", "");
HookEvent("round_end", RoundEndEvent);
}
public OnMapStart()
{
GetConVarString(g_CvarSoundName9, g_soundName9, MAX_FILE_LEN);
decl String:buffer9[MAX_FILE_LEN];
PrecacheSound(g_soundName9, true);
Format(buffer9, sizeof(buffer9), "sound/%s", g_soundName9);
AddFileToDownloadsTable(buffer9);
//OR if precaching an existing sound that's not needing to be downloaded:
PrecacheSound("player/crit_hit4.wav");
}
public Action:RoundEndEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
for(new i = 1; i <= GetMaxClients(); i++)
if(IsClientInGame(i) && !IsFakeClient(i))
{
EmitSoundToClient(i,g_soundName9, SOUND_FROM_PLAYER, SNDCHAN_AUTO, SNDLEVEL_NORMAL);
}
}
public OnEventShutdown()
{
UnhookEvent("round_end", RoundEndEvent);
}
Oh, and I was wondering, does anyone know how to check for when a bot disconnects? Or rather, that the client that left the game is not a bot?
Also, it seems that if you precache the sound, it doesn't matter what kbps is has, channel, etc, It will play it (that I know of so far) if it's either .wav or .mp3, haven't tried any other type.
This code could also be useful if you wanna force the download and precache of a certain sound file, then have modified sound_weapon etc file to change the sound on a specific weapon action.
__________________