AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   detect bomb damage in Ham_TakeDamage (https://forums.alliedmods.net/showthread.php?t=82632)

whosyourdaddy 12-26-2008 22:23

detect bomb damage in Ham_TakeDamage
 
im using Ham_TakeDamage to detect damage but for some reason bomb explosion wont damage T's i was wondering how i can make it detect if the damage is from the bomb and if so then skip the below functions and damage the player regulary

whosyourdaddy 01-28-2009 14:28

Re: detect bomb damage in Ham_TakeDamage
 
bump

SnoW 01-28-2009 14:44

Re: detect bomb damage in Ham_TakeDamage
 
Making new code to fix an other code isn't really effective. I would prefer posting your plugin here and then we could find out what's causing the problem and fix it. Ofc if you have some reason why you don't want to do it, but can't see any.

whosyourdaddy 01-28-2009 15:20

Re: detect bomb damage in Ham_TakeDamage
 
i think i found the fix for my issue. i had
Code:

if ( get_user_team( iAttacker ) == get_user_team( iVictim ) && !get_pcvar_num( CVAR_mp_friendlyfire ))
    return HAM_SUPERCEDE;

instead of
Code:

if ( get_user_team( iAttacker ) == get_user_team( iVictim ) && !get_pcvar_num( CVAR_mp_friendlyfire ))
    return HAM_IGNORED;



SnoW 01-29-2009 09:00

Re: detect bomb damage in Ham_TakeDamage
 
Quote:

Originally Posted by whosyourdaddy (Post 751793)
i think i found the fix for my issue. i had
Code:

if ( get_user_team( iAttacker ) == get_user_team( iVictim ) && !get_pcvar_num( CVAR_mp_friendlyfire ))
    return HAM_SUPERCEDE;

instead of
Code:

if ( get_user_team( iAttacker ) == get_user_team( iVictim ) && !get_pcvar_num( CVAR_mp_friendlyfire ))
    return HAM_IGNORED;


And still it should be:
Code:

if ( get_user_team( iAttacker ) == get_user_team( iVictim ) || !get_pcvar_num( CVAR_mp_friendlyfire ))
    return HAM_IGNORED;


Exolent[jNr] 01-29-2009 18:00

Re: detect bomb damage in Ham_TakeDamage
 
Quote:

Originally Posted by SnoW (Post 752176)
And still it should be:
Code:

if ( get_user_team( iAttacker ) == get_user_team( iVictim ) || !get_pcvar_num( CVAR_mp_friendlyfire ))
    return HAM_IGNORED;


Wrong.
His code will work as:

If players are not on same team, continue.
If players are on the same team and mp_friendlyfire is enabled, continue.
If players are on the same team and mp_friendlyfire is disabled, stop.

Your code will work as:

If players are not on the same team, stop.
If players are on the same team and mp_friendlyfire is enabled, stop.
If players are on the same team and mp_friendlyfire is disabled, continue.

It's simple logic.

SnoW 01-30-2009 09:58

Re: detect bomb damage in Ham_TakeDamage
 
Quote:

Originally Posted by Exolent[jNr] (Post 752436)
Wrong...
...It's simple logic.

Ofc it's the simplest logic ever, still I were just assuming that it was on/off cvar. Anyway now when I know better that it was mp_friendlyfire, can't still be sure how the plugin should act anyway. Maybe I should still stop commenting codes what I haven't seen.

Owyn 03-12-2009 16:16

Re: detect bomb damage in Ham_TakeDamage
 
how do you detect that damage is by C4 explosion in Ham_TakeDamage ?

im tring to block bomb damage and killing but no luck atm )= looking forward for a little help

portocala 09-03-2010 13:13

Re: detect bomb damage in Ham_TakeDamage
 
Personally I found a method:

PHP Code:

new is_bomb 0;

public 
plugin_init ()
{
    
register_plugin (PLUGINVERSIONAUTHOR);
    
register_event("23""event_bomb""a""1=17""6=-105""7=17")
    
RegisterHam (Ham_TakeDamage"player""fwEventTakeDmg");
}

public 
event_bomb()
{
    
is_bomb 1;
    
set_task(0.1"not_bomb");
}

public 
not_bomb()
{
    
is_bomb 0;
}

public 
fwEventTakeDmg (i_Victimi_Inflictori_AttackerFloat:Damagei_DamageBits)
{
    if(
is_bomb)
    {
        
//
    
}


I calculated the time interval between bomb explode and ham_takedamage (in float) and these too are happening in (almost) the same time. So, the 0.1 time for set_task is just perfect.

It's just an opinion... What do you think ?

Bugsy 09-03-2010 13:53

Re: detect bomb damage in Ham_TakeDamage
 
http://forums.alliedmods.net/showthread.php?t=87614


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

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