Raised This Month: $ Target: $400
 0% 

i need to fix this code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Qumsieh
Senior Member
Join Date: Jun 2015
Old 08-15-2015 , 15:43   i need to fix this code
Reply With Quote #1

hello guys i'm having a problem with hp in [HSN], the problem is when you have 200 hp and fall from place and lose hp you cant get it back when you step on the health block, i mean the hp block will heal you till you reach the normal hp (100), i need it to give you the full hp you have.

PHP Code:
ActionHeal(ident)
{
    new 
Float:gametime get_gametime();
    if ( !( 
gametime >= g_next_heal_time[id] ) ) return PLUGIN_HANDLED;
    
    new 
health get_user_health(id);
    if ( 
health >= 100 ) return PLUGIN_HANDLED;
    
    static 
property[5];
    
    
GetProperty(ent1property);
    
health += str_to_num(property);
    
set_user_health(idmin(100health));
    
    
GetProperty(ent2property);
    
g_next_heal_time[id] = gametime str_to_float(property);
    
    return 
PLUGIN_HANDLED;

here is the code

Last edited by Qumsieh; 08-16-2015 at 11:36.
Qumsieh is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 08-16-2015 , 02:53   Re: i need to fix this code
Reply With Quote #2

From what I understand from your post you want them to be able to get back their 200 HP?
If so, change this line
PHP Code:
if ( health >= 100 ) return PLUGIN_HANDLED
to
PHP Code:
if ( health >= 200 ) return PLUGIN_HANDLED
Darkness_ is offline
Qumsieh
Senior Member
Join Date: Jun 2015
Old 08-16-2015 , 03:45   Re: i need to fix this code
Reply With Quote #3

Quote:
Originally Posted by Darkness_ View Post
From what I understand from your post you want them to be able to get back their 200 HP?
If so, change this line
PHP Code:
if ( health >= 100 ) return PLUGIN_HANDLED
to
PHP Code:
if ( health >= 200 ) return PLUGIN_HANDLED

emmm, when i cahanged the value to 200 and stand on the health block my health will back to 100 even if i have 200 hp

Last edited by Qumsieh; 08-16-2015 at 10:22.
Qumsieh is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-16-2015 , 11:08   Re: i need to fix this code
Reply With Quote #4

post the code in php !

you need to check his hp before he fell ! (post fall)
and then regenerate his hp !

Last edited by Natsheh; 08-16-2015 at 11:11.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Qumsieh
Senior Member
Join Date: Jun 2015
Old 08-16-2015 , 11:35   Re: i need to fix this code
Reply With Quote #5

Quote:
you need to check his hp before he fell ! (post fall)
and then regenerate his hp !

give me examble of this code on what you wrote

Last edited by Qumsieh; 08-16-2015 at 14:15.
Qumsieh is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-16-2015 , 16:18   Re: i need to fix this code
Reply With Quote #6

here's example :-

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <engine>

#define PLUGIN "Health Regeneration"
#define VERSION "1.0"
#define AUTHOR "Natsheh"

#define TASK_HP_REGENERATION 400
#define FALL_VELOCITY 350.0

new bool:user_falling[33]
new 
Float:user_health[33]

public 
plugin_init()
{
    
register_plugin("Health Regeneration""1.0""Natsheh");
}

public 
client_PreThink(id)
{
    if(!
is_user_alive(id) && !is_user_connected(id))
        return
    
    if(
entity_get_float(idEV_FL_flFallVelocity) >= FALL_VELOCITY)
    {
        
user_health[id] = entity_get_float(idEV_FL_health)
        
user_falling[id] = true;
    }
    else
    {
        
user_falling[id] = false;
    }
}

public 
client_PostThink(id)
{
    if(!
is_user_alive(id) && !is_user_connected(id))
        return
    
    if(
user_falling[id])
    {
        
set_task(2.5"health_regeneration"id+TASK_HP_REGENERATION)
    }
}

public 
health_regeneration(taskid)
{
    new 
id taskid TASK_HP_REGENERATION
    
    entity_set_float
(idEV_FL_healthuser_health[id])
    
remove_task(taskid)

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Qumsieh
Senior Member
Join Date: Jun 2015
Old 08-16-2015 , 17:14   Re: i need to fix this code
Reply With Quote #7

Quote:
Originally Posted by Natsheh View Post
here's example :-

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <engine>

#define PLUGIN "Health Regeneration"
#define VERSION "1.0"
#define AUTHOR "Natsheh"

#define TASK_HP_REGENERATION 400
#define FALL_VELOCITY 350.0

new bool:user_falling[33]
new 
Float:user_health[33]

public 
plugin_init()
{
    
register_plugin("Health Regeneration""1.0""Natsheh");
}

public 
client_PreThink(id)
{
    if(!
is_user_alive(id) && !is_user_connected(id))
        return
    
    if(
entity_get_float(idEV_FL_flFallVelocity) >= FALL_VELOCITY)
    {
        
user_health[id] = entity_get_float(idEV_FL_health)
        
user_falling[id] = true;
    }
    else
    {
        
user_falling[id] = false;
    }
}

public 
client_PostThink(id)
{
    if(!
is_user_alive(id) && !is_user_connected(id))
        return
    
    if(
user_falling[id])
    {
        
set_task(2.5"health_regeneration"id+TASK_HP_REGENERATION)
    }
}

public 
health_regeneration(taskid)
{
    new 
id taskid TASK_HP_REGENERATION
    
    entity_set_float
(idEV_FL_healthuser_health[id])
    
remove_task(taskid)

so do i need to add this code in the plugin that i use or seperet one?
Qumsieh is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-16-2015 , 17:22   Re: i need to fix this code
Reply With Quote #8

Quote:
Originally Posted by Qumsieh View Post
so do i need to add this code in the plugin that i use or seperet one?
What?
I just gave you an example try to figure it by yourself !

the plugin that i gave you is separated !

Edited.

Last edited by Natsheh; 08-16-2015 at 17:24.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Qumsieh
Senior Member
Join Date: Jun 2015
Old 08-16-2015 , 18:13   Re: i need to fix this code
Reply With Quote #9

Quote:
Originally Posted by Natsheh View Post
What?
I just gave you an example try to figure it by yourself !

the plugin that i gave you is separated !

Edited.
still cant fix it !!

Last edited by Qumsieh; 08-19-2015 at 05:21.
Qumsieh is offline
Qumsieh
Senior Member
Join Date: Jun 2015
Old 08-19-2015 , 05:21   Re: i need to fix this code
Reply With Quote #10

Quote:
Originally Posted by Qumsieh View Post
still cant fix it !!
Qumsieh 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 11:16.


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