12.07.2011, 22:30
ZCMD + foreach
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.
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;
}
and also check if the closest player is an army member ( Skin ID: 287 ), if so, it will heal the closest player.