AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Error with a join sound. (https://forums.alliedmods.net/showthread.php?t=317447)

kratoss1812 07-14-2019 06:52

Error with a join sound.
 
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

DarkDeviL 07-14-2019 08:18

Re: Error with a join sound.
 
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.

kratoss1812 07-14-2019 08:27

Re: Error with a join sound.
 
Quote:

Originally Posted by DarkDeviL (Post 2659059)
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


All times are GMT -4. The time now is 16:13.

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