AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Is it possible to hook the grenade explode event? (https://forums.alliedmods.net/showthread.php?t=125380)

r4ndomz 04-27-2010 17:08

Is it possible to hook the grenade explode event?
 
I had an idea that requires it. :twisted:

Silencer123 04-27-2010 17:12

Re: Is it possible to hook the grenade explode event?
 
Include:
#include <hamsandwich>

In plugin_init():
RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")

Somewhere else:
public fw_ThinkGrenade(entity) {
// [...]
}

Taken from: http://forums.alliedmods.net/showthread.php?t=74905
Found in 10 Seconds with the Forums' search function. D;
Note that the above is not the whole secret. Conduct your own research on the plugin linked to above. ;)

r4ndomz 04-27-2010 17:28

Re: Is it possible to hook the grenade explode event?
 
And that is the explosion? Like, if i client_print(hihi) will it print exactly at the explosion?

I did search, and i swear, i found nothing useful. I searched keywords "hooking grenade explosion" because i knew there was a dumb limit to the search thing.

wrecked_ 04-27-2010 17:33

Re: Is it possible to hook the grenade explode event?
 
Test it.

Bugsy 04-27-2010 17:44

Re: Is it possible to hook the grenade explode event?
 
You may want to verify/test if that also hooks C4 explosion. IIRC, they have the same classname. I could be wrong but it cant hurt to test.

r4ndomz 04-27-2010 17:59

Re: Is it possible to hook the grenade explode event?
 
1 Attachment(s)
Is it the code or is my hlds hating me for using it again?

Exolent[jNr] 04-27-2010 18:58

Re: Is it possible to hook the grenade explode event?
 
1. You can't use get_user_origin() with a non-player entity.
2. Cache get_maxplayers() in a global variable and retrieve the value on plugin_init().
3. Player indexes are from 1->maxplayers, not 0->(maxplayers - 1).
4. No need to check is_user_connected() since is_user_alive() checks if player is connected.
5. Don't create variables inside loops.
6. Cache the radius at the top of the function so you don't retrieve it for every player.

r4ndomz 04-27-2010 19:11

Re: Is it possible to hook the grenade explode event?
 
Quote:

Originally Posted by Exolent[jNr] (Post 1162737)
1. You can't use get_user_origin() with a non-player entity.

Then how do i get the origin? Im multitasking and i dont have that much time left.

wrecked_ 04-27-2010 19:16

Re: Is it possible to hook the grenade explode event?
 
Code:
new Float:origin[3] pev( ent, pev_origin, origin )

Bugsy 04-27-2010 19:17

Re: Is it possible to hook the grenade explode event?
 
That method uses a Float, wrecked.

Float: origin[ 3 ]


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

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