Raised This Month: $ Target: $400
 0% 

Detect DMG_FALL Death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 05-06-2013 , 14:54   Detect DMG_FALL Death
Reply With Quote #1

How to detect event, when player death with DMG_FALL?
FromTheFuture is offline
YakumoHiratsuhi
Veteran Member
Join Date: Dec 2010
Location: Dreαmlαnd.
Old 05-06-2013 , 15:17   Re: Detect DMG_FALL Death
Reply With Quote #2

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

__________________
"Podra parecer ridiculo o imposible, pero este es el camino que seguimos los verdaderos hombres, si hay un muro en el camino, lo derribamos, si no hay camino, haremos uno, con nuestras propias manos, porque el magma de nuestro corazón arde en llamas."

Last edited by YakumoHiratsuhi; 05-06-2013 at 15:22.
YakumoHiratsuhi is offline
Send a message via MSN to YakumoHiratsuhi
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-06-2013 , 15:21   Re: Detect DMG_FALL Death
Reply With Quote #3

Another way If I remember well, is to hook Ham_Killed and checking bits with m_bitsDamageType offset (76).
__________________
Arkshine is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 05-07-2013 , 08:36   Re: Detect DMG_FALL Death
Reply With Quote #4

Quote:
Originally Posted by Arkshine View Post
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 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-07-2013 , 09:42   Re: Detect DMG_FALL Death
Reply With Quote #5

Quote:
Originally Posted by FromTheFuture View Post
PHP Code:
public fw_HamKilled(victimattackershouldgib)
{
    if(
get_pdata_int(victim,76) == DMG_FALL)
    {
                     
//player is crash
    
}

That is right?

More & DMG_FALL.
__________________
Arkshine is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-06-2013 , 15:46   Re: Detect DMG_FALL Death
Reply With Quote #6

You wouldn't need to check this on POST since the damage can still be modified ???
__________________
  • ZapTic - Paintball (Version 7.1.3 b1303)
  • Your #1 CS Paintball Server since 2008
  • 85.131.163.101:27015
Leon M. is offline
YakumoHiratsuhi
Veteran Member
Join Date: Dec 2010
Location: Dreαmlαnd.
Old 05-06-2013 , 15:51   Re: Detect DMG_FALL Death
Reply With Quote #7

Quote:
Originally Posted by Leon M. View Post
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.
__________________
"Podra parecer ridiculo o imposible, pero este es el camino que seguimos los verdaderos hombres, si hay un muro en el camino, lo derribamos, si no hay camino, haremos uno, con nuestras propias manos, porque el magma de nuestro corazón arde en llamas."

Last edited by YakumoHiratsuhi; 05-06-2013 at 15:53.
YakumoHiratsuhi is offline
Send a message via MSN to YakumoHiratsuhi
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-06-2013 , 15:58   Re: Detect DMG_FALL Death
Reply With Quote #8

Quote:
Originally Posted by Leon M. View Post
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
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-06-2013 , 19:40   Re: Detect DMG_FALL Death
Reply With Quote #9

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.
__________________
  • ZapTic - Paintball (Version 7.1.3 b1303)
  • Your #1 CS Paintball Server since 2008
  • 85.131.163.101:27015
Leon M. is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 05-07-2013 , 09:12   Re: Detect DMG_FALL Death
Reply With Quote #10

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?

Last edited by FromTheFuture; 05-07-2013 at 09:13.
FromTheFuture 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 10:56.


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