AlliedModders

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

jugule 06-06-2020 09:11

[SM] Exception reported: Entity 1 (1) is invalid
 
06/06/2020 - 16:06:48: [SM] Exception reported: Entity 1 (1) is invalid
06/06/2020 - 16:06:48: [SM] Blaming: pluginn.smx
06/06/2020 - 16:06:48: [SM] Call stack trace:
06/06/2020 - 16:06:48: [SM][0] GetEntPropArraySize
06/06/2020 - 16:06:48: [SM][1] Line 3122, pluginn.sp::RemoveAllWeapons
06/06/2020 - 16:06:48: [SM][2] Line 6302, pluginn.sp::functiondd

6302: RemoveAllWeapons(x);

code
PHP Code:

void RemoveAllWeapons(int client)
{   
    
int length GetEntPropArraySize(clientProp_Send"m_hMyWeapons");
    for (
int i 0lengthi++) 
    {
        
int weapon GetEntPropEnt(clientProp_Send"m_hMyWeapons"i); 
        if (
weapon != -1)
        {
            
RemovePlayerItem(clientweapon);
            
AcceptEntityInput(weapon"KillHierarchy");
        }
    }
    
    
SetEntPropEnt(clientProp_Send"m_hActiveWeapon", -1);


what is problem?

Silvers 06-06-2020 09:16

Re: [SM] Exception reported: Entity 1 (1) is invalid
 
Whatever is calling RemoveAllWeapons is where the problem is. The client its passing to this function is invalid.

SpirT 06-18-2020 17:46

Re: [SM] Exception reported: Entity 1 (1) is invalid
 
Hey!

PHP Code:

DisarmPlayer(client)
{
    for(new 
05i++)
    {
        new 
weapon = -1;
        while((
weapon GetPlayerWeaponSlot(clienti)) != -1)
        {
            if(
IsValidEntity(weapon))
            {
                
RemovePlayerItem(clientweapon);
            }
        }
    }
    
SetEntProp(clientProp_Send"m_bHasDefuser"0);
    
SetEntProp(clientProp_Send"m_bHasHeavyArmor"0);
    
SetEntProp(clientProp_Send"m_ArmorValue"0);
    
SetEntProp(clientProp_Send"m_bHasHelmet"0);


I usually use this to disarm players. Try that! And the problem might not be with your custom void but yes where it is being used...

Contact me on steam or, for better purposes, post your .sp here.

Best Regards,

SpirT.

Powerlord 06-18-2020 19:13

Re: [SM] Exception reported: Entity 1 (1) is invalid
 
You're missing a IsClientInGame check in there.


All times are GMT -4. The time now is 08:29.

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