Raised This Month: $ Target: $400
 0% 

[HELP] Adding health doesnt work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tolpecek
Member
Join Date: Dec 2018
Old 12-26-2018 , 07:01   [HELP] Adding health doesnt work
Reply With Quote #1

Hello,
I am doing Basebuilder mod and i have problem with regeneration.

Code:
public plugin_init()
{
RegisterHam(Ham_Spawn, "player", "zaciatok_kola", 1 )
}
Code:
public zaciatok_kola(id)
{
set_task(1.5,"Task_HPRegenLoop",0,_,_,"b")
}
Code:
public Task_HPRegenLoop(id)
{
	log_amx("It works") // this is only test that this function is executed.
	new addhealth = 10; 
	if (!addhealth)
		return;    
	
	if (get_user_health(id) < MaxHP[id] && g_item_reg[id] && cs_get_user_team(id) == CS_TEAM_CT)
	{ 
		set_user_health(id, get_user_health(id) + addhealth);
		
	}
	else 
	{
		if (get_user_health(id) < MaxHP[id] && g_item_reg[id] && get_user_team(id) & 2)
		{
			remove_task(id);
		}
	}
}

it simply does not add healths

Last edited by tolpecek; 12-26-2018 at 07:57. Reason: forgot write something
tolpecek is offline
tolpecek
Member
Join Date: Dec 2018
Old 12-26-2018 , 08:31   Re: [HELP] Adding health doesnt work
Reply With Quote #2

even with if(is_user_alive(id)) check doesnt work
tolpecek is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-26-2018 , 08:34   Re: [HELP] Adding health doesnt work
Reply With Quote #3

You are passing 0 as id in set_task. Pass the actual player index.
__________________
HamletEagle is offline
tolpecek
Member
Join Date: Dec 2018
Old 12-26-2018 , 09:27   Re: [HELP] Adding health doesnt work
Reply With Quote #4

thanks, it works
tolpecek is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 12-29-2018 , 06:46   Re: [HELP] Adding health doesnt work
Reply With Quote #5

Code:
set_task(1.5,"Task_HPRegenLoop",0,_,_,"b")
->
Code:
set_task(1.5, "Task_HPRegenLoop", id, .flags = "b")
Also, you have to add if(is_user_alive(id)) in public zaciatok_kola(id)
__________________

Last edited by eat1k; 12-29-2018 at 06:46.
eat1k 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 07:40.


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