Raised This Month: $ Target: $400
 0% 

Grenade Think


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nomexous
Member
Join Date: Oct 2007
Old 10-22-2007 , 14:54   Grenade Think
Reply With Quote #1

I've recently begun coding for AMXX just to see what things I can do. I'm working right now on a plugin which prevents grenades from being used on maps like fy_iceworld. Here is the code so far (thanks to FrostNades):

Code:
#include <amxmodx> #include <fakemeta> #include <engine> #define PLUGIN "Nade Disabler" #define VERSION "0.1" #define AUTHOR "Nomexous" new nade_pcvar public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         nade_pcvar = register_cvar("amx_disable_grenades", "0")         register_think("grenade", "grenade_think") } public grenade_think(ent) {     if (get_pcvar_num(nade_pcvar)) return PLUGIN_HANDLED }
This works very well. It's exactly what I want. You can buy grenades and throw them, but they will simply bounce to a halt and not explode.

However, I'm not entirely clear on how this stops the grenades from exploding. And I would like to know a way to make the thrown grenades (now lying forlornly on the ground) to explode on command, taking into account that they can be either flashes, smokes, or HEs.

Last edited by Nomexous; 10-22-2007 at 22:36.
Nomexous is offline
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 10-23-2007 , 23:11   Re: Grenade Think
Reply With Quote #2

im guessing that amxx thinks of the grenade first then blocks it from the hl engine so it doesnt explode, i think you can make a command to switch HANDLED to CONTINUE for 1 second and that might make all nades explode
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 10-23-2007 , 23:17   Re: Grenade Think
Reply With Quote #3

Yes, exactly what kp_uparrow said. In other words, (to rephrase him) when you return PLUGIN_HANDLED, the event you hooked gets blocked from further actions by AMXX. That's why your grenade doesn't explode, because the event never got to the "explode" part.

Throw grenade ===> return PLUGIN_HANDLED =X(block)X=> Explode
else
Throw grenade ===> return PLUGIN_CONTINUE ===> Explode
__________________
M249-M4A1 is offline
Reply



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 01:15.


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