AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]How to detect damage/killed to entities (https://forums.alliedmods.net/showthread.php?t=110170)

powwoww 11-26-2009 02:17

[SOLVED]How to detect damage/killed to entities
 
public plugin_init(){
register_plugin("DMG TEST","0.1","Flea")
RegisterHam(Ham_Killed, "func_breakable", "FwdHamBreakableKilled", 1 )
}
public FwdHamBreakableKilled(ent, killer ){
client_print(0,print_chat,"Break...")
}

I broke the glass in cs_assault, but nothing happened...
Could anybody please tell me how to make it?

Firippu are right:) , also thank Arkshine

Firippu 11-26-2009 03:27

Re: How to detect damage/killed to entities?
 
I don't think Ham_Killed works for entities.

this does what you want
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <engine>

public plugin_init()
{
    
register_plugin("New Plugin","1.0","Unknown")
    
    
RegisterHam(Ham_TakeDamage,"func_breakable","FwdHamBreakableKilled",1)
}

public 
FwdHamBreakableKilled(ent)
{
    if(
entity_get_float(ent,EV_FL_health)<0)
    {
        
client_print(0,print_chat,"Break...")
    }



Arkshine 11-26-2009 03:55

Re: How to detect damage/killed to entities?
 
Weird Killed() is called from TakeDamage :

Code:
// do the damage     pev->health -= flDamage;     if (pev->health <= 0)     {         Killed( pevAttacker, GIB_NORMAL );         Die();         return 0;     }


All times are GMT -4. The time now is 13:42.

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