@LondoN, you are missing the check for g_item_sti[] for terrorists, while also applying the check for g_item_reg[] for both teams while his original code had it for only CT. If this is specific to CT's, terrorists would never get health regen.
I would eliminate the set_task() at spawn. Create the task one time and check all players.
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#define Task_RegenHealth 29812
new g_item_reg[ MAX_PLAYERS + 1 ];
new g_item_sti[ MAX_PLAYERS + 1 ];
new Float:MaxHP[ MAX_PLAYERS + 1 ];
public plugin_init()
{
set_task( 2.0 , "Task_HPRegenLoop" , Task_RegenHealth , .flags="b" );
}
public Task_HPRegenLoop()
{
new iPlayers[ 32 ] , iNum , id , CsTeams:ctTeam , iHealth;
get_players( iPlayers , iNum , "ach" );
if ( iNum )
{
for ( new i = 0 ; i < iNum ; i++ )
{
id = iPlayers[ i ];
ctTeam = cs_get_user_team( id );
iHealth = get_user_health( id );
if ( g_item_reg[ id ] && ( ctTeam == CS_TEAM_CT ) )
{
if ( iHealth < 500 )
set_user_health(id, clamp( iHealth + 5 , 1 , 500 ) );
}
else if ( g_item_sti[ id ] && ( ctTeam == CS_TEAM_T ) )
{
if ( iHealth < MaxHP[ id ] )
set_user_health( id , clamp( iHealth + floatround( MaxHP[ id ] * 0.05 ) , 1 , floatround( MaxHP[ id ] ) ) );
}
}
}
}
__________________