AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved pev(ent, pev_health) return 0.0 (https://forums.alliedmods.net/showthread.php?t=309211)

Celena Luna 07-17-2018 13:33

pev(ent, pev_health) return 0.0
 
PHP Code:

RegisterHam(Ham_TakeDamage"func_breakable""fw_Object_TakeDamage")

public 
fw_Object_TakeDamage(entweaponkillerdmg)
{
    new 
health pev(ent,pev_health); 
    if (
health dmg <= 0.0)
    {
        
client_print(killerprint_chat"Ent: %i"ent)
        
client_print(killerprint_chat"Ent HP: %.f"health)
        return 
HAM_IGNORED;
    }
    return 
HAM_IGNORED;


I tried to hook the "func_breakable" entity when it destroyed but the health return always 0.0.
did I missed something? is there other way to hook it?

maqi 07-17-2018 14:02

Re: pev(ent, pev_health) return 0.0
 
Code:
Float:health

Anyway, Ham_Killed should work, right ?

Also, second parameter is not a weapon, while the dmg parameter is also a float.

Celena Luna 07-17-2018 14:19

Re: pev(ent, pev_health) return 0.0
 
Quote:

Originally Posted by hzqst (Post 1285175)
Func_breakable won't be killed unless you remove it using FL_KILLME or map flags(kill after trigger)
It just disappears when strength goes to 0

Also, I just lazy to change the parameter.
It should be
PHP Code:

fw_Object_TakeDamage(victiminflictorattackerFloat:dmgdamagebtis

EDIT: OK, it work now. Used pev wrong way
PHP Code:

public fw_Object_TakeDamage(VictimInflictorAttackerFloat:DamageDamageBits)
{
    static 
Float:Healthpev(Victimpev_healthHealth)
    
client_print(Attackerprint_chat"Ent: %i"Victim)
    
client_print(Attackerprint_chat"Ent HP: %.f"Health)



CrazY. 07-19-2018 09:35

Re: pev(ent, pev_health) return 0.0
 
Second parameter is the entity that inflicted the damage, so it can be weapon entity too.


All times are GMT -4. The time now is 12:47.

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