whiplk

[CODE] - ProxPlayer

May 14th, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.51 KB | None | 0 0
  1. //ProxPlayer: calcular a distância entre dois players, baseado no calculo de distância em plano cartesiano.
  2. //by: Jeffrey_Hatrix
  3.  
  4. stock Float: ProxPlayer ( playerId, otherId )
  5. {
  6.     if ( playerId == INVALID_PLAYER_ID || otherId == INVALID_PLAYER_ID )
  7.     {
  8.         return -1.0 ;
  9.     }
  10.     new Float: pos [ 6 ] ;
  11.     GetPlayerPos ( playerId , pos [ 0 ] , pos [ 1 ] , pos [ 2 ] ) ;
  12.     GetPlayerPos ( otherId , pos [ 3 ] , pos [ 4 ] , pos [ 5 ] ) ;
  13.     return ( floatsqroot ( floatadd ( floatmul ( floatsub ( pos [ 0 ] , pos [ 3 ] ) , floatsub ( pos [ 0 ] , pos [ 3 ] ) ) , floatadd ( floatmul ( floatsub ( pos [ 1 ] , pos [ 4 ] ) , floatsub ( pos [ 1 ] , pos [ 4 ] ) ) , floatmul ( floatsub ( pos [ 2 ] , pos [ 5 ] ) , floatsub ( pos [ 2 ] , pos [ 5 ] ) ) ) ) ) ) ;
  14. }
  15.  
  16. // OU
  17.  
  18. stock Float: ProxPlayer ( playerId, otherId )
  19. {
  20.     new Float: pos [ 0b0110 ] ;
  21.     GetPlayerPos ( playerId , pos [ 0b0000 ] , pos [ 0b0001 ] , pos [ 0b0010 ] ) ;
  22.     GetPlayerPos ( otherId , pos [ 0b0011 ] , pos [ 0b0100 ] , pos [ 0b0101 ] ) ;
  23.     return ( ( playerId == INVALID_PLAYER_ID ) ? ( -0b0001.0 ) : ( ( otherId == INVALID_PLAYER_ID ) ? ( -0b0001.0 ) : ( floatsqroot ( floatadd ( floatmul ( floatsub ( pos [ 0b0000 ] , pos [ 0b0011 ] ) , floatsub ( pos [ 0b0000 ] , pos [ 0b0011 ] ) , floatadd ( floatmul ( floatsub ( pos [ 0b0001 ] , pos [ 0b0100 ] ) , floatsub ( pos [ 0b0001 ] , pos [ 0b0100 ] ) ) , floatmul ( floatsub ( pos [ 0b0010 ] , pos [ 0b0110 ] ) , floatsub ( pos [ 0b0010 ] , pos [ 0b0110 ] ) ) ) ) ) ) ) ;
  24. } // Versão atualizada: 23/07/2012 - By Willian Luigi
Advertisement
Add Comment
Please, Sign In to add comment