Raised This Month: $ Target: $400
 0% 

Set_user_health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 06-06-2010 , 11:04   Set_user_health
Reply With Quote #1

Why this plugin isn't working properly ?

when I'm holding a knife it should restore my Health every 10 seconds, but it doesn't.

code:

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

#define PLUGIN "knife heal"
#define VERSION "1.0"
#define AUTHOR "addinol"
new gtimegmaxgadd
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("CurWeapon""Event_CurWeapon""be","1=1");
    
gtime register_cvar("inch_khptime","10.0")
    
gmax register_cvar("inch_khpmax","200")
    
gadd register_cvar("inch_khprestore","3")
}

public 
Event_CurWeapon(id)
{
    new 
clipammoweapon get_user_weapon(id,clip,ammo);
    if(
weapon == CSW_KNIFE) { 
    
set_task(get_pcvar_float(gtime), "hp")
}
}

public 
hp(id){
    new 
userHp get_user_health(id)
    if(
userHp >= get_pcvar_num(gmax))
    {
        
set_user_health(idget_pcvar_num(gmax))
    }else{
    
set_user_health(iduserHp get_pcvar_num(gadd))
    
set_task(get_pcvar_float(gtime), "hp")
    }

reinert is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 06-06-2010 , 12:48   Re: Set_user_health
Reply With Quote #2

PHP Code:
public hp(id){
    new 
userHp get_user_health(id)
    if(
userHp >= get_pcvar_num(gmax))
    {
        
set_user_health(idget_pcvar_num(gmax))
    }else{
    
set_user_health(iduserHp get_pcvar_num(gadd))
    
set_task(get_pcvar_float(gtime), "hp")
    }

You never defined (id) in hp(id). I don't believe.

Last edited by RedRobster; 06-06-2010 at 12:50.
RedRobster is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 06-06-2010 , 13:49   Re: Set_user_health
Reply With Quote #3

Quote:
Originally Posted by RedRobster View Post
PHP Code:
public hp(id){
    new 
userHp get_user_health(id)
    if(
userHp >= get_pcvar_num(gmax))
    {
        
set_user_health(idget_pcvar_num(gmax))
    }else{
    
set_user_health(iduserHp get_pcvar_num(gadd))
    
set_task(get_pcvar_float(gtime), "hp")
    }

You never defined (id) in hp(id). I don't believe.
What you posted is the exact same.
__________________
Hi.
Kreation is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 06-06-2010 , 13:52   Re: Set_user_health
Reply With Quote #4

Quote:
Originally Posted by Kreation View Post
What you posted is the exact same.
I don't believe he was posting a fix. He quoted the area he thought needed to be fixed and said:

Quote:
You never defined (id) in hp(id). I don't believe.
So that the topic creator knew which part of the code he was talking about.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 06-06-2010 at 13:54.
GXLZPGX is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 06-06-2010 , 13:55   Re: Set_user_health
Reply With Quote #5

Quote:
Originally Posted by GXLZPGX View Post
So that the topic creator knew which part of the code he was talking about.
But he did define id. I'm am just off today, I swear. I must've taken stupid pills.
__________________
Hi.
Kreation is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 06-06-2010 , 15:08   Re: Set_user_health
Reply With Quote #6

Quote:
Originally Posted by Kreation View Post
But he did define id. I'm am just off today, I swear. I must've taken stupid pills.
I don't think when he first set the task that he defined id. He just did
PHP Code:
set_task(get_pcvar_float(gtime), "hp" 
He never defines what the "id" is that he is using when he actually executes the function.

I do think that:
PHP Code:
set_task(get_pcvar_float(gtime), "hp"id 
would work... o.o
RedRobster is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 06-07-2010 , 08:10   Re: Set_user_health
Reply With Quote #7

Quote:
Originally Posted by Kreation View Post
But he did define id. I'm am just off today, I swear. I must've taken stupid pills.
You always take stupid pills xD
SaM.ThE.MaN is offline
t*stylez
BANNED
Join Date: Apr 2010
Old 06-07-2010 , 10:58   Re: Set_user_health
Reply With Quote #8

Quote:
Originally Posted by Kreation View Post
But he did define id. I'm am just off today, I swear. I must've taken stupid pills.
you do that everyday in ventrilo :]
t*stylez is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 06-06-2010 , 15:09   Re: Set_user_health
Reply With Quote #9

So whats exactly wrong ? I don't see anything maybe problem is in my server ;D

EDIT: i will try.

Last edited by reinert; 06-06-2010 at 15:15.
reinert is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 06-06-2010 , 20:41   Re: Set_user_health
Reply With Quote #10

PHP Code:
public Event_CurWeapon(id)
{
    new 
clipammoweapon get_user_weapon(id,clip,ammo);
    if(
weapon == CSW_KNIFE) { 
        
set_task(get_pcvar_float(gtime), "hp"id)
    } else {
        
remove_task(id)
    }

Do you think that'd work if he removed the task if it wasn't a knife? I don't think it would matter if that task is not already going.
RedRobster 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 05:20.


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