Raised This Month: $32 Target: $400
 8% 

Crash AcceptEntityInput


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BeNq!
Senior Member
Join Date: Mar 2009
Old 04-15-2019 , 10:24   Crash AcceptEntityInput
Reply With Quote #1

Hello,

This is my plugin:

PHP Code:
#pragma semicolon 1

#include <sdkhooks> 
#include <sdktools> 

public OnEntityCreatedentity, const String:classname[] )

    if( 
StrEqualclassname"weapon_p90" ) || StrEqualclassname"weapon_g3sg1" ) || StrEqualclassname"weapon_scar20" ) )
    { 
        
SDKHookentitySDKHook_SpawnHook_OnEntitySpawn ); 
    } 

public 
Action:Hook_OnEntitySpawnentity )
{     
    if( !
IsValidEntityentity ) )
        return 
Plugin_Continue;
    
    
AcceptEntityInputentity"Kill" ); 
    return 
Plugin_Handled

Unfortunately, the server crashes. Please help me.
BeNq! is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 04-15-2019 , 12:30   Re: Crash AcceptEntityInput
Reply With Quote #2

Not tested but should work

PHP Code:
#pragma semicolon 1

#include <sdkhooks> 
#include <sdktools> 

public OnEntityCreatedentity, const String:classname[] )

    if( 
StrEqualclassname"weapon_p90" ) || StrEqualclassname"weapon_g3sg1" ) || StrEqualclassname"weapon_scar20" ) )
    { 
        
SDKHookentitySDKHook_SpawnHook_OnEntitySpawn ); 
    } 

public 
Action:Hook_OnEntitySpawnentity )
{     
    if(
IsValidEntityentity ) )
    {
        
RequestFrame(view_as<RequestFrameCallback>(KillEntity), EntIndexToEntRef(entity));
    }
    return 
Plugin_Continue;
}

void KillEntity(int entityReference)
{
    
AcceptEntityInput(entityReference"Kill" ); 

__________________

Last edited by impossible_cc; 04-25-2019 at 15:20.
impossible_cc is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-15-2019 , 20:40   Re: Crash AcceptEntityInput
Reply With Quote #3

Kill is sent a frame later already, have you tried just returning Plugin_Stop on the spawn hook?
Mitchell is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 04-16-2019 , 08:25   Re: Crash AcceptEntityInput
Reply With Quote #4

I tested it and works ( not crashes ).
BeNq! is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-16-2019 , 16:56   Re: Crash AcceptEntityInput
Reply With Quote #5

Returning stop or killing a frame later?
__________________
Neuro Toxin is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 04-18-2019 , 05:52   Re: Crash AcceptEntityInput
Reply With Quote #6

PHP Code:

public void OnEntityCreated(int entity, const char[] classname)

    if (
StrEqual(classname"weapon_p90") || StrEqual(classname"weapon_g3sg1") || StrEqual(classname"weapon_scar20"))
    { 
        
SDKHook(entitySDKHook_SpawnPostHook_OnEntitySpawn); 
    } 

public 
void Hook_OnEntitySpawn(int entity)
{     
     
AcceptEntityInput(entity"Kill");

__________________
Ilusion9 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-18-2019 , 11:09   Re: Crash AcceptEntityInput
Reply With Quote #7

Quote:
Originally Posted by Ilusion9 View Post
PHP Code:

public void OnEntityCreated(int entity, const char[] classname)

    if (
StrEqual(classname"weapon_p90") || StrEqual(classname"weapon_g3sg1") || StrEqual(classname"weapon_scar20"))
    { 
        
SDKHook(entitySDKHook_SpawnPostHook_OnEntitySpawn); 
    } 

public 
void Hook_OnEntitySpawn(int entity)
{     
     
AcceptEntityInput(entity"Kill");

Pretty sure the reason it crashes is because its in the middle of being equipped to a player if it's being killed before it's actually given to the player.
Mitchell is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 04-18-2019 , 12:01   Re: Crash AcceptEntityInput
Reply With Quote #8

Then he should use mp_items_prohibited convar.
__________________
Ilusion9 is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 04-25-2019 , 15:09   Re: Crash AcceptEntityInput
Reply With Quote #9

Error:

L 04/25/2019 - 00:05:18: [SM] Call stack trace:
L 04/25/2019 - 00:05:18: [SM] [0] AcceptEntityInput
L 04/25/2019 - 00:05:18: [SM] [1] Line 33, surf_delete_weapon.sp::KillEntity
L 04/25/2019 - 00:067: [SM] Exception reported: Entity -1 (-486866775) is not a CBaseEntity

Code:
void KillEntity( int entityReference )
{
    AcceptEntityInput( entityReference, "Kill" ); 
}
BeNq! is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 04-25-2019 , 15:22   Re: Crash AcceptEntityInput
Reply With Quote #10

Safer way

PHP Code:
#pragma semicolon 1

#include <sdkhooks> 
#include <sdktools> 

public OnEntityCreatedentity, const String:classname[] )

    if( 
StrEqualclassname"weapon_p90" ) || StrEqualclassname"weapon_g3sg1" ) || StrEqualclassname"weapon_scar20" ) )
    { 
        
SDKHookentitySDKHook_SpawnHook_OnEntitySpawn ); 
    } 

public 
Action:Hook_OnEntitySpawnentity )
{     
    if(
IsValidEntityentity ) )
    {
        
RequestFrame(view_as<RequestFrameCallback>(KillEntity), EntIndexToEntRef(entity));
    }
    return 
Plugin_Continue;
}

void KillEntity(int entityReference)
{
    if(
EntRefToEntIndex(entityReference) != INVALID_ENT_REFERENCE)
    {
        
AcceptEntityInput(entityReference"Kill" ); 
    }

__________________
impossible_cc 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 07:34.


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