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

Solved "Client X is not connected" directly after IsClientConnected


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-20-2018 , 12:04   "Client X is not connected" directly after IsClientConnected
Reply With Quote #1

Quote:
L 03/19/2018 - 19:07:46: [SM] Native "EmitSound" reported: Client 18 is not connected
L 03/19/2018 - 19:07:46: [SM] Displaying call stack trace for plugin "l4d_crowned_horde.smx":
L 03/19/2018 - 19:07:46: [SM] [0] Line 370, E:\SM Plugins\SM 1.3 Compiler\include\sdktools_sound.inc::EmitSoun dToClient()
L 03/19/2018 - 19:07:46: [SM] [1] Line 479, l4d_crowned_horde.sp:laySound()
L 03/19/2018 - 19:07:46: [SM] [2] Line 302, l4d_crowned_horde.sp::Event_WitchHarasserSet( )
Code:
	new i;
	for (i = 1; i <= GetMaxClients(); i++)
	{
		if (!IsClientConnected(i))
		{
			continue;
		}
		if (IsFakeClient(i))
		{
			continue;
		}

		EmitSoundToClient(i, sound_witch, witch_id, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
	}
Looks like exception by design?

Nothing that I can improve here to prevent it?

Last edited by Dragokas; 03-20-2018 at 17:23. Reason: Solved
Dragokas is offline
StealthGus
Junior Member
Join Date: Mar 2015
Old 03-20-2018 , 12:37   Re: "Client X is not connected" directly after IsClientConnected
Reply With Quote #2

You aren't checking for IsClientConnected, you're checking !IsClientConnected or if client is not connected. Same thing with your "IsFakeClient". And then you're having it continue to a function that is trying to perform something on a client that is either not there or is a fake client.

You should change it to something like this:

PHP Code:
for (int i 1MaxClientsi++) {
  if (
IsClientConnected(i) && !IsFakeClient(i)) {
    
EmitSoundToClient(isound_witchwitch_idSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGSSNDVOL_NORMALSNDPITCH_NORMAL, -1NULL_VECTORNULL_VECTORtrue0.0);
  }


Last edited by StealthGus; 03-20-2018 at 12:42.
StealthGus is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 03-20-2018 , 12:48   Re: "Client X is not connected" directly after IsClientConnected
Reply With Quote #3

Old syntax because your plugin is written in old syntax. There's no point playing sounds to clients that can't hear them anyway, that's why you check IsClientInGame.

Code:
for (new i = 1; i <= MaxClients; i++)
{
	if (IsClientInGame(i) && !IsFakeClient(i))
	{
		EmitSoundToClient(i, sound_witch, witch_id, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
	}
}

Last edited by Visual77; 03-20-2018 at 13:09.
Visual77 is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 03-20-2018 , 12:51   Re: "Client X is not connected" directly after IsClientConnected
Reply With Quote #4

Quote:
Originally Posted by StealthGus View Post
You aren't checking for IsClientConnected, you're checking !IsClientConnected or if client is not connected. Same thing with your "IsFakeClient". And then you're having it continue to a function that is trying to perform something on a client that is either not there or is a fake client.

You should change it to something like this:

PHP Code:
for (int i 1MaxClientsi++) {
  if (
IsClientConnected(i) && !IsFakeClient(i)) {
    
EmitSoundToClient(isound_witchwitch_idSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGSSNDVOL_NORMALSNDPITCH_NORMAL, -1NULL_VECTORNULL_VECTORtrue0.0);
  }

His conditions are correct. If not connected = skip. If fakeclient = skip. Otherwise Emit sound.
__________________

Last edited by hleV; 03-20-2018 at 12:52.
hleV is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-20-2018 , 13:01   Re: "Client X is not connected" directly after IsClientConnected
Reply With Quote #5

StealthGus,

1) as far as I know from C++, 'continue' command in 'for' cycles mean skipping all lines until last scope of "for" command and starting new iteration, so EmitSoundToClient will be skipped if IsClientConnected is not connected or if fake client. So,
your code example should be a functionally analogue. Would you like to say that "continue" behaviour is somehow different in SourcePawn?

2) How
Code:
(1) && (2)
considered in SourcePawn: will (2) be called if (1) is false ?
Dragokas is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 03-20-2018 , 13:23   Re: "Client X is not connected" directly after IsClientConnected
Reply With Quote #6

Quote:
Originally Posted by Dragokas View Post
considered in SourcePawn: will (2) be called if (1) is false ?
(2) will not be called if (1) is false.
Visual77 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-20-2018 , 14:14   Re: "Client X is not connected" directly after IsClientConnected
Reply With Quote #7

The error maybe misleading, the player is probably needed to be in game (fully connected) to emit to.
Mitchell is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-20-2018 , 17:21   Re: "Client X is not connected" directly after IsClientConnected
Reply With Quote #8

Good point, thanks.

Ahh, missed Visual77 answer.
Quote:
Reply With Quote Multi-Quote This Message Quick reply to this message #3
Old syntax because your plugin is written in old syntax. There's no point playing sounds to clients that can't hear them anyway, that's why you check IsClientInGame.
Thanks.

BTW. Not my code/code style, so I'll leave that syntax as is for now.
Dragokas is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 03-20-2018 , 19:04   Re: "Client X is not connected" directly after IsClientConnected
Reply With Quote #9

Quote:
Originally Posted by Dragokas View Post
Nothing that I can improve here to prevent it?
Looking at the EmitSound code, the error message should really say like "client is not in game" as Visual77 said. You could file an issue on Github if you want.

Last edited by Fyren; 03-20-2018 at 19:05.
Fyren is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 03-20-2018 , 20:07   Re: "Client X is not connected" directly after IsClientConnected
Reply With Quote #10

Quote:
Originally Posted by Fyren View Post
Looking at the EmitSound code, the error message should really say like "client is not in game" as Visual77 said. You could file an issue on Github if you want.
Since Fyren has said this, I made a pull request that improves this error. Creating an issue is no longer necessary :p
headline 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 18:17.


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