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

check victim health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LearninG
Senior Member
Join Date: Apr 2019
Location: Iran
Old 10-21-2019 , 17:09   check victim health
Reply With Quote #1

Hi , i want to check if current victim health (gondor health) is lower than (main health / 2) and also (/3) , however as you can see below i made it work , but it's not efficient , hope that you give me an efficient way of checking victim health.

Code:
new g_gondor_health = 1600 // an example

Code:
public On_Player_Take_Damage(victim, inflictor, attacker, Float:dmg, dmgbits) {     if (attacker == victim)       return HAM_IGNORED     if (check_user_class(g_gondar_class , victim))     {         check_health(victim) // checking victim (gondor) health     }      return HAM_HANDLED }

Code:
check_health(index) {     new current_health     current_health = get_user_health(index)     if ((g_gondar_health / 2) >= current_health)     {         set_user_maxspeed(index , 450.0)         set_user_rendering(index, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha,155)         message_begin(MSG_ALL,iconstatus,{0,0,0},index)         write_byte(1) // status (0=hide, 1=show, 2=flash)         write_string("dmg_poison") // sprite name         write_byte(255) // red         write_byte(255) // green         write_byte(0) // blue         message_end()     }     if((g_gondar_health / 3) >= current_health)     {         set_user_maxspeed(index , 800.0)         set_user_rendering(index, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha,55)         message_begin(MSG_ALL,iconstatus,{0,0,0},index)         write_byte(1) // status (0=hide, 1=show, 2=flash)         write_string("dmg_poison") // sprite name         write_byte(255) // red         write_byte(0) // green         write_byte(0) // blue         message_end()     } }
LearninG is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 10-21-2019 , 18:02   Re: check victim health
Reply With Quote #2

whats is the problem exactly?
atleast add some client_prints debug by yourself to see whats called what is not?
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 10-21-2019 at 18:02.
JocAnis is offline
LearninG
Senior Member
Join Date: Apr 2019
Location: Iran
Old 10-21-2019 , 23:33   Re: check victim health
Reply With Quote #3

ok , let's say gondar ( a hero ) has 1800 hp on new round. i want to check if it's health becomes lower than 900 , then i will add some effects and if it becomes lower than 600 i will disable that effects and will add new effects.
basically this is how i'm checking :
Code:
(if ((g_gondar_health / 2) >= current_health)
and at the same
Code:
(if ((g_gondar_health / 3) >= current_health)

so both sentence becomes true when gondar health reaches 599 and effects will be activated. problem is both sentence will be excuted while the health is under (main health /3 ). and 1 of them is unnnessesary.
Code:
check_health(index) {     new current_health     current_health = get_user_health(index)     if ((g_gondar_health / 2) >= current_health)     {         set_user_maxspeed(index , 450.0)         set_user_rendering(index, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha,155)         message_begin(MSG_ALL,iconstatus,{0,0,0},index)         write_byte(1) // status (0=hide, 1=show, 2=flash)         write_string("dmg_poison") // sprite name         write_byte(255) // red         write_byte(255) // green         write_byte(0) // blue         message_end()     }     if((g_gondar_health / 3) >= current_health)     {         set_user_maxspeed(index , 800.0)         set_user_rendering(index, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha,55)         message_begin(MSG_ALL,iconstatus,{0,0,0},index)         write_byte(1) // status (0=hide, 1=show, 2=flash)         write_string("dmg_poison") // sprite name         write_byte(255) // red         write_byte(0) // green         write_byte(0) // blue         message_end()     } }
LearninG is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 10-22-2019 , 00:02   Re: check victim health
Reply With Quote #4

I'm tired and sleepy, but the logic would be this, maybe some adjustment is needed.

PHP Code:
check_health(index)
{
    new 
current_health
    current_health 
get_user_health(index)

    if ((
g_gondar_health 2) >= current_health && (g_gondar_health 3) < current_health)
    {
        
set_user_maxspeed(index 450.0)
        
set_user_rendering(indexkRenderFxGlowShell000kRenderTransAlpha,155)
        
message_begin(MSG_ALL,iconstatus,{0,0,0},index)
        
write_byte(1// status (0=hide, 1=show, 2=flash)
        
write_string("dmg_poison"// sprite name
        
write_byte(255// red
        
write_byte(255// green
        
write_byte(0// blue
        
message_end()
    }
    else if ((
g_gondar_health 3) >= current_health)
    {
        
set_user_maxspeed(index 800.0)
        
set_user_rendering(indexkRenderFxGlowShell000kRenderTransAlpha,55)
        
message_begin(MSG_ALL,iconstatus,{0,0,0},index)
        
write_byte(1// status (0=hide, 1=show, 2=flash)
        
write_string("dmg_poison"// sprite name
        
write_byte(255// red
        
write_byte(0// green
        
write_byte(0// blue
        
message_end()
    }

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
E1_531G
Senior Member
Join Date: Dec 2017
Old 10-22-2019 , 00:27   Re: check victim health
Reply With Quote #5

Let say
PHP Code:
g_gondar_health 3000 
PHP Code:
if ( current_health < (g_gondar_health 3) ) // less than 1000?
    //code
else if ( current_health < (g_gondar_health 2) ) // we are here, so it's not less than 1000. maybe less than 1500?
    //code
else // we are here, so it's not less than 1000 or 1500. it's more
    //code, if needed 
Also, for only one player MSG_ALL is the wrong type.
__________________
My English is A0
E1_531G 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 09:43.


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