AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] Random EngFunc_RemoveEntity Crash - NS (https://forums.alliedmods.net/showthread.php?t=64222)

tekproxy 12-11-2007 00:00

[Solved] Random EngFunc_RemoveEntity Crash - NS
 
When a grenade is thrown, I want to remove the grenade entity and replace it with my own. I have everything working almost perfectly except if I include the code to remove the original grenade entity the server crashes.

I've been messing with this for 12 hours, anyone have any ideas (Natural Selection mod, btw):

Code:

#include <amxmodx>
#include <fakemeta>

public plugin_init()
{
    register_plugin("Crash Test", "1.0", "frustrated");
   
    register_forward(FM_SetModel, "fw_setmodel");
}

public fw_setmodel(ent, model[])
{
    if ( !pev_valid(ent) ) {
        return FMRES_IGNORED;
    }
   
    static classname[32];
    pev(ent, pev_classname, classname, 31);
   
    if ( equali(classname, "handgrenade") ) {
        // removes entity, then crashes
        engfunc(EngFunc_RemoveEntity, ent);
    }
   
    return FMRES_IGNORED;
}

It takes 1-10 nades being thrown and then crash. Server restarts. There are no amxx plugin error logs created and I'm running in debug mode.

The only debug info the hl server gives me is totally worthless, as can be expected.

Is there a better place to do this other than FM_SetModel? I saw some code do this for CS in set_model but it was for engine, not fakemeta and it worked... HMMMMMMMMm.

ConnorMcLeod 12-11-2007 04:52

Re: Random EngFunc_RemoveEntity Crash - NS
 
Try to post register :

register_forward(FM_SetModel, "fw_setmodel", 1)

Alka 12-11-2007 08:34

Re: Random EngFunc_RemoveEntity Crash - NS
 
Try to put after
Code:

engfunc(EngFunc_RemoveEntity, ent);
"return FMRES_SUPERCEDE". This should be the reason. If this is not working try connorr suggestion.

Zenith77 12-11-2007 10:11

Re: Random EngFunc_RemoveEntity Crash - NS
 
I suggest you do both, as well as a pev_valid() check.

toazron1 12-11-2007 16:06

Re: Random EngFunc_RemoveEntity Crash - NS
 
I made a little plugin that turned the handnades into flash bangs, and I found it easier to hook FM_Think

Wilson [29th ID] 12-12-2007 09:33

Re: Random EngFunc_RemoveEntity Crash - NS
 
Worst comes to worst, you can also just use the grenade entity and have your way with it.

Change the timer so it doesn't blow up...change the model, etc.

tekproxy 12-18-2007 23:53

Re: Random EngFunc_RemoveEntity Crash - NS
 
I could have sworn that I tried the suggestions made, but this code works. I ran around throwing nades and they were removed without server crash. Thanks, all.

Code:

#include <amxmodx>
#include <fakemeta>

public plugin_init()
{
        register_plugin("Crash Test", "1.1", "not_so_frustrated");
       
        register_forward(FM_SetModel, "fw_setmodel", 1);
}

public fw_setmodel(ent, model[])
{
        if ( !pev_valid(ent) ) {
                return FMRES_IGNORED;
        }
       
        static classname[32];
        pev(ent, pev_classname, classname, 31);
       
        if ( equali(classname, "handgrenade") ) {
                // removes entity, then doesn't crash ;)
                engfunc(EngFunc_RemoveEntity, ent);

                // now i can do what i want here...

                return FMRES_SUPERCEDE;
        }
       
        return FMRES_IGNORED;
}


Sn!ff3r 03-08-2009 13:05

Re: [Solved] Random EngFunc_RemoveEntity Crash - NS
 
Bump old thread.

I already tried with killme flags.


All times are GMT -4. The time now is 10:59.

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