Raised This Month: $32 Target: $400
 8% 

Custom Sounds are Not PreCached properly for Clients?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gotank65
Junior Member
Join Date: Jun 2006
Location: Bucks
Old 08-10-2016 , 04:34   Custom Sounds are Not PreCached properly for Clients?
Reply With Quote #1

EDIT: This has been Partially Solved, https://wiki.alliedmods.net/Csgo_qui..._Custom_Sounds
CS:GO has issues preaching custom sounds, requires a workaround on the page above

NEW ISSUE: How can I safely Re-fakeCache the sound (that has already been "fake" precached) for each client that joins the server AFTER the initial precache?

The listed workaround works, unless the client joins AFTER the precache...
_____________________________________________ _____________________
I have had this issue with a few different Plugins that I run on my server.
edit: for CS:GO

the SoccerJam Plugin works perfectly with ANY sound that is in the game by default, however, using the CFG intended for setting up custom sounds doesn't seem to work correctly

PHP Code:
"sounds"
{
    
"ball_explosion"        
    
{
        
"weapons/c4/c4_explode1.wav" ""
    
}
    
"goal_siren"    
    
{
        
"ambient/atmosphere/cs_metalscrapeverb10.wav" ""
    
}
    
"goal"    
    
{
        
"player/vo/phoenix/niceshot04.wav" ""
    
}
    
"ball_pickup"    
    
{
        
"weapons/sensorgrenade/sensor_equip.wav" ""
    

    
"kick_charge"    
    
{
        
"ui/item_showcase_sticker_01.wav" ""
    
}
    
"ball_kick"        
    
{
        
"weapons/sensorgrenade/sensor_detect.wav" ""
    
}
    
"fastball_pickup"    
    
{
        
"ambient/energy/spark6.wav" ""
    
}
    
"ball_respawned"    
    
{
        
"buttons/button11.wav" ""
    
}
    
"upgrade_maxlevel"        
    
{
        
"ambient/misc/brass_bell_e.wav" ""
    
}
    
"ball_kill"        
    
{
        
"player/pl_fallpain1.wav" ""
    
}
    
"death_zone_kill"    
    
{
        
"ambient/energy/weld1.wav" ""
    
}
    
"ball_steal"    
    
{
        
"player/vo/fbihrt/radiobotniceshot02.wav" ""
    
}
    
"match_timeisup"    
    
{
        
"training/score100.wav" ""
    
}
    
"timer_tick"    
    
{
        
"weapons/flashbang/grenade_hit1.wav" ""
    
}
    
"ball_bounce"    
    
{
        
"physics/rubber/rubber_tire_impact_soft1.wav" ""
    
}
    
"level_up"    
    
{
        
"kickball/levelup.wav" ""
    
}
    
"turbo_ready"    
    
{
        
"items/nvg_on.wav" ""
    
}
    
"long_jump_ready"    
    
{
        
"weapons/revolver/revolver_draw.wav" ""
    
}

Any DEFAULT sounds work no problem, but if the sound is a custom sound, it does not work correctly for clients in the server.

To fix the sound issue, a client must run this command:


"snd_updateaudiocache"

I have the same issue with other plugins that use Custom sounds by Default.


Clients will not hear the custom sounds unless they run

"snd_updateaudiocache"

Is this a plugin issue, or is this a server issue?

How can I adjust the plugins to update the clients audio cache properly to play custom sounds on the server.

Here is some of the code for Audio Caching in the plugins:

Soccerjam
PHP Code:
public SM_OnSjConfigLoaded()
{
    new 
soundId
    
for (new soundGroupId 0soundGroupId SoundGroupsCountsoundGroupId++)
    {
        for (
soundId 0soundId SoundCount[soundGroupId]; soundId++)
        {
            
PrecacheSound(SoundPaths[soundGroupId][soundId])

            
decl String:fullSoundPath[PLATFORM_MAX_PATH]
            
Format(fullSoundPathsizeof(fullSoundPath), "sound/%s"SoundPaths[soundGroupId][soundId])
            
AddFileToDownloadsTable(fullSoundPath)
        }
    }

Entire Soccer Sound File
PHP Code:
const MAX_SOUNDS 128
const MAX_SOUND_GROUPS 128
const MAX_SOUNDS_IN_GROUPS 32

static SoundGroupsCount
static SoundCount[MAX_SOUND_GROUPS]
static 
String:SoundGroupNames[MAX_SOUNDS][MAX_NAME_LENGTH]
static 
String:SoundPaths[MAX_SOUND_GROUPS][MAX_SOUNDS][PLATFORM_MAX_PATH]


public 
SM_Init()
{
    
CreateConfig("sounds.cfg""sounds"SM_ReadConfig)
}

CreateSound(const String:soundGrouopName[])
{
    
strcopy(SoundGroupNames[SoundGroupsCount], MAX_NAME_LENGTHsoundGrouopName)
    
SoundGroupsCount++
    return 
SoundGroupsCount 1
}

public 
SM_ReadConfig(Handle:kv)
{
    for (new 
soundGroupId 0soundGroupId SoundGroupsCountsoundGroupId++)
    {
        
SoundCount[soundGroupId] = 0
        
if (KvJumpToKey(kvSoundGroupNames[soundGroupId]))
        {
            if (
KvGotoFirstSubKey(kvfalse))
            {
                do
                {
                    new 
soundCountInThisGroup SoundCount[soundGroupId]
                    
KvGetSectionName(kvSoundPaths[soundGroupId][soundCountInThisGroup], PLATFORM_MAX_PATH)
                    
SoundCount[soundGroupId]++
                }
                while (
KvGotoNextKey(kvfalse))
                
KvGoBack(kv)
            }
            
KvGoBack(kv)
        }
    }
}

public 
SM_OnSjConfigLoaded()
{
    new 
soundId
    
for (new soundGroupId 0soundGroupId SoundGroupsCountsoundGroupId++)
    {
        for (
soundId 0soundId SoundCount[soundGroupId]; soundId++)
        {
            
PrecacheSound(SoundPaths[soundGroupId][soundId])

            
decl String:fullSoundPath[PLATFORM_MAX_PATH]
            
Format(fullSoundPathsizeof(fullSoundPath), "sound/%s"SoundPaths[soundGroupId][soundId])
            
AddFileToDownloadsTable(fullSoundPath)
        }
    }
}

stock String:GetSoundPathById(soundGroupIdString:dest[PLATFORM_MAX_PATH])
{
    if (
SoundCount[soundGroupId] == 0)
    {
        return
    }
    new 
randomSoundId GetRandomInt(0SoundCount[soundGroupId] - 1)
    
strcopy(destPLATFORM_MAX_PATHSoundPaths[soundGroupId][randomSoundId])
}

stock PlaySoundByIdToAll(soundGroupId)
{
    if (
SoundCount[soundGroupId] == 0)
    {
        return
    }
    new 
randomSoundId GetRandomInt(0SoundCount[soundGroupId] - 1)
    if (!
StrEqual(SoundPaths[soundGroupId][randomSoundId], ""false))
    {
        for (new 
1<= MaxClientsi++)
        {
            if (
IsClientInGame(i))
            {
                
EmitSoundToClient(iSoundPaths[soundGroupId][randomSoundId]);
            }
        }
    }
}

stock PlaySoundByIdToClient(clientsoundGroupId)
{
    if (
SoundCount[soundGroupId] == 0)
    {
        return
    }
    new 
randomSoundId GetRandomInt(0SoundCount[soundGroupId] - 1)
    if (!
StrEqual(SoundPaths[soundGroupId][randomSoundId], ""false))
    {
        
EmitSoundToClient(clientSoundPaths[soundGroupId][randomSoundId]);
    }
}

stock PlaySoundByIdFromEntity(soundGroupIdentity)
{
    if (
SoundCount[soundGroupId] == 0)
    {
        return
    }
    new 
randomSoundId GetRandomInt(0SoundCount[soundGroupId] - 1)
    if (!
StrEqual(SoundPaths[soundGroupId][randomSoundId], ""false))
    {
        
EmitSoundToAll(SoundPaths[soundGroupId][randomSoundId], entity);
    }

Goomba Stomp Plugin
PHP Code:
#define STOMP_SOUND "goomba/stomp.wav"
#define REBOUND_SOUND "goomba/rebound.wav"


public OnMapStart()
{
    
PrecacheSound(STOMP_SOUNDtrue);
    
PrecacheSound(REBOUND_SOUNDtrue);

    
decl String:stompSoundServerPath[128];
    
decl String:reboundSoundServerPath[128];
    
Format(stompSoundServerPathsizeof(stompSoundServerPath), "sound/%s"STOMP_SOUND);
    
Format(reboundSoundServerPathsizeof(reboundSoundServerPath), "sound/%s"REBOUND_SOUND);

    
AddFileToDownloadsTable(stompSoundServerPath);
    
AddFileToDownloadsTable(reboundSoundServerPath);

Note:
All the files are downloaded to the clients Correctly, the only issue is that they can't hear the sounds unless they update their audio cache...

TL;DR
How can I make it so that clients hear the custom sounds used by the plugins on my server, without "manually" asking them to update their audio cache. edit: Game is CS:GO

Thank you!


Last edited by Gotank65; 08-11-2016 at 18:01.
Gotank65 is offline
Naydef
Senior Member
Join Date: Dec 2015
Location: Doom Town, Nevada
Old 08-10-2016 , 04:52   Re: Custom Sounds are Not PreCached properly for Clients?
Reply With Quote #2

Game?
__________________
My plugins:
*None for now*


Steam:
naydef
Naydef is offline
Gotank65
Junior Member
Join Date: Jun 2006
Location: Bucks
Old 08-10-2016 , 05:36   Re: Custom Sounds are Not PreCached properly for Clients?
Reply With Quote #3

Quote:
Originally Posted by Naydef View Post
Game?
CS:GO
Gotank65 is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 08-10-2016 , 06:37   Re: Custom Sounds are Not PreCached properly for Clients?
Reply With Quote #4

its 99.9% human error.
I've had shit happening with sounds aswel, check if your stringtables are not full.
Make the script output something after precaching, this way you know it reached that code.
__________________
ImACow is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 08-10-2016 , 07:47   Re: Custom Sounds are Not PreCached properly for Clients?
Reply With Quote #5

Have you tried?
https://forums.alliedmods.net/showthread.php?t=237045
Michael Shoe Maker is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 08-10-2016 , 08:45   Re: Custom Sounds are Not PreCached properly for Clients?
Reply With Quote #6

https://wiki.alliedmods.net/Csgo_qui..._Custom_Sounds
__________________
WildCard65 is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 08-10-2016 , 13:28   Re: Custom Sounds are Not PreCached properly for Clients?
Reply With Quote #7

Have you tried not to change font size?
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.

Last edited by KissLick; 08-10-2016 at 13:28.
KissLick is offline
Gotank65
Junior Member
Join Date: Jun 2006
Location: Bucks
Old 08-11-2016 , 17:38   Re: Custom Sounds are Not PreCached properly for Clients?
Reply With Quote #8

Quote:
Originally Posted by Michael Shoe Maker View Post
I see that is mentioned in the CSGO Quirks wiki page linked by the other user:

Quote:
Originally Posted by WildCard65 View Post
Thanks WildCard, this worked for me at least for the most part. However, I now have a different Issue.

I implemented the Second method described on the page, using this code as an example:

PHP Code:
#include <sourcemod>
#include <sdktools>
 
new const String:FULL_SOUND_PATH[] = "sound/custom/ur.mp3";
new const 
String:RELATIVE_SOUND_PATH[] = "*/custom/ur.mp3";
 
public 
OnPluginStart()
{
    
RegConsoleCmd"sm_testsound"sm_testsound );
}
 
public 
OnMapStart()
{
    
AddFileToDownloadsTableFULL_SOUND_PATH );
    
FakePrecacheSoundRELATIVE_SOUND_PATH );
}
 
public 
Action:sm_testsoundclientargc )
{
    
EmitSoundToClientclientRELATIVE_SOUND_PATH );
 
    return 
Plugin_Handled;
}
 
