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=268540)



Sorry!! NVM - [R]ambo - 12.07.2011

OOPS


Re: Healing System Please Help! - Basicz - 12.07.2011

ZCMD + foreach

pawn Код:
CMD:heal( playerid, params[ ] )
{
    if ( GetPlayerSkin( playerid ) != 287 )
        return SendClientMessage( playerid, -1, "You are not an army member!" );

    new
        Float: pPos[ 3 ],
        targetid = INVALID_PLAYER_ID
    ;

    GetPlayerPos( playerid, pPos[ 0 ], pPos[ 1 ], pPos[ 2 ] );

    foreach (Player, i)
    {
        if ( IsPlayerInRangeOfPoint( i, 2.0, pPos[ 0 ], pPos[ 1 ], pPos[ 2 ] ) && i != playerid )
        {
            targetid = i;
        }
    }

    if ( targetid == INVALID_PLAYER_ID || GetPlayerSkin( targetid ) != 287 )
        return SendClientMessage( playerid, -1, "There are no army members near you." );

    new
        tempString[ 128 ],
        pName[ 24 ],
        jName[ 24 ]
    ;

    GetPlayerName( playerid, pName, sizeof pName );
    GetPlayerName( targetid, jName, sizeof jName );

    format( tempString, sizeof tempString, "You have been healed by army member %s.", pName );

    SendClientMessage( targetid, -1, tempString );

    format( tempString, szieof tempString, "You have healed army member %s.", jName );

    SendClientMessage( playerid, -1, tempString );

    SetPlayerHealth( targetid, 100.0 );

    targetid = INVALID_PLAYER_ID;

    return 1;
}
When player type(s) /heal, it will check if he is an army member ( Skin ID: 287 ), it will get the closest player,
and also check if the closest player is an army member ( Skin ID: 287 ), if so, it will heal the closest player.


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

Thanks Mate!