AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   is_hostage_alive(ent) (https://forums.alliedmods.net/showthread.php?t=89829)

Empowers 04-11-2009 03:42

is_hostage_alive(ent)
 
I have ent id of hostage.. I wanna to check is he alive.. whats the best way?

Note: I'm checking that in somethink like fw_preHostageRespawn :)

maybe that's why this doesn't work:
PHP Code:

if(pev(ent,pev_deadflag)!=DEAD_NO

PHP Code:

if(!pev(ent,pev_health)) 


xPaw 04-11-2009 03:51

Re: is_hostage_alive(ent)
 
Check pev_health, i'm sure it should be more than 0

Empowers 04-11-2009 03:51

Re: is_hostage_alive(ent)
 
thx, will try :)

Empowers 04-11-2009 03:59

Re: is_hostage_alive(ent)
 
I updated the post. Doesn't work :(

Empowers 04-11-2009 04:00

Re: is_hostage_alive(ent)
 
And there is the question will Ham_Killed hook hostage death?

Exolent[jNr] 04-11-2009 04:03

Re: is_hostage_alive(ent)
 
Hook the forward in post and not pre.

Empowers 04-11-2009 04:05

Re: is_hostage_alive(ent)
 
Quote:

Originally Posted by Exolent[jNr] (Post 802793)
Hook the forward in post and not pre.

I need to SUPERCEDE it in some cases. Also I need check was hostage alive before respawn, but not after it had respawned..

xPaw 04-11-2009 04:39

Re: is_hostage_alive(ent)
 
PHP Code:

stock bool:is_hostage_aliveiEntity ) {
    if( !
pev_validiEntity ) )
        return 
false;
    
    new 
szClassname32 ];
    
peviEntitypev_classnameszClassname31 );
    
    if( !
equalszClassname"hostage_entity" ) )
        return 
false;
    
    if( 
peviEntitypev_health ) > )
        return 
true;
    
    return 
false;


not tested.

Empowers 04-11-2009 04:49

Re: is_hostage_alive(ent)
 
Man I was doing the same.. :) Just I think hostages HP is restored before respawn, so I need some other way to check that..

xPaw 04-11-2009 05:04

Re: is_hostage_alive(ent)
 
Dont know how you tryed but it worked pefect for me.
PHP Code:

#include <amxmodx>
#include <fakemeta>

public plugin_init() {
    
register_clcmd"say /host""cmdLol" );
}

public 
cmdLolid ) {
    if( 
is_hostage_alive155 ) )    // hardcoding indexes not save, just did for test, it was hostage for me @ cs_assualt, maxplayers 5.
        
client_print0print_chat"Hostage is alive." );
    else
        
client_print0print_chat"Hostage is dead." );
}

stock bool:is_hostage_aliveiEntity ) {
    if( !
pev_validiEntity ) )
        return 
false;
    
    new 
szClassname32 ];
    
peviEntitypev_classnameszClassname31 );
    
    if( !
equalszClassname"hostage_entity" ) )
        return 
false;
    
    if( 
peviEntitypev_health ) > )
        return 
true;
    
    return 
false;




All times are GMT -4. The time now is 02:19.

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