View Single Post
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 04-24-2021 , 05:51   Re: [CS:GO] Invalid Edict.
Reply With Quote #4

Move the IsValidEntity(entity) check above that line, like this:
PHP Code:
public OnEntitySpawned(entity)
{
    if(
IsValidEntity(entity))
    {
        
decl String:class_name[32];
        
GetEdictClassname(entityclass_name32);
        new 
owner GetEntPropEnt(entityProp_Data"m_hOwnerEntity");
        if(
owner <= MaxClients && IsClientInGame(owner)) // add any other necessary checks here if you want
        
{
            if(
StrContains(class_name"projectile") != -&& (((GetConVarBool(g_AllowPlayers) || isAdmin(owner)) && Tails[owner]) || GetConVarBool(g_DefaultOn)))
            {
                if(
StrContains(class_name"hegrenade") != -&& GetConVarBool(g_EnableHETails))
                    
GetSetColor(g_HEColor);
                else if(
StrContains(class_name"flashbang") != -&& GetConVarBool(g_EnableFlashTails))
                    
GetSetColor(g_FlashColor);
                else if(
StrContains(class_name"smoke") != -&& GetConVarBool(g_EnableSmokeTails))
                    
GetSetColor(g_SmokeColor);
                else if(
StrContains(class_name"decoy") != -&& GetConVarBool(g_EnableDecoyTails))
                    
GetSetColor(g_DecoyColor);
                else if(
StrContains(class_name"molotov") != -&& GetConVarBool(g_EnableMolotovTails))
                    
GetSetColor(g_MolotovColor);
                else if(
StrContains(class_name"incgrenade") != -&& GetConVarBool(g_EnableIncTails))
                    
GetSetColor(g_IncColor);
                
TE_SetupBeamFollow(entityg_iBeamSprite0GetConVarFloat(g_TailTime), GetConVarFloat(g_TailWidth), GetConVarFloat(g_TailWidth), GetConVarInt(g_TailFadeTime), TempColorArray);
                
TE_SendToAll();
            }
        }
    }

Edit: I forgot to explain why you need to move the check above that line. Here goes:

Since you are working with that entity, any code you have regarding that entity that comes before validating it first is prone to causing that "invalid entity index" or "invalid edict" error. You always want to validate an entity first before working with it.
__________________

Last edited by Psyk0tik; 04-24-2021 at 05:59.
Psyk0tik is offline