09.12.2012, 10:52
Not finished, you should make it. I'll just give you some tips for the beginning.
pawn Код:
#define GetDistanceBetweenCoords(%1,%2,%3,%4,%5,%6) floatsqroot((%4 - %1)*(%4 - %1) + (%5 - %2)*(%5 - %2) + (%6 - %3)*(%6 - %3))
command(rob, playerid, params[])
{
new
ID
;
if( !sscanf( params, "r", ID ) )
{
// Rob the ID
}
else GetPlayerClosestPlayer( playerid );
return 1;
}
stock GetPlayerClosestPlayer(playerid,bool:NPC = true)
{
new pid = INVALID_PLAYER_ID,
Float:distance = 8.0,
Float:tmp[7];
GetPlayerPos(playerid,tmp[0],tmp[1],tmp[2]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(i == playerid) continue;
if(!IsPlayerConnected(i)) continue;
if(NPC == false) if(IsPlayerNPC(i)) continue;
GetPlayerPos(i,tmp[3],tmp[4],tmp[5]);
tmp[6] = GetDistanceBetweenCoords(tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]);
if(distance < tmp[6]) continue;
distance = tmp[6];
pid = i;
}
return pid;
}