AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detect DMG_FALL Death (https://forums.alliedmods.net/showthread.php?t=215342)

FromTheFuture 05-06-2013 14:54

Detect DMG_FALL Death
 
How to detect event, when player death with DMG_FALL?

YakumoHiratsuhi 05-06-2013 15:17

Re: Detect DMG_FALL Death
 
I'm pretty sure there's a better way out there, but here's mine.

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#define DMG_FALL        (1<<5)      // Fell too far (taken from hldsk_const)
#define PLUGIN    "Falling Death.."
#define AUTHOR    "Unknown"
#define VERSION    "1.0"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_TakeDamage"player""fw_Player_TakeDamage")
}

// Player took damage
public fw_Player_TakeDamage(victiminflictorattackerFloat:damagedmgtype)
{
    if(!(
dmgtype DMG_FALL))
        return 
HAM_IGNORED;
    
    new 
Float:health Float:get_user_health(victim)
    if(
health damage <= 0)
        
dmg_fall_killed_player(victimdamage)
    
    return 
HAM_HANDLED;
}

// Player got killed by DMG_FALL type.
public dmg_fall_killed_player(victimFloat:damage)
{
    
// Do what you want here..
    



Arkshine 05-06-2013 15:21

Re: Detect DMG_FALL Death
 
Another way If I remember well, is to hook Ham_Killed and checking bits with m_bitsDamageType offset (76).

Leon M. 05-06-2013 15:46

Re: Detect DMG_FALL Death
 
You wouldn't need to check this on POST since the damage can still be modified ???

YakumoHiratsuhi 05-06-2013 15:51

Re: Detect DMG_FALL Death
 
Quote:

Originally Posted by Leon M. (Post 1947115)
You wouldn't need to check this on POST since the damage can still be modified ???

The damage type can only be changed by 3rd party plugins, but i guess that isn't the case right now, but if you're right, he can just change the virtual function hook to post and that's all.

YamiKaitou 05-06-2013 15:58

Re: Detect DMG_FALL Death
 
Quote:

Originally Posted by Leon M. (Post 1947115)
You wouldn't need to check this on POST since the damage can still be modified ???

The damage can only be modified during a PRE hook. In a POST hook, you cannot modify it anymore. So a POST hook will give you the correct damage amount

Leon M. 05-06-2013 19:40

Re: Detect DMG_FALL Death
 
Yeah, i think he want to detect just a death caused by fall damage without modifying the damage itself. But it would be good if op gives a lil bit more detailed information about its purpose. :)

FromTheFuture 05-07-2013 08:36

Re: Detect DMG_FALL Death
 
Quote:

Originally Posted by Arkshine (Post 1947103)
Another way If I remember well, is to hook Ham_Killed and checking bits with m_bitsDamageType offset (76).

PHP Code:

public fw_HamKilled(victimattackershouldgib)
{
    if(
get_pdata_int(victim,76) == DMG_FALL)
    {
                     
//player is crash
    
}


That is right?

FromTheFuture 05-07-2013 09:12

Re: Detect DMG_FALL Death
 
How I can correctly set HIT_HEAD in PreKill?
I do this:
PHP Code:

set_pdata_int(victim75HIT_HEAD

And How correctly set killer weapon to HEGrenade?
In PreKill this not work:
PHP Code:

set_pdata_int(victim761<<24

I think I must change damage type in HamDamagePre?

Arkshine 05-07-2013 09:42

Re: Detect DMG_FALL Death
 
Quote:

Originally Posted by FromTheFuture (Post 1947408)
PHP Code:

public fw_HamKilled(victimattackershouldgib)
{
    if(
get_pdata_int(victim,76) == DMG_FALL)
    {
                     
//player is crash
    
}


That is right?


More & DMG_FALL.


All times are GMT -4. The time now is 10:56.

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