Raised This Month: $ Target: $400
 0% 

[Solved] Random EngFunc_RemoveEntity Crash - NS


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tekproxy
New Member
Join Date: Dec 2007
Old 12-11-2007 , 00:00   [Solved] Random EngFunc_RemoveEntity Crash - NS
Reply With Quote #1

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.

Last edited by tekproxy; 12-19-2007 at 18:15.
tekproxy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-11-2007 , 04:52   Re: Random EngFunc_RemoveEntity Crash - NS
Reply With Quote #2

Try to post register :

register_forward(FM_SetModel, "fw_setmodel", 1)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 12-11-2007 , 08:34   Re: Random EngFunc_RemoveEntity Crash - NS
Reply With Quote #3

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.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 12-11-2007 , 10:11   Re: Random EngFunc_RemoveEntity Crash - NS
Reply With Quote #4

I suggest you do both, as well as a pev_valid() check.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
toazron1
Senior Member
Join Date: Oct 2006
Old 12-11-2007 , 16:06   Re: Random EngFunc_RemoveEntity Crash - NS
Reply With Quote #5

I made a little plugin that turned the handnades into flash bangs, and I found it easier to hook FM_Think
__________________
toazron1 is offline
Send a message via AIM to toazron1
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 12-12-2007 , 09:33   Re: Random EngFunc_RemoveEntity Crash - NS
Reply With Quote #6

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.
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
tekproxy
New Member
Join Date: Dec 2007
Old 12-18-2007 , 23:53   Re: Random EngFunc_RemoveEntity Crash - NS
Reply With Quote #7

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;
}
tekproxy is offline
Sn!ff3r
Veteran Member
Join Date: Aug 2007
Location: Poland
Old 03-08-2009 , 13:05   Re: [Solved] Random EngFunc_RemoveEntity Crash - NS
Reply With Quote #8

Bump old thread.

I already tried with killme flags.
__________________
Join US - custom Zombie Server - Custom Addons:




Last edited by Sn!ff3r; 03-08-2009 at 13:08.
Sn!ff3r is offline
Send a message via Skype™ to Sn!ff3r
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 10:59.


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