Sounds not playing, but debugs works and sounds downloading so problem with emitsound. And there is no error logs.
Can someone look at this sourcecode and say what is wrong ?
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <clientprefs>
#include <mapchooser_extended>
char cStartSound[135], cEndSound[135];
bool bIsClientDisabledSounds[MAXPLAYERS + 1] = {false, ... };
Handle hCookie;
public void OnPluginStart() {
hCookie = RegClientCookie("votesounds", "Vote Sounds", CookieAccess_Public);
RegConsoleCmd("sm_sounds", Sounds);
}
public void OnMapStart() {
char path[PLATFORM_MAX_PATH], buffer[135];
BuildPath(Path_SM, path, sizeof(path), "configs/votesounds/sounds.ini");
KeyValues kv = CreateKeyValues("sounds");
kv.ImportFromFile(path);
kv.Rewind();
if(kv.JumpToKey("startsound", false)) {
kv.GetString("sound", buffer, 135);
Format(cStartSound, 135, buffer);
Format(buffer, 135, "sound/%s", cStartSound);
AddFileToDownloadsTable(buffer);
PrecacheSound(buffer);
}
if(kv.JumpToKey("endsound", false)) {
kv.GetString("sound", buffer, 135);
Format(cEndSound, 135, buffer);
Format(buffer, 135, "sound/%s", cEndSound);
AddFileToDownloadsTable(buffer);
PrecacheSound(buffer);
}
}
public void OnClientCookiesCached(int client) {
static char cValue[2];
GetClientCookie(client, hCookie, cValue, sizeof(cValue));
bIsClientDisabledSounds[client] = view_as<bool>(StringToInt(cValue));
}
public Action Sounds(int client, int args) {
if(IsClientInGame(client)) {
if (bIsClientDisabledSounds[client]) bIsClientDisabledSounds[client] = false;
else if (!bIsClientDisabledSounds[client]) bIsClientDisabledSounds[client] = true;
PrintToChat(client, "Sounds are %s", bIsClientDisabledSounds[client] ? "disabled" : "enabled");
static char cValue[2];
IntToString(bIsClientDisabledSounds[client], cValue, sizeof(cValue));
SetClientCookie(client, hCookie, cValue);
}
return Plugin_Handled;
}
public OnMapVoteStarted() {
EmitSounds(cStartSound);
// DEBUG PrintToChatAll("soundstart");
}
public OnMapVoteEnd(const char[] map) {
EmitSounds(cEndSound);
// DEBUG PrintToChatAll("soundend");
}
void EmitSounds(const char[] cSound) {
for(int i = 1; i < MaxClients; i++) {
if(IsClientInGame(i) && !IsFakeClient(i)) {
if(!bIsClientDisabledSounds[i]) {
EmitSoundToClient(i, cSound);
}
}
}
}