Raised This Month: $51 Target: $400
 12% 

Solved [HELP] Detect or block player healing events after drowning in water?


Post New Thread Reply   
 
Thread Tools Display Modes
felhasznalo
AlliedModders Donor
Join Date: Aug 2015
Location: Hungary
Old 08-12-2015 , 11:12   Re: [HELP] Detect or block player healing events after drowning in water?
Reply With Quote #11

Thanks, I ended up using the exact code Bugsy posted above with set_pdata_int() and return HAM_SUPERCEDE, and it works great!

Last edited by felhasznalo; 08-12-2015 at 11:21.
felhasznalo is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-12-2015 , 11:18   Re: [HELP] Detect or block player healing events after drowning in water?
Reply With Quote #12

Use the exact code I posted above with set_pdata_int() and return HAM_SUPERCEDE.
__________________
Bugsy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-12-2015 , 13:15   Re: [HELP] Detect or block player healing events after drowning in water?
Reply With Quote #13

I agree that using a bigger value is better, because we avoid some forward calls, but in this case it is unknown. Given that and also considering that this is not a heavy consumption forward and that the plugin should work in most of situations I would go with my first way(TakeHeal will be called one time after every drown dmg, but this is not too much and plugin will work correctly).
__________________

Last edited by HamletEagle; 08-12-2015 at 13:16.
HamletEagle is online now
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-12-2015 , 13:18   Re: [HELP] Detect or block player healing events after drowning in water?
Reply With Quote #14

Try your method out yourself, when you first get out of water you heal once before it is stopped. You may need to add +1 or something to fix that..or just use 500 :-B
__________________
Bugsy is offline
Old 08-12-2015, 13:27
HamletEagle
This message has been deleted by HamletEagle.
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-12-2015 , 13:37   Re: [HELP] Detect or block player healing events after drowning in water?
Reply With Quote #15

It happens if you don't supercede TakeHeal. But using my way + superceding will do the trick. In my tests it was working because I was using a cmd to test. TakeHeal is a bit late(because a heal already started, this is why player is healed one time).

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

const m_idrowndmg 345
const m_idrownrestored 346

public plugin_init() 
{
    
RegisterHam(Ham_TakeHealth "player" "TakeHealth")
}
 
public 
TakeHealth(idFloat:HealthHealed DamageBits)
{
    
set_pdata_int(idm_idrownrestoredget_pdata_int(idm_idrowndmg))
    return 
HAM_SUPERCEDE

__________________

Last edited by HamletEagle; 08-12-2015 at 13:50.
HamletEagle is online now
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-12-2015 , 15:56   Re: [HELP] Detect or block player healing events after drowning in water?
Reply With Quote #16

So either way works, but you could save a native call by using a high value (like 5000) instead of setting damage restored to the dmgtaken value. While it is technically more proper to set dmgrestored to the damagetaken, it isn't required/necessary in this case.
__________________

Last edited by Bugsy; 08-12-2015 at 18:28.
Bugsy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-13-2015 , 05:03   Re: [HELP] Detect or block player healing events after drowning in water?
Reply With Quote #17

Your first post said something else(probably due to my poor english, sorry for that) I was going to answer it, with both methods heal once will happen, if we don't supercede the forward. This is because TakeHeal is already called(the condition m_idrowndmg > m_idrownrestored was one time true) when altering dmgrestored, which will trick the game only for next heals. Mine or your way function in the same way, except the value that is set.

IMO, it is required, because using hard coded values like 100/500/5000 can be broken by a simple and common thing as a health change(there are a lot of shops, vip plugins, custom mods - like I said above most of zm have +10.000 hp). A plugin should be a perfect balance between code and usability. What's the point in saving a native call if there are 90% chances of plugin not working correctly ? Micro-optimizations does not worth, especially in this case.
__________________

Last edited by HamletEagle; 08-13-2015 at 05:06.
HamletEagle is online now
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-13-2015 , 09:06   Re: [HELP] Detect or block player healing events after drowning in water?
Reply With Quote #18

Fair enough
__________________
Bugsy 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 05:16.


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