AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [HELP]Exception reported: Entity 1 (1) is invalid (https://forums.alliedmods.net/showthread.php?t=326936)

XGAK 08-24-2020 06:43

[HELP]Exception reported: Entity 1 (1) is invalid
 
Code:

L 08/24/2020 - 17:50:17: [SM] Exception reported: Entity 1 (1) is invalid
L 08/24/2020 - 17:50:17: [SM] Blaming: freaks\the_world.ff2
L 08/24/2020 - 17:50:17: [SM] Call stack trace:
L 08/24/2020 - 17:50:17: [SM]  [0] SetEntPropEnt
L 08/24/2020 - 17:50:17: [SM]  [1] Line 461, the_world.sp::Timer_EndAbility

Here is the code.
Code:

public Action:Timer_EndAbility(Handle:htimer, int boss)
{
        ISTIMEFREEZED = false;
        char classname[60];
        SetConVarInt(FindConVar("sv_client_predict"), 1);
        for(new i=1; i<=MaxClients; i++)
        {
                if(IsValidClient(i) && !IsBoss(i))
                {
                        SetClientOverlay(i, "");
                        if(T_targeted[i]==1)
                        {
//                                new attacker = GetClientOfUserId(FF2_GetBossUserId(0));
                                stabdamage=FF2_GetAbilityArgumentFloat(0, this_plugin_name, ABILITY_NAME1 , 2, 320.0);
                                SDKHooks_TakeDamage(i, boss, boss, stabdamage, DMG_SLASH|DMG_ALWAYSGIB);
                                T_targeted[i]=0;
                        }
                        SetEntityMoveType(i, iPrevCollision[i]);
                        SetEntProp(i, Prop_Send, "m_bIsPlayerSimulated", 1);
                        SetEntProp(i, Prop_Send, "m_bSimulatedEveryTick", 1);
                        SetEntProp(i, Prop_Send, "m_bAnimatedEveryTick", 1);
                        SetEntProp(i, Prop_Send, "m_bClientSideAnimation", 1);
                        SetEntProp(i, Prop_Send, "m_bClientSideFrameReset", 0);
                        SetEntPropFloat(i, Prop_Send, "m_flNextAttack", GetGameTime());
                        new weapon = GetEntPropEnt(i, Prop_Send, "m_hActiveWeapon");
                        if(IsValidEntity(weapon))
                        {
                                SetEntProp(weapon, Prop_Send, "m_bIsPlayerSimulated", 1);
                                SetEntProp(weapon, Prop_Send, "m_bAnimatedEveryTick", 1);
                                SetEntProp(weapon, Prop_Send, "m_bSimulatedEveryTick", 1);
                                SetEntProp(weapon, Prop_Send, "m_bClientSideAnimation", 1);
                                SetEntProp(weapon, Prop_Send, "m_bClientSideFrameReset", 0);
                        }
                        TF2_RemoveCondition(i, TFCond_FreezeInput);
                }
                else
                {
                        iPrevCollision[i]=MOVETYPE_WALK; // Reset
                }
                SDKUnhook(i, SDKHook_OnTakeDamage, OnTakeDamageTW);
        }

        for(int entity = 33; entity <= MAXENTITIES; entity++)
        {
                if(IsValidEntity(entity))
                {
                        GetEntityClassname(entity, classname, sizeof(classname));
                        if(!StrContains(classname, "obj_"))
                        {
                                if(TF2_GetObjectType(entity) == TFObject_Dispenser
                                || TF2_GetObjectType(entity) == TFObject_Teleporter
                                || TF2_GetObjectType(entity) == TFObject_Sentry)
                                {
                                        SetEntProp(entity, Prop_Send, "m_bDisabled", 0);
                                        SetEntProp(entity, Prop_Send, "m_bIsPlayerSimulated", 1);
                                        SetEntProp(entity, Prop_Send, "m_bAnimatedEveryTick", 1);
                                        SetEntProp(entity, Prop_Send, "m_bSimulatedEveryTick", 1);
                                        SetEntProp(entity, Prop_Send, "m_bClientSideAnimation", 1);
                                        SetEntProp(entity, Prop_Send, "m_bClientSideFrameReset", 1);
                                }
                        }
                        if(!StrContains(classname, "tf_projectile"))
                        {
                                SetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity", boss);
                                if(GetEntProp(entity, Prop_Send, "m_nForceBone") == 998)
                                        SetEntityMoveType(entity, iPrevCollision[entity]);
                                else
                                        SetEntityMoveType(entity, MOVETYPE_FLY);
                                SetVariantInt(BossTeam);
                                AcceptEntityInput(entity, "TeamNum", -1, -1, 0);
                                SetVariantInt(BossTeam);
                                AcceptEntityInput(entity, "SetTeam", -1, -1, 0);
                                SetEntProp(entity, Prop_Send, "m_nSkin", (BossTeam==_:TFTeam_Blue) ? 1 : 0);
                                // invert angles
                                new Float:angle[3];
                                GetEntPropVector(entity, Prop_Data, "m_angRotation", angle);
                                angle[0] = -angle[0]; //fixAngle(angle[0] + 180.0);
                                angle[1] = fixAngle(angle[1] + 180.0);
                                // redo velocity
                                new Float:velocity[3];
                                GetAngleVectors(angle, velocity, NULL_VECTOR, NULL_VECTOR);
                                if(StrEqual(classname, "tf_projectile_pipe_remote"))
                                {
                                        SetEntPropEnt(entity, Prop_Data, "m_hThrower", boss);

                                        SDKCall(g_CTFGrenadeDetonate, entity);
                                }
                                if(StrEqual(classname, "tf_projectile_pipe"))
                                {

                                        SetEntPropEnt(entity, Prop_Data, "m_hThrower", boss);

                                        SetEntityMoveType(entity, MOVETYPE_FLYGRAVITY);
                                        SDKHook(entity, SDKHook_StartTouch, ProjectileTouchHook);
                                        ScaleVector(velocity, 500.0);
                                }
                                else
                                        ScaleVector(velocity, 800.0);
                                TeleportEntity(entity, NULL_VECTOR, angle, velocity);

                                if(HasEntProp(entity, Prop_Send, "m_iDeflected"))
                                        SetEntPropEnt(entity, Prop_Send, "m_iDeflected", GetEntProp(entity, Prop_Send, "m_iDeflected")+1);

                        }
                }
        }


        return Plugin_Continue;
}

This error appears once in a while. How can I fix it?

DJ Tsunami 08-24-2020 06:51

Re: [HELP]Exception reported: Entity 1 (1) is invalid
 
m_iDeflected is a plain integer, not an entity index, so use SetEntProp instead of SetEntPropEnt.

XGAK 08-24-2020 07:02

Re: [HELP]Exception reported: Entity 1 (1) is invalid
 
Quote:

Originally Posted by DJ Tsunami (Post 2715354)
m_iDeflected is a plain integer, not an entity index, so use SetEntProp instead of SetEntPropEnt.

Thanks!
Will fix it.


All times are GMT -4. The time now is 21:00.

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