AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Client index 0 is invalid (https://forums.alliedmods.net/showthread.php?t=325067)

jugule 06-07-2020 09:18

Client index 0 is invalid
 
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?

DJ Tsunami 06-07-2020 11:46

Re: Client index 0 is invalid
 
You're passing 0 to GetClientTeam, which is not a valid client index.

jugule 06-09-2020 08:55

Re: Client index 0 is invalid
 
Quote:

Originally Posted by DJ Tsunami (Post 2704456)
You're passing 0 to GetClientTeam, which is not a valid client index.

The problem persists.

andi67 06-09-2020 13:39

Re: Client index 0 is invalid
 
The hole blockcode could be helpful......

ddhoward 06-09-2020 14:20

Re: Client index 0 is invalid
 
Quote:

Originally Posted by jugule (Post 2704771)
The problem persists.

Then you didn't fix it.

Stop calling GetClientTeam() if client == 0.

Balimbanana 06-09-2020 21:15

Re: Client index 0 is invalid
 
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.

Silvers 06-09-2020 21:38

Re: Client index 0 is invalid
 
The servers entity index is 0 on a listen server. The clients entity index is 1. Clients start from 1.

Peace-Maker 06-12-2020 05:46

Re: Client index 0 is invalid
 
The attacker and inflictor parameters can be 0 for e.g. fall damage.

jugule 06-12-2020 05:56

Re: Client index 0 is invalid
 
Solved! Thanks!

Marttt 06-12-2020 16:51

Re: Client index 0 is invalid
 
As Peace-Maker said, entity can be 0, which means "world" (fall damage, prop damage), glad you solved.


All times are GMT -4. The time now is 12:53.

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