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

entity health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
felipemilralze
Senior Member
Join Date: Jul 2011
Location: Brazil
Old 07-16-2015 , 14:39   entity health
Reply With Quote #1

PHP Code:

It does not work

new Float:health entity_get_float(entityEV_FL_health);

if(
health 300.0)
{
client_print(entityprint_center"hp %f"health);
}
else if(
health 150.0)
{
client_print(entityprint_center"hp %f"health);

felipemilralze is offline
Send a message via MSN to felipemilralze Send a message via Skype™ to felipemilralze
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 07-16-2015 , 17:49   Re: entity health
Reply With Quote #2

Ehat means "it does not work" ? Did you try just print in chat the health outside these if'ies ?

Entity has health ?

Last edited by grs4; 07-16-2015 at 17:54.
grs4 is offline
felipemilralze
Senior Member
Join Date: Jul 2011
Location: Brazil
Old 07-16-2015 , 18:20   Re: entity health
Reply With Quote #3

I was trying to do an entity shine in green if the horsepower is less than 150, and is less than 50 bright yellow

example: let's assume that health equals 600.
if less than 600 health makes green glow, if smaller 300 is yellow glow.

More models is an entity

PHP Code:
public place_palletwbags(id

     
    if(
palletscout == get_pcvar_num(maxpallets)) 
    { 
        
ChatColor(id"^x04Mestre |^x01 Por razoes de seguranca so permitem^x04 %d ^x01Os sacos de areia no servidor!",get_pcvar_num 

        
(maxpallets)); 

        return 
PLUGIN_HANDLED
    } 
     
    
// create a new entity  
    
new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"func_wall")); 

    
// set a name to the entity 
    
set_pev(ent,pev_classname,"amxx_pallets"); 
     
    
// set model         
    
engfunc(EngFunc_SetModel,ent,g_models[random(sizeof g_models)]); 
     
    
// register a new var. for origin 
    
static Float:xorigin[3];
 
    
get_user_hitpoint(id,xorigin); 
       
    
// check if user is aiming at the air  
    
if(engfunc(EngFunc_PointContents,xorigin) == CONTENTS_SKY
    { 
        
ChatColor(id"^x04Mestre |^x01 Voce nao pode colocar sacos de areia no ceu!"); 
        return 
PLUGIN_HANDLED
    } 

    
// set sizes 
    
static Float:p_mins[3], Float:p_maxs[3]; 
    
p_mins PALLET_MINS
    
p_maxs PALLET_MAXS
    
engfunc(EngFunc_SetSizeentp_minsp_maxs); 
    
set_pev(entpev_minsp_mins); 
    
set_pev(entpev_maxsp_maxs ); 
    
set_pev(entpev_absminp_mins); 
    
set_pev(entpev_absmaxp_maxs ); 
     
    
// set the rock of origin where is user placed 
    
engfunc(EngFunc_SetOriginentxorigin); 
        
    
// make the rock solid 
    
set_pev(ent,pev_solid,SOLID_BBOX); // touch on edge, block 
     
    // set the movetype 
    
set_pev(ent,pev_movetype,MOVETYPE_FLY); // no gravity, but still collides with stuff 
     
    // now the damage stuff, to set to take it or no 
    // if you set the cvar "pallets_wbags_health" 0, you can't destroy a pallet with bags 
    // else, if you want to make it destroyable, just set the health > 0 and will be 
    // destroyable. 
    
new Float:p_cvar_health get_pcvar_float(phealth); 
    switch(
p_cvar_health
    {
        case 
0.0 
    { 
        
set_pev(ent,pev_takedamage,DAMAGE_NO); 
    }
    
    default : 
    { 
        
set_pev(ent,pev_health,p_cvar_health); //600 hp para o saco
        
set_pev(ent,pev_takedamage,DAMAGE_YES); // danos ativado
    

    }   
    
    new 
Floathealth entity_get_float(entEV_FL_health);
    
    if(
health 601.0)
    {
        
set_rendering(entkRenderFxGlowShell02550kRenderNormal25);
    }
    else if(
health 401.0)
    {
        
set_rendering(entkRenderFxGlowShell2552550kRenderNormal25);
    }
    else if(
health 201.0)
    {
        
set_rendering(entkRenderFxGlowShell25500kRenderNormal25);
    }
    
    
//set_rendering(ent, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 25);
    //set_rendering(ent, kRenderFxGlowShell, 255, 255, 0, kRenderNormal, 25);

    
static Float:rvec[3]; 
    
pev(id,pev_v_angle,rvec); 
     
    
rvec[0] = 0.0
     
    
set_pev(ent,pev_angles,rvec); 
     
    
// drop entity to floor 
    
fm_drop_to_floor(ent); 

    
set_pev(entpev_ownerid);
     
    
// num .. 
    
palletscout++; 
     
    
// confirm message 
    
new nome[33];
    
get_user_name(idnome31);

    
ChatColor(0"!gMestre |!t %s plantou um saco de areia!"nome);

    
ChatColor(id"^x04Mestre |^x01 Voce colocou uma sacos de areia, voce tem^x04 %i ^x01remanescente"g_bolsas[id]) 
    
    return 
PLUGIN_HANDLED


Last edited by felipemilralze; 07-16-2015 at 18:42.
felipemilralze is offline
Send a message via MSN to felipemilralze Send a message via Skype™ to felipemilralze
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 07-16-2015 , 19:05   Re: entity health
Reply With Quote #4

try with getting health using fakemeta :

pev(entity, pev_health)
grs4 is offline
felipemilralze
Senior Member
Join Date: Jul 2011
Location: Brazil
Old 07-16-2015 , 19:37   Re: entity health
Reply With Quote #5

Quote:
Originally Posted by grs4 View Post
try with getting health using fakemeta :

pev(entity, pev_health)
the condition is not working, or not this function obtaining health.

PHP Code:

if(pev(entpev_health) < 600.0)
{
  
set_rendering(entkRenderFxGlowShell02550kRenderNormal25);
}
else if(
pev(entpev_health) < 300.0)
{
  
set_rendering(entkRenderFxGlowShell2552550kRenderNormal25);

felipemilralze is offline
Send a message via MSN to felipemilralze Send a message via Skype™ to felipemilralze
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 07-17-2015 , 07:29   Re: entity health
Reply With Quote #6

Maybe health is above 600.0 ?
i dont know why it just happening.
grs4 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-17-2015 , 08:14   Re: entity health
Reply With Quote #7

It would be smart to print the entity's health value first. You should learn how to debug code with chat/log messages.
klippy is offline
colossus
Member
Join Date: Sep 2013
Old 07-18-2015 , 16:08   Re: entity health
Reply With Quote #8

Quote:
Originally Posted by felipemilralze View Post
PHP Code:

It does not work

new Float:health entity_get_float(entityEV_FL_health);

if(
health 300.0)
{
client_print(entityprint_center"hp %f"health);
}
else if(
health 150.0)
{
client_print(entityprint_center"hp %f"health);

---------------> show to player, not to entity
PHP Code:
new Float:health entity_get_float(entityEV_FL_health);

if(
health 300.0)
{
client_print(idprint_center"hp %f"health);
}
else if(
health 150.0)
{
client_print(idprint_center"hp %f"health);

colossus 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 21:29.


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