stock FakePrecacheSound( const String:szPath[] )
{
    
AddToStringTableFindStringTable"soundprecache" ), szPath );

This Method works well, although there is one "Hitch" using the "Fake" precache method only seems to precache the sound for the client if they are connected to the server during the precache.

Perhaps this is a flaw related to how I coded the precache, here is the additional code I added:

PHP Code:
static String:CHECK_MP3_STRING[5] = ".mp3"

public SM_OnSjConfigLoaded()
{
    new 
soundId
    
for (new soundGroupId 0soundGroupId SoundGroupsCountsoundGroupId++)
    {
        for (
soundId 0soundId SoundCount[soundGroupId]; soundId++)
        {
            
PrecacheSound(SoundPaths[soundGroupId][soundId]);
            
            
// Check if the file is an .mp3
            
if (StrContains(SoundPaths[soundGroupId][soundId], CHECK_MP3_STRINGtrue) > 0)
                {
                    
PrintToServer("------- File contains .mp3 ------ fake cache ------  %s  "SoundPaths[soundGroupId][soundId]);
                    
// Below, workaround for playing CUSTOM sounds in CSGO
                    
decl String:relativeSoundPath[PLATFORM_MAX_PATH];
                    
Format(relativeSoundPathsizeof(relativeSoundPath), "*/%s"SoundPaths[soundGroupId][soundId]);
                    
FakePrecacheSoundrelativeSoundPath );
                }
                
            
decl String:fullSoundPath[PLATFORM_MAX_PATH];
            
Format(fullSoundPathsizeof(fullSoundPath), "sound/%s"SoundPaths[soundGroupId][soundId]);
            
AddFileToDownloadsTable(fullSoundPath);
        }
    }
}

