SA-MP Forums Archive
Healing System Please Help! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Healing System Please Help! (/showthread.php?tid=268549)



Healing System Please Help! - [R]ambo - 12.07.2011

I want to be able to make my skin soldier, so that when he's beside his wounded teammate he's able to heal automatically. And that he's unable to heal other teammates.


Re: Healing System Please Help! - Basicz - 12.07.2011

Did I helped you before in this Thread?

OH! I know what did you change!

pawn Код:
#include < a_samp >
#include < foreach >

new
    pUpdateTimer[ MAX_PLAYERS ]
;

public OnPlayerConnect( playerid ) {
    pUpdateTimer[ playerid ] = SetTimerEx( "healMembers", 1000, true, "i", playerid );
    return 1;
}

forward healMembers( playerid );
public healMembers( playerid )
{
    if ( GetPlayerSkin( playerid ) == 287 )
    {
        new
            Float: X, Float: Y, Float: Z, target = INVALID_PLAYER_ID;

        GetPlayerPos( playerid, X, Y, Z );

        foreach (Player, i)
        {
            if ( IsPlayerInRangeOfPoint( i, 2.0, X, Y, Z ) && i != playerid )
            {
                target = i;
            }
        }

        if ( GetPlayerSkin( target ) == 287 )
        {
            new Float: pHealth;
            GetPlayerHealth( target, pHealth );
            if ( pHealth != 100.0 ) {
                SetPlayerHealth( target, pHealth + 4.0 );
                GameTextForPlayer( target, "~w~Being healed", 500, 3 );
            }
        }
    }
    return 1;
}
EDIT: Added a quick filterscript.