AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Adding health doesnt work (https://forums.alliedmods.net/showthread.php?t=313039)

tolpecek 12-26-2018 07:01

[HELP] Adding health doesnt work
 
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 :(

tolpecek 12-26-2018 08:31

Re: [HELP] Adding health doesnt work
 
even with if(is_user_alive(id)) check doesnt work :(

HamletEagle 12-26-2018 08:34

Re: [HELP] Adding health doesnt work
 
You are passing 0 as id in set_task. Pass the actual player index.

tolpecek 12-26-2018 09:27

Re: [HELP] Adding health doesnt work
 
thanks, it works

eat1k 12-29-2018 06:46

Re: [HELP] Adding health doesnt work
 
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)


All times are GMT -4. The time now is 07:40.

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