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

Solved AddNormalSoundHook. Client X is not connected


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 02-13-2019 , 21:13   AddNormalSoundHook. Client X is not connected
Reply With Quote #1

Hi,

please, can you tip me, why this sometimes cause:

Quote:
L 02/12/2019 - 00:55:08: [SM] Exception reported: Client 8 is not connected
L 02/12/2019 - 00:55:08: [SM] Blaming: l4d_panic_stunning.smx::OnNormalSoundPlay
L 02/12/2019 - 00:55:08: [SM] Exception reported: Client 8 is not connected
L 02/12/2019 - 00:55:08: [SM] Blaming: l4d_panic_stunning.smx::OnNormalSoundPlay
L 02/12/2019 - 00:55:08: [SM] Exception reported: Client 8 is not connected
.....
PHP Code:
AddNormalSoundHook(OnNormalSoundPlay);

...

public 
Action OnNormalSoundPlay(int clients[MAXPLAYERS], int &numClients,
        
char sample[PLATFORM_MAX_PATH], int &entityint &channelfloat &volumeint &level,
        
int &pitchint &flagschar soundEntry[PLATFORM_MAX_PATH], int &seed)
{
    if  ((
StrContains(sampleSOUND_DESTROY_1) == -1) && // exclude destroying sound
         
(StrContains(sampleSOUND_DESTROY_2) == -1) &&
         (
StrContains(sampleSOUND_DESTROY_3) == -1) &&
         (
StrContains(sampleSOUND_DESTROY_4) == -1))
    {
        if (
numClients == || !g_bAtLeastOneDeaf) return Plugin_Continue// just in case

        //remove clients from array
        
bool bFlag false;
        
int ij;
        for (
0numClientsi++)
        {
            if (!
bFlag)
            {
                if (
g_iDeafLock[clients[i]] > || !IsClientInGame(clients[i]))
                {
                    
bFlag true;    // at least one deaf client
                    
i;            // deaf client pos mark
                    
numClients--;
                }
            }
            else {
                if (
g_iDeafLock[clients[i]] > || !IsClientInGame(clients[i]))
                {
                    
numClients--;
                }
                else {
                    
clients[j] = clients[i]; // move values to the left
                    
j++;
                }
            }
        }
        if (
numClients == 0)
        {
            return 
Plugin_Handled;
        }
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;

g_iDeafLock is array of "booleans" 0, 1 - that define whether client should be deaf.

As you can see IsClientInGame is exist and should filter "Client 8 is not connected" error.

Thanks.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 02-15-2019 at 02:28.
Dragokas is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-14-2019 , 04:23   Re: AddNormalSoundHook. Client X is not connected
Reply With Quote #2

Yeah, don't do this

PHP Code:
for (0numClientsi++) 
at the same time you're doing this

PHP Code:
numClients--; 
The middle part of an if statement is evaluated on every loop, meaning that you're no longer checking the entire array as soon as you run into a deaf client.

Make a copy of numClients and use that in the if.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 02-14-2019 , 05:28   Re: AddNormalSoundHook. Client X is not connected
Reply With Quote #3

ahh, ok, thanks a much.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Reply



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 00:01.


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