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

Exception reported: Client index 0 is invalid


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
slava123
Junior Member
Join Date: Apr 2022
Location: zm_crazycity
Old 07-17-2022 , 09:15   Exception reported: Client index 0 is invalid
Reply With Quote #1

PHP Code:
for ( new <= MaxClients i++ )
    {
        if(
IsClientInGame(i) && !IsFakeClient(i))
        {
            
ShowSyncHudText(ihHudText"%t""stats"GetClientFrags(i), GetClientDeaths(i), topGetClientFrags(maxK), GetClientDeaths(maxK)); // line 72
        
}
    } 
the code is working but this error keep showing in server console any idea how to fix this?

L 07/17/2022 - 09:07:04: [SM] Exception reported: Client index 0 is invalid
L 07/17/2022 - 09:07:04: [SM] Blaming: plugin.smx
L 07/17/2022 - 09:07:04: [SM] Call stack trace:
L 07/17/2022 - 09:07:04: [SM] [0] GetClientDeaths
L 07/17/2022 - 09:07:04: [SM] [1] Line 72, plugin.sp PrintMsg

Last edited by slava123; 07-17-2022 at 09:17.
slava123 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-17-2022 , 09:18   Re: Exception reported: Client index 0 is invalid
Reply With Quote #2

The error is somewhere else (line 72), doesn't seem to be what you pasted but what is inside GetClientDeaths
May be the maxK var aswell, with this little snippet can't say
__________________

Last edited by Marttt; 07-17-2022 at 09:18.
Marttt is offline
slava123
Junior Member
Join Date: Apr 2022
Location: zm_crazycity
Old 07-17-2022 , 09:31   Re: Exception reported: Client index 0 is invalid
Reply With Quote #3

maxK is the player that has the most kills but its only show the real client not fake ones is that what the problem is? because if there is no clients on the server the server cannot get the top 1, any way here is the the full script:
PHP Code:
    new maxK 0;
    
Players[0] = 0;
    new 
String:top[100];

    for (new 
1<= MaxClientsi++)
    if (
IsClientInGame(i) && !IsFakeClient(i))
    {
        if (
Players[i] > Players[maxK]) maxK i;
        if((
GetClientFrags(i) == 0) && (GetClientDeaths(i) == 0)) Players[maxK] = 0;
    }

    
GetClientName(maxK,top,100);

    if(
StrEqual(hostnametopfalse))
        
top "Nobody";
    
    new 
Handle:hHudText CreateHudSynchronizer();
    
SetHudTextParams(-1.5, -1.74.002550255);
    for ( new 
<= MaxClients i++ )
    {
        if(
IsClientInGame(i) && !IsFakeClient(i))
        {
            
ShowSyncHudText(ihHudText"%t""stats"GetClientFrags(i), GetClientDeaths(i), topGetClientFrags(maxK), GetClientDeaths(maxK));
        }
    }
    
CloseHandle(hHudText); 
slava123 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-17-2022 , 14:38   Re: Exception reported: Client index 0 is invalid
Reply With Quote #4

probably, if there are no real clients maxK will be 0 then will throw that error
May be better to check if maxK is 0 then exit the function.
__________________
Marttt is offline
slava123
Junior Member
Join Date: Apr 2022
Location: zm_crazycity
Old 07-18-2022 , 08:59   Re: Exception reported: Client index 0 is invalid
Reply With Quote #5

like that?
PHP Code:
if(IsClientInGame(i) && !IsFakeClient(i) && maxK != 0)
        {
            
ShowSyncHudText(ihHudText"%t""stats"GetClientFrags(i), GetClientDeaths(i), topGetClientFrags(maxK), GetClientDeaths(maxK));
        } 
sorry I'm really new to this
slava123 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-18-2022 , 13:52   Re: Exception reported: Client index 0 is invalid
Reply With Quote #6

may work like that too, now try and see
__________________
Marttt is offline
slava123
Junior Member
Join Date: Apr 2022
Location: zm_crazycity
Old 07-18-2022 , 17:28   Re: Sloved Exception reported: Client index 0 is invalid
Reply With Quote #7

tysm!! it works like magic
slava123 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 13:53.


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