Raised This Month: $2 Target: $400
 0% 

Client index 0 is invalid


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jugule
Member
Join Date: Apr 2020
Old 06-07-2020 , 09:18   Client index 0 is invalid
Reply With Quote #1

PHP Code:
L 06/07/2020 11:39:36: [SMException reportedClient index 0 is invalid
L 06
/07/2020 11:39:36: [SMBlamingtest.smx
L 06
/07/2020 11:39:36: [SMCall stack trace:
L 06/07/2020 11:39:36: [SM]   [0GetClientTeam
L 06
/07/2020 11:39:36: [SM]   [1Line 1386test.sp::Hook_OnTakeDamage 
function:

PHP Code:
if(test)
        {
            
            if(
GetClientTeam(client) == 2)
            {
                if(
GetClientTeam(attacker) == GetClientTeam(client) && IsFreezed[client] && !IsFreezed[attacker])
                {
                
SetEntityMoveType(clientMOVETYPE_WALK);
                
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"1.0);
                
SetEntityRenderColor(client255255255255);
                
IsFreezed[client] = false;
                --
FreezeCount;
                } 
                else if(
GetClientTeam(attacker) != GetClientTeam(client) && !IsFreezed[client])
                {
                
SetEntityMoveType(clientMOVETYPE_NONE);
                
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"0.0);
                
SetEntityRenderColor(client00255255);
                
IsFreezed[client] = true;
                ++
FreezeCount;
                }
            }
        } 
what is problem with this?

Last edited by jugule; 06-07-2020 at 09:18.
jugule is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Old 06-07-2020 , 11:46   Re: Client index 0 is invalid
Reply With Quote #2

You're passing 0 to GetClientTeam, which is not a valid client index.
__________________
DJ Tsunami is offline
jugule
Member
Join Date: Apr 2020
Old 06-09-2020 , 08:55   Re: Client index 0 is invalid
Reply With Quote #3

Quote:
Originally Posted by DJ Tsunami View Post
You're passing 0 to GetClientTeam, which is not a valid client index.
The problem persists.
jugule is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 06-09-2020 , 13:39   Re: Client index 0 is invalid
Reply With Quote #4

The hole blockcode could be helpful......
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 06-09-2020 , 14:20   Re: Client index 0 is invalid
Reply With Quote #5

Quote:
Originally Posted by jugule View Post
The problem persists.
Then you didn't fix it.

Stop calling GetClientTeam() if client == 0.
__________________
ddhoward is offline
Balimbanana
Member
Join Date: Jan 2017
Old 06-09-2020 , 21:15   Re: Client index 0 is invalid
Reply With Quote #6

It is from a take damage hook (by the error message).
From what I have gathered, this generally happens if you are running a listen-server SourceMod, where the host is client 0, but the actual player entity is at 1. You could change it to:
Code:
if(test)
{
	if (client == 0)
	{
		if (IsValidEntity(client+1)) client++;
		else return Plugin_Continue;
	}
	if(GetClientTeam(client) == 2)
	{
		if(GetClientTeam(attacker) == GetClientTeam(client) && IsFreezed[client] && !IsFreezed[attacker])
		{
			SetEntityMoveType(client, MOVETYPE_WALK);
			SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 1.0);
			SetEntityRenderColor(client, 255, 255, 255, 255);
			IsFreezed[client] = false;
			--FreezeCount;
		} 
		else if(GetClientTeam(attacker) != GetClientTeam(client) && !IsFreezed[client])
		{
			SetEntityMoveType(client, MOVETYPE_NONE);
			SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 0.0);
			SetEntityRenderColor(client, 0, 0, 255, 255);
			IsFreezed[client] = true;
			++FreezeCount;
		}
	}
}
Also, I haven't seen the ++ or -- before the variable before, but I suppose if it works, then ok.

Last edited by Balimbanana; 06-10-2020 at 02:20.
Balimbanana is offline
Silvers
AlliedModders Donor
Join Date: Aug 2010
Location: SpaceX
Old 06-09-2020 , 21:38   Re: Client index 0 is invalid
Reply With Quote #7

The servers entity index is 0 on a listen server. The clients entity index is 1. Clients start from 1.
__________________
Silvers is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 06-12-2020 , 05:46   Re: Client index 0 is invalid
Reply With Quote #8

The attacker and inflictor parameters can be 0 for e.g. fall damage.
__________________
Peace-Maker is offline
jugule
Member
Join Date: Apr 2020
Old 06-12-2020 , 05:56   Re: Client index 0 is invalid
Reply With Quote #9

Solved! Thanks!
jugule is offline
Marttt
Senior Member
Join Date: Jan 2019
Old 06-12-2020 , 16:51   Re: Client index 0 is invalid
Reply With Quote #10

As Peace-Maker said, entity can be 0, which means "world" (fall damage, prop damage), glad you solved.
__________________

Last edited by Marttt; 06-12-2020 at 16:51.
Marttt 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 10:56.


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