AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hooking the self damage event? (https://forums.alliedmods.net/showthread.php?t=11370)

VarmVaffel 03-17-2005 13:47

Hooking the self damage event?
 
Is it possible to hook the player self damage event, like when the player jumps down a cliff or similar?

- VV

Twilight Suzuka 03-17-2005 15:50

That is not an event.

xeroblood 03-17-2005 17:53

It is the Damage Event, and the attacker is the world (index 0)...

Something like this:
Code:
#include <amxmodx> public plugin_init() {     register_event( "Damage", "Event_Damage", "b", "2=0" ) } public Event_Damage( id ) {     new szUsername[32]     get_user_name( id, szUsername, 31 )     client_print( 0, print_chat, "%s hurt self!", szUsername )     return PLUGIN_CONTINUE }

VarmVaffel 03-18-2005 05:06

Thank you, just what I wanted! :D

- VV

Reignman 06-30-2005 12:21

How do you get that to display how much damage was done to self like ...

Quote:

Reignman hurt self! 42

xeroblood 06-30-2005 17:32

Code:
#include <amxmodx> public plugin_init() {     register_event( "Damage", "Event_Damage", "b", "2=0" ) } public Event_Damage( id ) {     new iDamage = read_data( 2 )     new szUsername[32]     get_user_name( id, szUsername, 31 )     client_print( 0, print_chat, "%s hurt self for %d HP!", szUsername, iDamage )     return PLUGIN_CONTINUE }

Reignman 06-30-2005 19:11

It always displays 0 HP! for every fall. Is the script missing something?

xeroblood 06-30-2005 20:40

:shock: Oooops.. ya, it should only be printing 0.. that would make sense!!

I messed up, did it too fast.. try this tho, it may be what you're looking for: (but again, I didnt test this)

Code:
#include <amxmodx> public plugin_init() {     register_event( "Damage", "Event_Damage", "b", "2!0" ) } public Event_Damage( id ) {     new iDamage = read_data( 2 )     new iAttackerID = get_user_attacker( id )     if( (iAttackerID == 0) || (iAttackerID == id) )     {         new szUsername[32]         get_user_name( id, szUsername, 31 )         client_print( 0, print_chat, "%s hurt self for %d HP!", szUsername, iDamage )     }     return PLUGIN_CONTINUE }

NOTE: Notice the change in the register_event()

Reignman 07-06-2005 19:38

Thanks, worked great. Can I get just one more thing added? If the person dies (suicide) can I get it to display ...

Quote:

Player hurt self 37 HP (died)

Anthraxnz 07-06-2005 20:21

this might work if you add it to the damage function

Code:
if (iDamage == 0 )     client_print( 0, print_chat, "%s Has Died", szUsername )

just taking a stab in the dark at this prolly doesnt work


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

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