stock FakePrecacheSound( const String:szPath[] )
{
    
AddToStringTableFindStringTable"soundprecache" ), szPath );

This code works correctly to precache the sound, the only issue is, if the server has loaded a map before the client connects, then the sound will not be Precached for the client until the server changes the map again.

My question is, can I simply adjust the String Table "soundprecache" for each client as they connect to the server?

Based on the Usage on this page: https://sm.alliedmods.net/new-api/sd...dToStringTable

PHP Code:
/**
 * Adds a string to a given string table.
 *
 * @param tableidx        A string table index.
 * @param str        String to add.
 * @param userdata        An optional user data string.
 * @param length        Length of user data string. This should include the null terminator.
 *                        If set to -1, then user data will be not be altered if the specified string
 *                        already exists in the string table.
 */
native AddToStringTable(tableidx, const String:str[], const String:userdata[]=""length=-1); 
I'm not sure what will happen, or if it would be a bad thing to simply call the "Fake PreCache" function each time a new client connects:

PHP Code:
stock FakePrecacheSound( const String:szPath[] )
{
    
AddToStringTableFindStringTable"soundprecache" ), szPath );

Although the arguments listed for AddToStringTable says that

"@param length - If set to -1, then user data will be not be altered if the specified string already exists in the string table."

TL;DR

How can I safely Re-fakeCache the sound (that has already been "fake" precached) for each client that joins the server AFTER the initial precache?

Thank you!!

Last edited by Gotank65; 08-11-2016 at 17:43. Reason: Fix code all on one line
Gotank65 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:53.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode