AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Health Restore (https://forums.alliedmods.net/showthread.php?t=172814)

ingmar13 11-26-2011 10:24

Health Restore
 
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

kramesa 11-26-2011 10:32

Re: Health Restore
 
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")



ingmar13 11-26-2011 10:36

Re: Health Restore
 
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

}

kramesa 11-26-2011 10:38

Re: Health Restore
 
I fixed, try now

kotinha 11-26-2011 10:54

Re: Health Restore
 
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 <=

ingmar13 11-26-2011 11:04

Re: Health Restore
 
thanks again!

kramesa 11-26-2011 11:05

Re: Health Restore
 
Quote:

Originally Posted by kotinha (Post 1603008)
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


All times are GMT -4. The time now is 08:33.

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