AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Removing Grenade Entity Before Explosion (https://forums.alliedmods.net/showthread.php?t=337357)

hellmonja 04-15-2022 14:16

Removing Grenade Entity Before Explosion
 
Is there any known bug with removing a grenade entity multiple times before it explodes, like making the game crash or something?

I'm working on this plugin where you can throw a camera like a grenade for recon. I take a smokegrenade and right before it detonates I remove it and place an entity there that acts as the camera and I see what it sees.

About several minutes into the game it sometimes crashes for no apparent reason. I was either shooting a bot or just walking around minutes away from the last cam I threw. I'm not sure which part is the problem since it doesn't create a log, only a minidump that I can't read. And my best bet is the removal of grenade entities. Anyone have relevant information would be much appreciated...

Craxor 04-15-2022 14:19

Re: Removing Grenade Entity Before Explosion
 
1. Don't you have log errors?
2. Search in my thread "help with okapi" ive maded something similar .

hellmonja 04-15-2022 14:27

Re: Removing Grenade Entity Before Explosion
 
Quote:

Originally Posted by Craxor (Post 2776908)
1. Don't you have log errors?

As I've said it only creates a minidump. No error logs...

I see how the thread can be related. But I only asked if anyone had an idea if removing grenades would cause the game to crash. The thing is 90% complete and I'm not too keen in converting the whole of it to Okapi. But you gave me an idea. I found the approved Teleport Nade plugin here and will try to emulate that instead, thank you...

Natsheh 04-15-2022 14:54

Re: Removing Grenade Entity Before Explosion
 
Show the code.

hellmonja 04-15-2022 15:33

Re: Removing Grenade Entity Before Explosion
 
Quote:

Originally Posted by Natsheh (Post 2776917)
Show the code.

Sorry. Not that I don't want to share, but the thing in embedded into a larger plugin. And I know you would like to have the whole thing but I doubt anyone would take the time to sift thru it.

I know, it seems dumb, asking for help without posting code. But I only asked if anyone had any idea if this would make the game crash. Nevertheless, Craxor gave me an idea for a possible solution so I think we're all good.

PS: If you're wondering about my code, the gist is it's hooked on FM_SetModel. Inside there's a timed task that removes the grenade entity with remove_entity(). And the timer is set a few milliseconds before detonation. I've also made liberal use of pev_valid...

Natsheh 04-15-2022 19:22

Re: Removing Grenade Entity Before Explosion
 
Alright, a solution don't use remove_entity, use instead the other method which is by setting an entity flags to FL_KILLME then call entity think, its more reliable safer way !

hellmonja 04-16-2022 08:24

Re: Removing Grenade Entity Before Explosion
 
Quote:

Originally Posted by Natsheh (Post 2776937)
Alright, a solution don't use remove_entity, use instead the other method which is by setting an entity flags to FL_KILLME then call entity think, its more reliable safer way !

That's definitely good to know, thanks. I'm familiar with FL_KILLME but it never worked for me. Probably because I'm unfamiliar with calling entity think and didn't know you had to do that.

I made this stock. Did I do it properly?...
PHP Code:

stock kill_entity(ent)
{
    
set_pev(entpev_flagspev(entpev_flags) | FL_KILLME);
    
set_pev(entpev_nextthinkget_gametime() + 0.01);
    
dllfunc(DLLFunc_Thinkent);



Natsheh 04-16-2022 13:04

Re: Removing Grenade Entity Before Explosion
 
Yes, but you don't need to set up next think

So basically remove this...

Code:

set_pev(ent, pev_nextthink, get_gametime() + 0.01);

hellmonja 04-17-2022 02:23

Re: Removing Grenade Entity Before Explosion
 
Quote:

Originally Posted by Natsheh (Post 2776994)
So basically remove this...

Code:

set_pev(ent, pev_nextthink, get_gametime() + 0.01);

Roger that. It's working now but I haven't had time to do an extensive so I don't know yet if it fixed the crashing. If it still does it's probably other stuff that's causing it. But it's good to know, I'll be using FL_KILLME instead remove_entity from now on, thank you very much!...


All times are GMT -4. The time now is 12:05.

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