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

Health Restore


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ingmar13
Member
Join Date: Jun 2008
Old 11-26-2011 , 10:24   Health Restore
Reply With Quote #1

I'm wondering how to restore the health bar with a command..



for example:

/restore-health

I = I ++ (if health <100)
something like this XD


PS. I'm no coder/programmer
__________________
will make maps for food!
ingmar13 is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 11-26-2011 , 10:32   Re: Health Restore
Reply With Quote #2

Try is:

PHP Code:
#include <amxmodx>
#include <fun>

public plugin_init()
{
    
register_plugin("Restore Damage""0.1""kramesa")
    
register_clcmd("say /restore-health""Restore_Damage")
}
public 
Restore_Damage(id)
{    
    if(
get_user_health(id) == 100)
        
client_print(idprint_chat"Your life already is 100")
    
    if(
get_user_health(id) < 100)
        
Life(id)
}

public 
Life(id)
{
    
set_user_health(id100)
    
client_print(idprint_chat"Your life changed to 100")

__________________

Last edited by kramesa; 11-26-2011 at 10:59.
kramesa is offline
ingmar13
Member
Join Date: Jun 2008
Old 11-26-2011 , 10:36   Re: Health Restore
Reply With Quote #3

thanks a lot !

I really appreciate this. will put this code in my plugin ^^


it says 1 warning.
line 15: Warning 255: unreachable code

line15:
Code:
set_user_health(id, 100)
    client_print(id, print_chat, "Your life changed to 100")
    return PLUGIN_HANDLED
}
__________________
will make maps for food!

Last edited by ingmar13; 11-26-2011 at 10:46.
ingmar13 is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 11-26-2011 , 10:38   Re: Health Restore
Reply With Quote #4

I fixed, try now
__________________

Last edited by kramesa; 11-26-2011 at 10:59.
kramesa is offline
kotinha
Senior Member
Join Date: Jun 2009
Location: Alentejo, Portugal :)
Old 11-26-2011 , 10:54   Re: Health Restore
Reply With Quote #5

PHP Code:
#include <amxmodx>
#include <fun>

public plugin_init()
{
    
register_plugin("Restore Damage""0.1""kramesa")
    
register_clcmd("say /restore-health""Restore_Damage")
}
public 
Restore_Damage(id)
{
    if(
get_user_health(id) == 100)
        
client_print(idprint_chat"Your life already is 100")
    else
    {
        
set_user_health(id100)
        
client_print(idprint_chat"Your life changed to 100")
    }

kramesa, you have to put {} if you want more that one line of code in the condition.
And if(get_user_health(id) <= 100) means if user health is LOWER or equal to 100. You must use == instead of <=
__________________
"If God exists, I hope he has a good excuse." - Woody Allen

Last edited by kotinha; 11-26-2011 at 10:54.
kotinha is offline
ingmar13
Member
Join Date: Jun 2008
Old 11-26-2011 , 11:04   Re: Health Restore
Reply With Quote #6

thanks again!
__________________
will make maps for food!
ingmar13 is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 11-26-2011 , 11:05   Re: Health Restore
Reply With Quote #7

Quote:
Originally Posted by kotinha View Post
PHP Code:
#include <amxmodx>
#include <fun>

public plugin_init()
{
    
register_plugin("Restore Damage""0.1""kramesa")
    
register_clcmd("say /restore-health""Restore_Damage")
}
public 
Restore_Damage(id)
{
    if(
get_user_health(id) == 100)
        
client_print(idprint_chat"Your life already is 100")
    else
    {
        
set_user_health(id100)
        
client_print(idprint_chat"Your life changed to 100")
    }

kramesa, you have to put {} if you want more that one line of code in the condition.
And if(get_user_health(id) <= 100) means if user health is LOWER or equal to 100. You must use == instead of <=
Ok! Thanks
__________________
kramesa is offline
Reply


Thread Tools
Display Modes

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 08:51.


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