View Single Post
Author Message
farawayf
Senior Member
Join Date: Jan 2019
Old 12-14-2019 , 10:56   [CS:S] Problems with EmitSound
Reply With Quote #1

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_SMpathsizeof(path), "configs/votesounds/sounds.ini");
    
    
KeyValues kv CreateKeyValues("sounds");
    
kv.ImportFromFile(path);

    
kv.Rewind();
    if(
kv.JumpToKey("startsound"false)) {
        
kv.GetString("sound"buffer135);
        
Format(cStartSound135buffer);
        
Format(buffer135"sound/%s"cStartSound);
        
AddFileToDownloadsTable(buffer);
        
PrecacheSound(buffer);
    }
    if(
kv.JumpToKey("endsound"false)) {
        
kv.GetString("sound"buffer135);
        
Format(cEndSound135buffer);
        
Format(buffer135"sound/%s"cEndSound);
        
AddFileToDownloadsTable(buffer);
        
PrecacheSound(buffer);
    }
}

public 
void OnClientCookiesCached(int client) {
    static 
char cValue[2];
    
GetClientCookie(clienthCookiecValuesizeof(cValue));
    
bIsClientDisabledSounds[client] = view_as<bool>(StringToInt(cValue));
}

public 
Action Sounds(int clientint 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], cValuesizeof(cValue));
        
SetClientCookie(clienthCookiecValue);
    }
    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 1MaxClientsi++) {
        if(
IsClientInGame(i) && !IsFakeClient(i)) {
            if(!
bIsClientDisabledSounds[i]) {
                
EmitSoundToClient(icSound);
            }
        }
    }


Last edited by farawayf; 12-14-2019 at 16:39.
farawayf is offline