Raised This Month: $ Target: $400
 0% 

Hooking the Drown Event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fang
Senior Member
Join Date: Nov 2007
Location: New Jersey
Old 04-26-2008 , 22:33   Hooking the Drown Event
Reply With Quote #1

Is there a way to hook and then stop the drown event? I tried setting the damage to 0 but I'd prefer to just stop the event from starting. Possible?
fang is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-27-2008 , 00:11   Re: Hooking the Drown Event
Reply With Quote #2

Try this:
PHP Code:
#include <amxmodx>
#include <fakemeta>

#define DMG_DROWN (1<<14)

public plugin_init()
{
    
register_forward(FM_PlayerPreThink"FM_PreThink");
}

public 
FM_PreThink(id)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED;

    new 
dmg pev(idpev_dmg);

    if(
dmg DMG_DROWN)
        return 
FMRES_SUPERCEDE;

    return 
FMRES_IGNORED;

__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-27-2008 , 01:04   Re: Hooking the Drown Event
Reply With Quote #3

why not just take it out?

Code:
if(dmg & DMG_DROWN)     set_pev(id, pev_dmg, (dmg & ~DMG_DROWN));
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
hoboman
Senior Member
Join Date: Jul 2007
Old 04-27-2008 , 01:18   Re: Hooking the Drown Event
Reply With Quote #4

how about this:
Code:
#include <amxmodx>
#include <hamsandwich>

#define PLUGIN	"No Drowning"
#define AUTHOR	"hoboman313"
#define VERSION	"1.0"

#define DMG_DROWN 1<<14

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	RegisterHam( Ham_TakeDamage, "player", "damage" )
}

public damage(this, idinflictor, idattacker, Float:damage, damagebits)
{
	if(damagebits & DMG_DROWN)
		return HAM_SUPERCEDE
	
	return HAM_IGNORED
}
should be MUCH more efficient
__________________
hoboman is offline
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 04-27-2008 , 01:23   Re: Hooking the Drown Event
Reply With Quote #5

To prevent drowning without setting the damage to 0 or blocking it:
PHP Code:
set_pev(idpev_air_finished99999.9
Cheap_Suit is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-27-2008 , 02:53   Re: Hooking the Drown Event
Reply With Quote #6

Quote:
Originally Posted by X-olent View Post
why not just take it out?

Code:
if(dmg & DMG_DROWN) set_pev(id, pev_dmg, (dmg & ~DMG_DROWN));
That's what I was looking for.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
fang
Senior Member
Join Date: Nov 2007
Location: New Jersey
Old 04-27-2008 , 14:40   Re: Hooking the Drown Event
Reply With Quote #7

Thanks. Didn't think there'd be that many posts
fang 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 19:01.


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