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

Client not connected Prevention.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
extremeg
Senior Member
Join Date: Dec 2012
Old 04-21-2018 , 18:06   Client not connected Prevention.
Reply With Quote #1

Hello guys,

I have the question to you if someone of you maybe know how we can prevent that connected players which are alive that we become sometimes the error:

Exception reported: Client 3 is not connected

My problem is that i dont understand it why. The player is connected successfully and is already a time on the server. I have already a check for every command that i check with IsValidClient(client) that already includes a IsClientConnected check for the client. This tells me then that this function (IsClientConnected) maybe dont works? When i check before i access to the command with IsValidClient(client) and it returns true it cant be right.

Code of IsValidClient:

Code:
stock bool IsValidClient(int client)
{
	if (client >= 1 && client <= MaxClients && IsValidEntity(client) && IsClientConnected(client) && IsClientInGame(client))
	{
		return true;
	}
	
	return false;
}
good Regards,
cRUSHER [#HLG]

Last edited by extremeg; 04-21-2018 at 18:18.
extremeg is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 04-21-2018 , 18:51   Re: Client not connected Prevention.
Reply With Quote #2

Show us the actual code that causes the run-time error.
Fyren is offline
Bara
AlliedModders Donor
Join Date: Apr 2012
Location: Germany
Old 04-21-2018 , 20:37   Re: Client not connected Prevention.
Reply With Quote #3

Remove IsValidEntity and IsClientConnected (from your IsValidClient stock), your error should be fixed now with the "same" valid check.
__________________
Discord (Bara#5006) | My Plugins (GitHub)
You like my work? Support is not a crime.

Last edited by Bara; 04-21-2018 at 20:37.
Bara is offline
pride95
Senior Member
Join Date: Aug 2015
Old 04-22-2018 , 06:09   Re: Client not connected Prevention.
Reply With Quote #4

PHP Code:

RegConsoleCmd
("sm_spec"Client_Spec);

public 
Action Client_Spec(int Clientint Args)
{
    if(
Client != 0// Client 0 means the server itself.
    
{
        
SpecPlayer(ClientArgs);
    }    
        
    return 
Plugin_Handled;

show SpecPlayer function.

in post commands hook client is always connected and in game (like regadmincmd, regconsolecmd or OnClientSayCommand_Post).

if you hook a command with OnClientSayCommand or addcommandlistener you should chech after Client != 0, if IsClientInGame(Client).
pride95 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 04-23-2018 , 07:03   Re: Client not connected Prevention.
Reply With Quote #5

I know you solved your problem but I just want to share my IsValidClient stock with you since it looks different from yours.

PHP Code:
stock bool bIsValidClient(int client)
{
    return (
client && client <= MaxClients && IsClientInGame(client) && !IsClientInKickQueue(client) && !IsFakeClient(client));

I also noticed that your stock originally had IsClientConnected() && IsClientInGame in it, which is redundant.

This post explains why: https://forums.alliedmods.net/showthread.php?t=132438
__________________
Psyk0tik 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 03:04.


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