The code works now but it constantly increases hp every second when you are within the specified distance from another player, is this what you intended?. The reason I ask is I see your plugin title is "Heal on See"; were you trying to make it so if players can see each other it restores health? Or just if they are close to each other? If the latter then you may need to increase the distance of 40 a little bit.
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>
#define PLUGIN "Heal on See"
#define VERSION "1.0"
#define AUTHOR "author"
public plugin_init()
{
register_plugin( PLUGIN , VERSION , AUTHOR );
register_event( "DeathMsg" , "fw_EvDeathMsg" , "a" , "2>0" );
RegisterHam( Ham_Spawn , "player" , "FwdHamPlayerSpawn_Post" , 1 );
}
public FwdHamPlayerSpawn_Post( id )
{
if ( is_user_alive( id ) )
set_task( 1.0 , "healonsee" , id , _ , _ , "b" );
}
public fw_EvDeathMsg()
{
remove_task( read_data( 2 ) );
}
public healonsee(id)
{
new players[32] , num , iPlayer;
new origin1[ 3 ] , origin2[ 3 ];
get_players( players , num );
for( new i = 0 ; i < num ; i++ )
{
iPlayer = players[ i ];
if( ( id != iPlayer ) && is_user_alive( iPlayer ) )
{
get_user_origin( id , origin1 , 0 );
get_user_origin( iPlayer , origin2 , 0 );
if( get_distance( origin1 , origin2 ) <= 40 )
{
set_user_health( id , get_user_health( id ) + 1 );
}
}
}
}
__________________