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

Client not connected error: IsClientConnected() +> IsFakeClient()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ilham92-cc-sakura
Senior Member
Join Date: Oct 2008
Location: /var/www/index.html
Old 11-07-2020 , 14:24   Client not connected error: IsClientConnected() +> IsFakeClient()
Reply With Quote #1

How to prevent IsFakeClient() throw an error, I have put IsClientConnected() first

Error Log:
Code:
L 11/07/2020 - 00:11:29: [SM] Exception reported: Client 1 is not connected
L 11/07/2020 - 00:11:29: [SM] Blaming: myplugins.smx
L 11/07/2020 - 00:11:29: [SM] Call stack trace:
L 11/07/2020 - 00:11:29: [SM]   [0] IsFakeClient
L 11/07/2020 - 00:11:29: [SM]   [1] Line 278, F:\Project\DS_L4D2\Scripting\1.10.0-git6497\myplugins::CMD_CallBlock
Code:
PHP Code:
public void OnPluginStart()
{
    
// Command Call Back
    
AddCommandListener(CMD_CallBlock"wait");
    
AddCommandListener(CMD_CallBlock"pause");
    
AddCommandListener(CMD_CallBlock"unpause");
    
AddCommandListener(CMD_CallBlock"setpause");
    
AddCommandListener(CMD_CallBlock"jointeam");
    
AddCommandListener(CMD_CallBlock"go_away_from_keyboard");
}

...

public 
Action CMD_CallBlock(int client, const char[] commandint argc)
{
    if (
client == 0) \\Console
        
return Plugin_Continue;
        
    if (
IsClientConnected(client)) \\Execute only connected client
        
return Plugin_Continue;

    if (
IsFakeClient(client)) \\Bots
        
return Plugin_Continue;

    return 
Plugin_Handled
__________________
ilham92-cc-sakura is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 11-07-2020 , 14:54   Re: Client not connected error: IsClientConnected() +> IsFakeClient()
Reply With Quote #2

Your code currently returns Plugin_Continue if the client is connected. You want to return Plugin_Continue if the client is NOT connected.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 11-09-2020 , 05:51   Re: Client not connected error: IsClientConnected() +> IsFakeClient()
Reply With Quote #3

I don't think that's the case here. Also, you don't need the IsFakeClient check since bots can't do any of those commands and replace IsClientConnected with IsClientInGame since you're basically blocking no one that way. You can simply intercept all commands from being executed by connecting clients with:
PHP Code:
public void OnAllPluginsLoaded()
{
    
AddCommandListener(OnAllCmds"");
}

public 
Action OnAllCmds(int client, const char[] commandint argc)
{
    return (
client == || IsClientInGame(client)) ? Plugin_Continue Plugin_Handled;


Last edited by cravenge; 11-09-2020 at 05:52.
cravenge is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 11-09-2020 , 10:18   Re: Client not connected error: IsClientConnected() +> IsFakeClient()
Reply With Quote #4

Actually, DJ Tsunami is right. The error is caused by returning Plugin_Handled for someone that isn't even there. Plugin_Handled is only returned in this scenario to block the command from going through. If the client isn't connected, then there's nobody to block the command for, hence the error. The console and bot checks are correct, but the connection check is invalidating the OP's intended target(s) (connected players).
__________________
Psyk0tik 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 07:13.


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