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

IsFakeClient() throw error when Client is not connected,extremely rare error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
little_froy
Senior Member
Join Date: May 2021
Old 07-01-2021 , 10:01   IsFakeClient() throw error when Client is not connected,extremely rare error
Reply With Quote #1

L 07/01/2021 - 19:25:07: [SM] [0] IsFakeClient
L 07/01/2021 - 19:25:07: [SM] [1] Line 52, D:\L4D2PROJECTS\A-Plugins Important 20210630\A-Important - 重要插件\avoid_re - OK\avoid_2.1.sp::OnPlayerRunCmd
L 07/01/2021 - 19:25:07: [SM] Exception reported: Client 2 is not connected
L 07/01/2021 - 19:25:07: [SM] Blaming: break_chi1.1.smx
L 07/01/2021 - 19:25:07: [SM] Call stack trace:
L 07/01/2021 - 19:25:07: [SM] [0] IsFakeClient
L 07/01/2021 - 19:25:07: [SM] [1] Line 146, D:\L4D2PROJECTS\A- NEW- Important - 重要插件 20210629\A- NEW- Important - 重要插件\break_chi - OK\break_chi1.1.sp::OnPlayerRunCmd
L 07/01/2021 - 19:25:07: [SM] Exception reported: Client 1 is not connected
L 07/01/2021 - 19:25:07: [SM] Blaming: avoid_2.1.smx

is there any better imrove, or just add IsClientConnected() before IsFakeClient()?....

Last edited by little_froy; 07-02-2021 at 02:02.
little_froy is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-01-2021 , 17:06   Re: IsFakeClient() throw error when IsClientConnected() return false,extremely rare e
Reply With Quote #2

Should always check IsClientInGame* first
__________________

Last edited by Marttt; 07-02-2021 at 07:03.
Marttt is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 07-01-2021 , 22:50   Re: IsFakeClient() throw error when IsClientConnected() return false,extremely rare e
Reply With Quote #3

IsClientConnected() check is not enough.
You should check for IsClientInGame() before doing IsFakeClient().
IsClientInGame is already includes IsClientConnected() check.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
little_froy
Senior Member
Join Date: May 2021
Old 07-02-2021 , 02:04   Re: IsFakeClient() throw error when IsClientConnected() return false,extremely rare e
Reply With Quote #4

Quote:
Originally Posted by Dragokas View Post
IsClientConnected() check is not enough.
You should check for IsClientInGame() before doing IsFakeClient().
IsClientInGame is already includes IsClientConnected() check.
but the API https://sm.alliedmods.net/new-api/cl...IsClientInGame not have to be connected

Returns if a certain player has entered the game.

bool IsClientInGame(int client)
Parameters
int client
Player index (index does not have to be connected).

Last edited by little_froy; 07-02-2021 at 02:04.
little_froy is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 07-02-2021 , 02:11   Re: IsFakeClient() throw error when Client is not connected,extremely rare error
Reply With Quote #5

Meaning they don't have to be connected to check, it will return false and no error. Use IsClientInGame instead of IsClientConnected unless you have to check if someone is connected but not in-game.
__________________
Silvers is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 07-02-2021 , 03:25   Re: IsFakeClient() throw error when Client is not connected,extremely rare error
Reply With Quote #6

PHP Code:

static cell_t sm_IsClientFakeClient(IPluginContext *pCtx, const cell_t *params)
{
    
int index params[1];
    if ((
index 1) || (index playerhelpers->GetMaxClients()))
    {
        return 
pCtx->ThrowNativeError("Client index %d is invalid"index);
    }

    
IGamePlayer *pPlayer playerhelpers->GetGamePlayer(index);
    if (!
pPlayer->IsConnected())
    {
        return 
pCtx->ThrowNativeError("Client %d is not connected"index);
    }

    return (
pPlayer->IsFakeClient()) ? 0;

You should check first if client index is valid (if necessary) and if its connected or in game.
__________________
Ilusion9 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 15:57.


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