AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Grenade Think (https://forums.alliedmods.net/showthread.php?t=62276)

Nomexous 10-22-2007 14:54

Grenade Think
 
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.

kp_uparrow 10-23-2007 23:11

Re: Grenade Think
 
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

M249-M4A1 10-23-2007 23:17

Re: Grenade Think
 
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


All times are GMT -4. The time now is 01:15.

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