Raised This Month: $ Target: $400
 0% 

delay grenade explosion


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
icetea
BANNED
Join Date: Sep 2008
Old 10-06-2008 , 23:56   delay grenade explosion
Reply With Quote #1

I need to delay the grenade explosion to explode 3 seconds after interaction with an object
ex: i throw a nade, it hits the wall and then 3 seconds later it explodes; i throw a nade it hits a person and then 3 seconds later it explodes.

thanks for your help :c omply:


i like the smileys on this forum ;-)
icetea is offline
Sn!ff3r
Veteran Member
Join Date: Aug 2007
Location: Poland
Old 10-07-2008 , 01:49   Re: delay grenade explosion
Reply With Quote #2

Change pev_nextthink and check pev_flags (ex. FL_ONGROUND).
Sn!ff3r is offline
Send a message via Skype™ to Sn!ff3r
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 10-07-2008 , 11:54   Re: delay grenade explosion
Reply With Quote #3

Forward the grenades touch then use:
set_pev(iEnt, pev_dmgtime, get_gametime() + 3.0);
hlstriker is offline
icetea
BANNED
Join Date: Sep 2008
Old 10-07-2008 , 20:19   Re: delay grenade explosion
Reply With Quote #4

how do i use FM_Touch?
im a newby :/
icetea is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-07-2008 , 21:27   Re: delay grenade explosion
Reply With Quote #5

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

public plugin_init()
{
    
register_forward(FM_Touch"FwdTouch");
}

public 
FwdTouch(ptrptd)
{
    new 
ent 0hit = -1;
    if( 
pev_valid(ptr) )
    {
        new 
classname[32];
        
pev(ptrpev_classnamesizeof(classname) - 1);
        if( 
equal(classname"grenade") )
        {
            
ent ptr;
            
hit ptd;
        }
    }
    else if( 
pev_valid(ptd) )
    {
        new 
classname[32];
        
pev(ptdpev_classnamesizeof(classname) - 1);
        if( 
equal(classname"grenade") )
        {
            
ent ptd;
            
hit ptr;
        }
    }
    
    if( !
pev_valid(ent) || hit == -) return;
    
    if( 
pev(entpev_iuser1) ) return;
    
    
set_pev(entpev_iuser11);
    
set_pev(entpev_dmgtimeget_gametime() + 3.0);

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 10-13-2008 at 12:22.
Exolent[jNr] is offline
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 10-08-2008 , 09:46   Re: delay grenade explosion
Reply With Quote #6

Snippet from ChickenMod:

Code:
public plugin_init() {     register_forward( FM_SetModel, "SetModel" ) } public SetModel( entity, const model[] ) {     if ( !pev_valid( entity ) )         return FMRES_IGNORED     // Get owner of the grenade     static id; id = pev( entity, pev_owner )     if ( !is_user_connected( id ) )         return FMRES_IGNORED     if ( equali( model, "models/w_hegrenade.mdl" ) )     {         static Float:origin[ 3 ]         pev( id, pev_origin, origin ) // Get owners origin         engfunc( EngFunc_SetModel, entity, CHICKEN_MDL_GRENADE ) // Change grenade model         set_pev( entity, pev_velocity, Float:{ 0.0, 0.0, 0.0 } ) // Alter grenade velocity         engfunc( EngFunc_SetOrigin, entity, origin ) // Alter grenade origin             set_task( 0.1, "Set_Grenade_Damage", entity )         return FMRES_SUPERCEDE // Required if changing model else remove this line     }     return FMRES_IGNORED } public Set_Grenade_Damage( grenade ) {     set_pev( grenade, pev_dmgtime, get_gametime() + 10.0 ) // This can be in the caller function     set_pev( grenade, pev_dmg, 300.0 ) // This requires a 0.1s delay if modifying grenade damage. }
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd
Orangutanz is offline
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 10-09-2008 , 00:44   Re: delay grenade explosion
Reply With Quote #7

So which method is correct, pev_nextthink or pev_dmgtime? Or will either one work?
__________________
=====================================
- My Plugins -
=====================================
Vet is offline
Send a message via MSN to Vet
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 10-09-2008 , 05:12   Re: delay grenade explosion
Reply With Quote #8

It should be dmgtime.

nextthink sets grenade think cycle then what it does is check whether its more than dmgtime, if it is it causes the grenade to explode.
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd
Orangutanz is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-09-2008 , 11:30   Re: delay grenade explosion
Reply With Quote #9

Orangutanz is right. I don't know why I put pev_nextthink.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
icetea
BANNED
Join Date: Sep 2008
Old 10-12-2008 , 22:47   Re: delay grenade explosion
Reply With Quote #10

Quote:
Originally Posted by Exolent[jNr] View Post
Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> public plugin_init() { register_forward(FM_Touch, "FwdTouch"); } public FwdTouch(ptr, ptd) { if( !pev_valid(ptr) || !pev_valid(ptd) ) return; new ent = 0; static classname[32]; pev(ptr, pev_classname, classname, sizeof(classname) - 1); if( equal(classname, "grenade") ) { ent = ptr; } else { pev(ptd, pev_classname, classname, sizeof(classname) - 1); if( equal(classname, "grenade") ) ent = ptd; } if( !ent ) return; if( pev(ent, pev_iuser1) ) return; set_pev(ent, pev_iuser1, 1); set_pev(ent, pev_dmgtime, get_gametime() + 3.0); }
doesnt seem to be working correctly

the timing seemed kinda funny, so i tryed changing the explode time to 0.1 and it explodes in my face, i need it to count down the amount of seconds after contact with a wall and then explode
icetea 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 13:24.


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