Raised This Month: $12 Target: $400
 3% 

Error with a join sound.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 07-14-2019 , 06:52   Error with a join sound.
Reply With Quote #1

First of all, sorry for spaming this section but i'm trying to learn more about keyvalues because they are OP.

PHP Code:

public void OnClientPutInServer(int Client)
{
    if(
HasJoinSounds(Client))
    {
        
CreateTimer(GetRandomFloat(20.030.0), PlayJoinSoundClient);
    }
}

bool HasJoinSounds(int Client)
{
    
char szAuthID[32];
    
GetClientAuthId(ClientAuthId_Steam3szAuthIDsizeof(szAuthID)) 
    
/* Format : U:1:430133270 */
    
    
char Configfile[1024];
    
BuildPath(Path_SMConfigfile1024"configs/tz_plugins/JoinSounds.txt");
    
    if(!
FileExists(Configfile))
        
SetFailState("Can not find config file \"%s\"!"Configfile);
    
    
KeyValues hKV CreateKeyValues("JoinSound");
    
hKV.ImportFromFile(Configfile);
    
    if(
hKV.GetString(szAuthIDg_szSoundPath[Client], sizeof(g_szSoundPath)))
        return 
true;
    
    
hKV.Rewind();
    
delete hKV;    

    return 
false;
}

public 
Action PlayJoinSound(Handle pTimerany Data)
{
    
int Client GetClientOfUserId(Data);
    
EmitSoundToAll(g_szSoundPath[Client]);

This sould be my config :

PHP Code:
"JoinSound"
{
    
"U:1:430133270"    "joinsounds/laugh.mp3"

I don't really know why. I have an plugin that auto download any texture, model, sound and precache it.
Because I dont precache my sound in the source code is the main reason why my song it's not played
__________________

Last edited by kratoss1812; 07-14-2019 at 07:02.
kratoss1812 is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 07-14-2019 , 08:18   Re: Error with a join sound.
Reply With Quote #2

1. OnClientPutInServer is typically too early, to guarantee a proper Steam ID. If you really need a guarantee of a valid Steam ID, use OnClientPostAdminCheck.

2. Remember to check the bool return value of GetClientAuthId:

-> https://forums.alliedmods.net/showth...93#post2495993

-> https://forums.alliedmods.net/showth...99#post2551499

Code:
if (GetClientAuthId(Client, AuthId_Steam3, szAuthID, sizeof(szAuthID))) {
  /* YES! DO SOMETHING WITH THIS GOOD STEAM ID */
}
3. "U:1:430133270" is not a Steam 3 ID, "[U:1:430133270]" is.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 07-14-2019 , 08:27   Re: Error with a join sound.
Reply With Quote #3

Quote:
Originally Posted by DarkDeviL View Post
1. OnClientPutInServer is typically too early, to guarantee a proper Steam ID. If you really need a guarantee of a valid Steam ID, use OnClientPostAdminCheck.

2. Remember to check the bool return value of GetClientAuthId:

-> https://forums.alliedmods.net/showth...93#post2495993

-> https://forums.alliedmods.net/showth...99#post2551499

Code:
if (GetClientAuthId(Client, AuthId_Steam3, szAuthID, sizeof(szAuthID))) {
  /* YES! DO SOMETHING WITH THIS GOOD STEAM ID */
}
3. "U:1:430133270" is not a Steam 3 ID, "[U:1:430133270]" is.
My reaction reading this was "Oooooh"
I knew all of these but im just dumb.

Thank you so much
__________________
kratoss1812 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 02:10.


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